-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
59 lines (46 loc) · 2.24 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
cmake_minimum_required (VERSION 3.5)
project (mp)
# ------------------------------------------------------------------------
# Flags that are expected to be shared when added as sub-directory
# ------------------------------------------------------------------------
if (NOT CMAKE_BUILD_TYPE)
message (STATUS "Build type not specified. Set by default to DEBUG!")
set (CMAKE_BUILD_TYPE Debug)
endif ()
# ------------------------------------------------------------------------
# Flags that are NOT expected to be shared when added as sub-directory
# ------------------------------------------------------------------------
option (mp_BUILD_ASAN "Enable address sanitizer" OFF)
option (mp_BUILD_SAMPLES "Build samples" ON)
option (mp_BUILD_TESTS "Build tests" ON)
# ------------------------------------------------------------------------
# Actual configuration
# ------------------------------------------------------------------------
add_compile_options ("$<$<COMPILE_LANGUAGE:CXX>:-std=c++11>")
add_compile_options (-Wall -Wextra -pedantic -Werror)
include_directories (include)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/out")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
if (mp_BUILD_SAMPLES OR mp_BUILD_TESTS)
set (mp_UTILS_ROOT "utils")
add_library (test_c SHARED "${mp_UTILS_ROOT}/lib/c/lib.c")
add_library (test_cpp SHARED "${mp_UTILS_ROOT}/lib/cpp/lib.cpp")
endif ()
if (mp_BUILD_SAMPLES)
set (mp_SAMPLES_ROOT "sample")
add_executable (dynamiclib "${mp_SAMPLES_ROOT}/dynamiclib.cpp")
target_link_libraries (dynamiclib PRIVATE dl)
target_include_directories (dynamiclib PRIVATE "${mp_UTILS_ROOT}")
add_executable (ipstream "${mp_SAMPLES_ROOT}/ipstream.cpp")
add_executable (opstream "${mp_SAMPLES_ROOT}/opstream.cpp")
add_executable (dstream "${mp_SAMPLES_ROOT}/dstream.cpp")
add_executable (workdir "${mp_SAMPLES_ROOT}/workdir.cpp")
endif ()
if (mp_BUILD_TESTS)
set (mp_TESTS_ROOT "test")
aux_source_directory (${mp_TESTS_ROOT} mp_TEST_SOURCES)
add_executable (unittest ${mp_TEST_SOURCES})
target_link_libraries (unittest PRIVATE dl)
target_include_directories (unittest PRIVATE "${mp_UTILS_ROOT}")
endif()