From 14061f1e118f3380705b1d95c2ec770d2ccf3c79 Mon Sep 17 00:00:00 2001 From: Arjen Hoogesteger <65287900+sweco-nlahoo@users.noreply.github.com> Date: Wed, 19 May 2021 17:50:22 +0200 Subject: [PATCH] :hammer_and_wrench: User set CMake install subdirectory + cross-platform default location (#142) * Changed the JWT_CMAKE_FILES_INSTALL_DIR such that it is found on both Windows and Unix and that it may be configured to something entirely different * Update cmake.yml * Update cmake.yml * Update CMakeLists.txt Co-authored-by: Chris Mc * Update .github/workflows/cmake.yml Co-authored-by: Chris Mc * Update .github/workflows/cmake.yml Co-authored-by: Chris Mc * Update .github/workflows/cmake.yml Co-authored-by: Chris Mc Co-authored-by: Arjen Hoogesteger Co-authored-by: Arjen Hoogesteger <65287900+sweco-nlahoo@users.noreply.github.com> * Update CMakeLists.txt * Update CMakeLists.txt * Update traits.yml * trying different cmake path + debug in actions * fix typo * quick test for installing in lib dir * revert Co-authored-by: Chris Mc --- .github/workflows/cmake.yml | 65 ++++++++++++++++++++++++++++++++++-- .github/workflows/traits.yml | 6 ++-- CMakeLists.txt | 5 ++- 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index cff18ff..033152f 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -13,6 +13,45 @@ on: - ".github/workflows/cmake.yml" jobs: + default-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: lukka/get-cmake@latest + + - name: setup + run: | + mkdir build + cd build + cmake .. -DJWT_BUILD_EXAMPLES=OFF + sudo make install + + - name: test + run: | + cd tests/cmake + cmake . -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1 + cmake --build . + + default-win: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: lukka/get-cmake@latest + - run: choco install openssl + + - name: setup + run: | + cmake -E make_directory build + cd build + cmake .. -DJWT_BUILD_EXAMPLES=OFF + cmake --install . + + - name: test + run: | + cd tests/cmake + cmake . -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1 + cmake --build . + min-req: runs-on: ubuntu-latest steps: @@ -34,10 +73,10 @@ jobs: - name: test run: | cd tests/cmake - cmake . -DCMAKE_PREFIX_PATH=/usr/local/cmake -DTEST:STRING="defaults-enabled" + cmake . -DTEST:STRING="defaults-enabled" cmake --build . - custom-install: + custom-install-linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -54,7 +93,27 @@ jobs: - name: test run: | cd tests/cmake - cmake . -DCMAKE_PREFIX_PATH=/opt/jwt-cpp/cmake -DTEST:STRING="defaults-enabled" + cmake . -DCMAKE_PREFIX_PATH="/opt/jwt-cpp" -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1 + cmake --build . + + custom-install-win: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: lukka/get-cmake@latest + - run: choco install openssl + + - name: setup + run: | + cmake -E make_directory build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX:STRING="C:/jwt-cpp" -DJWT_BUILD_EXAMPLES=OFF + cmake --install . + + - name: test + run: | + cd tests/cmake + cmake . -DCMAKE_PREFIX_PATH="C:/jwt-cpp" -DTEST:STRING="defaults-enabled" -DCMAKE_FIND_DEBUG_MODE=1 cmake --build . no-pico: diff --git a/.github/workflows/traits.yml b/.github/workflows/traits.yml index b60c77f..52193c6 100644 --- a/.github/workflows/traits.yml +++ b/.github/workflows/traits.yml @@ -25,12 +25,12 @@ jobs: run: | mkdir build cd build - cmake .. -DJWT_BUILD_EXAMPLES=OFF - sudo make install + cmake .. -DJWT_BUILD_EXAMPLES=OFF -DCMAKE_FIND_DEBUG_MODE=1 + sudo cmake --install . - name: test run: | cd tests/jsoncons - cmake . -DCMAKE_PREFIX_PATH=/usr/local/cmake + cmake . -DCMAKE_FIND_DEBUG_MODE=1 cmake --build . ./jsoncons-traits-narrow diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c01d0c..c5f1d20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,10 @@ if(JWT_EXTERNAL_PICOJSON) target_link_libraries(jwt-cpp INTERFACE picojson::picojson>) endif() -set(JWT_CMAKE_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/cmake/jwt-cpp) +if(NOT JWT_CMAKE_FILES_INSTALL_DIR) + set(JWT_CMAKE_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/cmake) +endif() + configure_package_config_file( ${CMAKE_CURRENT_LIST_DIR}/cmake/jwt-cpp-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-config.cmake INSTALL_DESTINATION ${JWT_CMAKE_FILES_INSTALL_DIR} PATH_VARS JWT_EXTERNAL_PICOJSON JWT_SSL_LIBRARY)