-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (73 loc) · 3.1 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
cmake_minimum_required(VERSION 3.0)
project(utils C CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(cmake/platform.cmake)
set_platform_properties()
option(USE_CONAN "Use Conan Package Manager to deal with dependencies" ON)
if(USE_CONAN)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
endif()
message("Generator: ${CMAKE_GENERATOR}")
# Set global platform variable for source directories
if (UNIX)
set(PLATFORM "Linux")
elseif (WIN32 AND MSVC)
set(PLATFORM "Windows")
endif()
# Project options
option(BUILD_TESTS "Build tests" ON)
# Testing library include dir
set(CATCH_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/test/include")
# .cmake files
file(GLOB UTILS_CMAKE_SCRIPTS ${PROJECT_SOURCE_DIR}/cmake/*.cmake)
########################################################################################################################
# Target definitions
########################################################################################################################
# common
set(COMMON_HEADERS ${PROJECT_SOURCE_DIR}/common/include/common/Optional.h
${PROJECT_SOURCE_DIR}/common/include/common/Value.h
${PROJECT_SOURCE_DIR}/common/include/common/Utility.h)
add_library(common INTERFACE)
target_sources(common INTERFACE ${COMMON_HEADERS})
target_include_directories(common INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/common/include>)
# thread
set(THREAD_HEADERS ${PROJECT_SOURCE_DIR}/thread/include/thread/Threadpool.h
${PROJECT_SOURCE_DIR}/thread/include/thread/ActiveWorker.h)
add_library(thread INTERFACE)
target_sources(thread INTERFACE ${THREAD_HEADERS})
target_include_directories(thread INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/thread/include>)
if(UNIX)
target_link_libraries(thread INTERFACE pthread)
endif()
# scheduler
set(SCHEDULER_HEADERS ${PROJECT_SOURCE_DIR}/scheduler/include/scheduler/Scheduler.h)
set(SCHEDULER_SOURCES ${PROJECT_SOURCE_DIR}/scheduler/src/Scheduler.cpp
${PROJECT_SOURCE_DIR}/scheduler/src/Scheduler${PLATFORM}.cpp)
add_library(scheduler ${SCHEDULER_HEADERS} ${SCHEDULER_SOURCES})
target_include_directories(scheduler PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/scheduler/include>)
if(UNIX)
target_link_libraries(scheduler PRIVATE rt
INTERFACE pthread)
endif()
# Add executable (for manual testing)
add_executable(utils_exe ${PROJECT_SOURCE_DIR}/common/src/Main.cpp)
target_link_libraries(utils_exe scheduler)
# Add subdirectories
if(BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
option(BUILD_DOC "Build documentation" ON)
# check if Doxygen is installed
if(BUILD_DOC)
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_GENERATE_LATEX YES)
doxygen_add_docs(headers_doc ${UTILS_HEADERS} ${PROJECT_SOURCE_DIR}/Readme.md COMMENT "Generating API documentation with Doxygen")
#doxygen_add_docs(user_doc ${PROJECT_SOURCE_DIR}/Readme.md COMMENT "Generating User documentation with Doxygen")
else ()
message("Doxygen needs to be installed to generate the doxygen documentation")
endif ()
endif()