-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
68 lines (60 loc) · 2.28 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
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.15)
project(thh-handle-vector LANGUAGES CXX)
include(FetchContent)
include(GNUInstallDirs)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(
${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
option(THH_HANDLE_ENABLE_TEST "Enable testing" OFF)
option(THH_HANDLE_ENABLE_BENCH "Enable benchmarking" OFF)
if(THH_HANDLE_ENABLE_TEST)
FetchContent_Declare(
doctest
GIT_REPOSITORY https://github.com/onqtam/doctest.git
GIT_TAG ae7a13539fb71f270b87eb2e874fbac80bc8dda2)
FetchContent_MakeAvailable(doctest)
add_executable(${PROJECT_NAME}-test)
target_sources(${PROJECT_NAME}-test PRIVATE test.cpp)
target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME} doctest)
target_compile_options(
${PROJECT_NAME}-test
PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/W4
/WX>
$<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang>:
-Weverything
-Wall
-Wextra
-pedantic
-Wno-c++98-compat;-Wno-
-Wno-sign-conversion;-Wno-
-Wno-padded;-Wno->
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wall
-Wextra
-pedantic>)
endif()
if(THH_HANDLE_ENABLE_BENCH)
set(BENCHMARK_ENABLE_TESTING OFF)
FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG 4b13b3d47a9ad3bb4b83bde3c3841b2b0b5c5789)
FetchContent_MakeAvailable(benchmark)
add_executable(${PROJECT_NAME}-bench)
target_sources(${PROJECT_NAME}-bench PRIVATE bench.cpp)
target_link_libraries(${PROJECT_NAME}-bench ${PROJECT_NAME} benchmark)
target_compile_options(
${PROJECT_NAME}-bench
PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/W4 /WX>
$<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang,GNU>: -Wall -Wextra
-pedantic>)
endif()
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-config)
install(
EXPORT ${PROJECT_NAME}-config
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/${PROJECT_NAME}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})