diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index e8c5b02ed3..9d273706cc 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -207,40 +207,70 @@ jobs: [ ! -d "build/src/tests/googletest-src" ] cmake-system-sexpp: + name: system-sexpp, sexpp shared libs ${{ matrix.sexpp_shared_libs }}, rnp shared libs ${{ matrix.rnp_shared_libs }} runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'skip ci')" timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + sexpp_shared_libs: [ 'on' ] + rnp_shared_libs: ['on'] + steps: - - name: Checkout + - name: Install dependencies + run: | + sudo apt-get -y update + sudo apt-get -y install cmake libjson-c-dev libbotan-2-dev asciidoctor + + - name: Checkout sexpp uses: actions/checkout@v3 with: - fetch-depth: 1 - submodules: true + repository: rnpgp/sexpp + path: sexpp - - name: Install dependencies + - name: Configure sexpp run: | - sudo apt-get -y update - sudo apt-get -y install cmake libjson-c-dev libbotan-2-dev asciidoctor googletest + echo CORES="$(nproc --all)" >> $GITHUB_ENV + cmake -S sexpp -B sexpp/build \ + -DCMAKE_BUILD_TYPE=Release \ + -DDOWNLOAD_GTEST=ON \ + -DBUILD_SHARED_LIBS=${{ matrix.sexpp_shared_libs}} + + - name: Build sexpp + run: cmake --build sexpp/build --parallel ${{ env.CORES }} + + - name: Install sexpp + run: sudo cmake --install sexpp/build + + - name: Clean sexpp + run: rm -rf sexpp + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 1 + submodules: false - name: Configure run: | - echo CORES="$(nproc --all)" >> $GITHUB_ENV - cmake -B build -DBUILD_SHARED_LIBS=ON \ - -DCRYPTO_BACKEND=botan \ - -DDOWNLOAD_GTEST=OFF \ - -DSYSTEM_SEXPP=ON \ - -DCMAKE_BUILD_TYPE=Release . - + cmake -B build \ + -DBUILD_SHARED_LIBS=${{ matrix.rnp_shared_libs }} \ + -DCRYPTO_BACKEND=botan \ + -DDOWNLOAD_GTEST=ON \ + -DSYSTEM_LIBSEXPP=ON \ + -DCMAKE_BUILD_TYPE=Release . + - name: Build run: cmake --build build --parallel ${{ env.CORES }} - + - name: Test run: | mkdir -p "build/Testing/Temporary" cp "cmake/CTestCostData.txt" "build/Testing/Temporary" export PATH="$PWD/build/src/lib:$PATH" ctest --parallel ${{ env.CORES }} --test-dir build -C Debug --output-on-failure - + package-source: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'skip ci')" diff --git a/CMakeLists.txt b/CMakeLists.txt index 5310bb112e..da56fd2c6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ option(ENABLE_COVERAGE "Enable code coverage testing.") option(ENABLE_SANITIZERS "Enable ASan and other sanitizers.") option(ENABLE_FUZZERS "Enable fuzz targets.") option(DOWNLOAD_GTEST "Download Googletest" On) -option(SYSTEM_LIBSEXP "Use system sexp library" OFF) +option(SYSTEM_LIBSEXPP "Use system sexpp library" OFF) # crypto components function(tristate_feature_auto NAME DESCRIPTION) @@ -184,11 +184,28 @@ if (ENABLE_FUZZERS) endif() add_subdirectory(src/common) -if (SYSTEM_LIBSEXP) - find_package(PkgConfig) - pkg_check_modules(REQUIRED sexpp>=0.8.5) -else (SYSTEM_LIBSEXP) -# force static libsexpp +if (SYSTEM_LIBSEXPP) + find_package(PkgConfig QUIET) + pkg_check_modules(SEXPP sexpp>=0.8.7 REQUIRED) + find_library(SEXPP_LIBRARY + NAMES + "libsexpp" + "sexpp" + HINTS + "${SEXPP_LIBRARY_DIRS}" + ) + add_library(sexpp UNKNOWN IMPORTED) + set_target_properties(sexpp + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${SEXPP_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${SEXPP_LIBRARY}" + ) +else (SYSTEM_LIBSEXPP) +# If we use system libsexpp is not used we build sexpp static library +# If librnp is shared, libsexpp.a is a transient artifact which is hidden from +# the end user. +# If librnp is static we install libsexpp.a aside set(SAVED_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) set(BUILD_SHARED_LIBS OFF) set(WITH_SEXP_CLI OFF) @@ -196,7 +213,7 @@ else (SYSTEM_LIBSEXP) set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME development) add_subdirectory(src/libsexpp EXCLUDE_FROM_ALL) set(BUILD_SHARED_LIBS ${SAVED_BUILD_SHARED_LIBS}) -endif (SYSTEM_LIBSEXP) +endif (SYSTEM_LIBSEXPP) add_subdirectory(src/lib) add_subdirectory(src/rnp) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index d21ba7b679..40715f998c 100755 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -334,6 +334,7 @@ target_include_directories(librnp-obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/src" + "${SEXPP_INCLUDE_DIRS}" ) target_link_libraries(librnp-obj PRIVATE JSON-C::JSON-C) if (CRYPTO_BACKEND_BOTAN) @@ -431,8 +432,8 @@ endif() # On Unix like systems we will build/install/pack either shared library librnp.so or static librnp.a # On Windows we will build/install/pack either dynamic and import libraries rnp.dll, rnp.lib or static library rnp-static.lib -# If a client application uses shared rnp library, sexp is statically linked to librnp.so and libsexp.a is not installed -# If a client application uses static rnp library, it still needs libsexp.a and it is installed +# If a client application uses shared rnp library, sexpp is statically linked to librnp.so and libsexpp.a is not installed +# If a client application uses static rnp library, it still needs libsexpp.a and it is installed if (BUILD_SHARED_LIBS) install(TARGETS librnp @@ -455,13 +456,23 @@ if (BUILD_SHARED_LIBS) ) endif(WIN32) else(BUILD_SHARED_LIBS) -# static libraries only - install(TARGETS librnp sexpp +# static libraries +# install libsexpp unless system-installed libsexpp is used + if (SYSTEM_LIBSEXPP) + install(TARGETS librnp + EXPORT rnp-targets + ARCHIVE + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT development + ) + else (SYSTEM_LIBSEXPP) + install(TARGETS librnp sexpp EXPORT rnp-targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT development - ) + ) + endif (SYSTEM_LIBSEXPP) endif(BUILD_SHARED_LIBS) # install headers diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 62fc2201b8..c539d761de 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -181,6 +181,7 @@ target_include_directories(rnp_tests "${PROJECT_SOURCE_DIR}/src" "${PROJECT_SOURCE_DIR}/src/lib" "${BOTAN_INCLUDE_DIRS}" + "${SEXPP_INCLUDE_DIRS}" ) target_link_libraries(rnp_tests PRIVATE