-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
62 lines (45 loc) · 1.41 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
cmake_minimum_required(VERSION 3.10.0)
project(tdp VERSION 0.0.1)
add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
find_package(Threads REQUIRED)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
target_link_libraries(${PROJECT_NAME} INTERFACE Threads::Threads)
# Examples and Unit testing
option(TDP_BUILD_EXAMPLES "Build TDP examples" OFF)
option(TDP_BUILD_TESTS "Build TDP unit tests" OFF)
if(${TDP_BUILD_EXAMPLES})
add_subdirectory(examples)
endif()
if(${TDP_BUILD_TESTS})
enable_testing()
add_subdirectory(tests)
endif()
# Install interface
set(IS_ROOT_DIRECTORY OFF)
if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
set(IS_ROOT_DIRECTORY ON)
endif ()
option(TDP_INSTALL "Generate the TDP install interface" ${IS_ROOT_DIRECTORY})
if(TDP_INSTALL)
include(GNUInstallDirs)
target_include_directories(${PROJECT_NAME} INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
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_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
endif()