Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ROARING_USE_CPM option in CMake #532

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ endif()

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")

include(cmake/CPM.cmake)
option(ROARING_USE_CPM "Use CPM to fetch dependencies" ON)

if(ROARING_USE_CPM)
include(cmake/CPM.cmake)
endif()
find_package(CTargets)
find_package(Options)
find_package(LTO)
Expand Down
28 changes: 16 additions & 12 deletions microbenchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ set (BENCHMARK_DATA_DIR "${PROJECT_SOURCE_DIR}/benchmarks/realdata/")

include(${PROJECT_SOURCE_DIR}/tools/cmake/Import.cmake)

set_off(BENCHMARK_ENABLE_TESTING)
set_off(BENCHMARK_ENABLE_INSTALL)
set_off(BENCHMARK_ENABLE_WERROR)
set(BENCHMARK_ENABLE_WERROR OFF)
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
GIT_TAG 3441176
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF"
"BENCHMARK_ENABLE_WERROR OFF"
if(ROARING_USE_CPM)
set_off(BENCHMARK_ENABLE_TESTING)
set_off(BENCHMARK_ENABLE_INSTALL)
set_off(BENCHMARK_ENABLE_WERROR)
set(BENCHMARK_ENABLE_WERROR OFF)
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
GIT_TAG 3441176
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF"
"BENCHMARK_ENABLE_WERROR OFF"

)
)
else()
find_package(benchmark REQUIRED)
endif()

add_executable(bench bench.cpp)
target_link_libraries(bench PRIVATE roaring)
Expand Down
24 changes: 18 additions & 6 deletions tools/cmake/FindCTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ endif ()
include(${PROJECT_SOURCE_DIR}/tools/cmake/Import.cmake)
set(BUILD_STATIC_LIB ON)
if (ENABLE_ROARING_TESTS)
CPMAddPackage(
NAME cmocka
GITHUB_REPOSITORY clibs/cmocka
GIT_TAG f5e2cd7
if(ROARING_USE_CPM)
CPMAddPackage(
NAME cmocka
GITHUB_REPOSITORY clibs/cmocka
GIT_TAG f5e2cd7
)
else()
find_package(cmocka REQUIRED)
endif()
endif()

function(add_c_test TEST_NAME)
Expand All @@ -18,7 +22,11 @@ function(add_c_test TEST_NAME)

add_executable(${TEST_NAME} ${TEST_NAME}.c)

target_link_libraries(${TEST_NAME} roaring cmocka-static)
if(ROARING_USE_CPM)
target_link_libraries(${TEST_NAME} roaring cmocka-static)
else()
target_link_libraries(${TEST_NAME} roaring cmocka)
endif()

add_test(${TEST_NAME} ${TEST_NAME})
endfunction(add_c_test)
Expand All @@ -35,7 +43,11 @@ if (CMAKE_VERSION VERSION_GREATER 2.8.10)
get_directory_property(parent_dir PARENT_DIRECTORY)
target_include_directories(${TEST_NAME} PRIVATE "${parent_dir}/cpp")

target_link_libraries(${TEST_NAME} roaring cmocka-static)
if(ROARING_USE_CPM)
target_link_libraries(${TEST_NAME} roaring cmocka-static)
else()
target_link_libraries(${TEST_NAME} roaring cmocka)
endif()

add_test(${TEST_NAME} ${TEST_NAME})
endfunction(add_cpp_test)
Expand Down
Loading