Skip to content

Commit

Permalink
Use system Catch2 library instead of bundled one if found. (dashpay#25)
Browse files Browse the repository at this point in the history
Bundled Catch2 library (2.13.4) is outdated and doesn't compile with
glibc 2.34 because MINSIGSTKSZ is not a constant anymore.

Fortunately, this problem is fixed in newer version of Catch2,
and modern Linux distros (like Fedora) have this library in its repos.

This change makes cmake check for Catch2 provided by the system and
use it instead of bundled one if found.

Also, it adds include directories needed by "catch.hpp" only to
runtest target because it's used only there.

Signed-off-by: Oleg Girko <ol@infoserver.lv>

Co-authored-by: Oleg Girko <ol@infoserver.lv>
  • Loading branch information
OlegGirko and Oleg Girko authored Nov 28, 2021
1 parent 4b1d080 commit 40f47e6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,19 @@ install(FILES ${includes} DESTINATION include/bls-dash)
install(FILES ${C_LIB} DESTINATION lib)

if (BUILD_BLS_TESTS)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/catch)
add_executable(runtest test.cpp)
pkg_check_modules(CATCH2 catch2)
if (CATCH2_FOUND)
# Adding "catch2" subdir to include dirs because "catch.hpp" is included
# instead of "catch2/catch.hpp"
if (NOT CATCH2_INCLUDE_DIRS)
set(CATCH2_INCLUDE_DIRS ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif()
list(TRANSFORM CATCH2_INCLUDE_DIRS APPEND /catch2)
target_include_directories(runtest PRIVATE ${CATCH2_INCLUDE_DIRS})
else()
target_include_directories(runtest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/catch)
endif()
if (SODIUM_FOUND)
target_link_libraries(runtest blstmp relic_s sodium)
else()
Expand Down

0 comments on commit 40f47e6

Please sign in to comment.