-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
61 lines (51 loc) · 2.29 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
cmake_minimum_required(VERSION 3.7)
project(miniselect)
option(MINISELECT_TESTING "Building the tests." OFF)
option(MINISELECT_SANITIZE "Building the library with sanitizers." OFF)
option(MINISELECT_BUILD_LIBCXX "Building the library with libcxx." OFF)
option(MINISELECT_ENABLE_FUZZING "Building the library with fuzzing." OFF)
include_directories(include)
if (MINISELECT_TESTING)
enable_testing()
set(CMAKE_CXX_STANDARD 17)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
if (MINISELECT_SANITIZE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Wpedantic -Werror -Wno-gnu-zero-variadic-macro-arguments")
if (MINISELECT_BUILD_LIBCXX AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "Using libcxx as a default standard C++ library")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
message(STATUS "gtest tests are off")
add_subdirectory(benchmark)
add_subdirectory(googletest)
include_directories(testing)
include_directories(benches)
add_executable(benchmark_sort benches/benchmark_sort.cpp)
target_link_libraries(benchmark_sort benchmark::benchmark gtest)
add_executable(benchmark_select benches/benchmark_select.cpp)
target_link_libraries(benchmark_select benchmark::benchmark gtest)
set(TEST_SOURCES testing/test_select.cpp)
add_executable(test_select ${TEST_SOURCES})
target_link_libraries(test_select gtest gmock gtest_main)
add_test(NAME test_select COMMAND test_select)
set(TEST_SOURCES testing/test_sort.cpp)
add_executable(test_sort ${TEST_SOURCES})
target_link_libraries(test_sort gtest gmock gtest_main)
add_test(NAME test_sort COMMAND test_sort)
endif()
if(MINISELECT_ENABLE_FUZZING)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
message(STATUS "gtest tests are off")
add_subdirectory(benchmark)
add_subdirectory(googletest)
include_directories(testing)
add_subdirectory(fuzz)
endif()