@@ -2,34 +2,30 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
22
33project (sorting_network_cpp)
44
5- option (BUILD_BENCHMARK "Build the benchmark" ON )
6- option (BUILD_TESTS "Build the tests" OFF )
7-
8- include (cmake/Conan.cmake)
9- run_conan()
5+ option (SORTING_NETWORK_CPP_BUILD_BENCHMARK "Build the benchmark" OFF )
6+ option (SORTING_NETWORK_CPP_BUILD_TESTS "Build the tests" OFF )
107
118set (CMAKE_CXX_STANDARD 17)
129set (CMAKE_CXX_STANDARD_REQUIRED ON )
1310
11+ include (cmake/CPM.cmake)
12+
1413add_library (project_options INTERFACE )
1514target_compile_features (project_options INTERFACE cxx_std_17)
1615
1716if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC )
18- target_compile_options (project_options INTERFACE /W3 /O2 /fp:fast)
19- target_link_options (project_options INTERFACE /OPT:REF /GL)
17+ target_compile_options (project_options INTERFACE $<$< NOT :$<CONFIG:Debug>>: /W3 /O2 /fp:fast> /bigobj )
18+ target_link_options (project_options INTERFACE $<$< NOT :$<CONFIG:Debug>>: /OPT:REF /GL> )
2019elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
21- target_compile_options (project_options INTERFACE -O3 -ffast-math)
20+ target_compile_options (project_options INTERFACE $<$< NOT :$<CONFIG:Debug>>: -O3 -ffast-math> )
2221elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
23- target_compile_options (project_options INTERFACE -O3 -ffast-math)
22+ target_compile_options (project_options INTERFACE $<$< NOT :$<CONFIG:Debug>>: -O3 -ffast-math> )
2423endif ()
2524
26- add_library (sorting_network_cpp_lib INTERFACE )
27- target_include_directories (sorting_network_cpp_lib INTERFACE "include" )
25+ add_library (sorting_network_cpp INTERFACE )
26+ target_include_directories (sorting_network_cpp INTERFACE "${CMAKE_CURRENT_SOURCE_DIR} / include" )
2827
29- add_library (metal INTERFACE )
30- target_include_directories (metal INTERFACE "extern/metal/include" )
31-
32- if (BUILD_BENCHMARK)
28+ if (SORTING_NETWORK_CPP_BUILD_BENCHMARK)
3329 set (SN_BENCHMARK_EXECUTABLE_NAME ${PROJECT_NAME} _benchmark)
3430
3531 add_executable (${SN_BENCHMARK_EXECUTABLE_NAME}
@@ -42,13 +38,17 @@ if (BUILD_BENCHMARK)
4238 "src/benchmark_double.cpp"
4339 "src/benchmark_vec2i.cpp"
4440 )
45- target_link_libraries (${SN_BENCHMARK_EXECUTABLE_NAME} PRIVATE project_options sorting_network_cpp_lib )
41+ target_link_libraries (${SN_BENCHMARK_EXECUTABLE_NAME} PRIVATE project_options sorting_network_cpp )
4642endif ()
4743
48- if (BUILD_TESTS)
44+ if (SORTING_NETWORK_CPP_BUILD_TESTS)
45+ set (METAL_BUILD_DOC OFF )
46+ set (METAL_BUILD_EXAMPLES OFF )
47+ set (METAL_BUILD_TESTS OFF )
48+ CPMAddPackage("gh:brunocodutra/metal#v2.1.4" )
49+ CPMAddPackage("gh:google/googletest#release-1.12.0" )
50+
4951 set (SN_TESTS_EXECUTABLE_NAME ${PROJECT_NAME} _tests)
50- find_package (GTest REQUIRED)
51- include (GoogleTest)
5252
5353 add_executable (${SN_TESTS_EXECUTABLE_NAME}
5454 "test/test_base.h"
@@ -59,5 +59,5 @@ if(BUILD_TESTS)
5959 "test/test_insertion_sort.cpp"
6060 "test/test_size_optimized_sort.cpp"
6161 )
62- target_link_libraries (${SN_TESTS_EXECUTABLE_NAME} GTest::gtest GTest::gtest_main metal project_options sorting_network_cpp_lib )
62+ target_link_libraries (${SN_TESTS_EXECUTABLE_NAME} GTest::gtest GTest::gmock GTest:: gtest_main Metal project_options sorting_network_cpp )
6363endif ()
0 commit comments