-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
47 lines (34 loc) · 1.25 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
cmake_minimum_required(VERSION 3.14)
project(threadkit)
# ----- options ----- #
option(THREADKIT_BUILD_TESTS "build tests" ON)
option(THREADKIT_INSTALL "install headers and libs" ON)
option(THREADKIT_HOLD_DEPS "do not update existing deps" OFF)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
# ----- targets ----- #
file(GLOB_RECURSE __THREADKIT_SRC__ ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
add_library(threadkit_static STATIC ${__THREADKIT_SRC__})
unset(__THREADKIT_SRC__)
target_include_directories(threadkit_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
if(MSVC)
target_compile_options(threadkit_static PRIVATE /W4)
else()
target_compile_options(threadkit_static PRIVATE -Wall -Wextra -Werror)
endif()
# ----- dependencies ----- #
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_link_libraries(threadkit_static PUBLIC pthread)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(threadkit_static PUBLIC synchronization)
endif()
# ----- installations ----- #
if(THREADKIT_INSTALL)
install(DIRECTORY include DESTINATION .)
install(TARGETS threadkit_static DESTINATION lib)
endif()
# ----- tests ----- #
if(THREADKIT_BUILD_TESTS)
add_subdirectory(tests)
endif()