-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
101 lines (81 loc) · 2.98 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
90
91
92
93
94
95
96
97
98
99
100
# Note: 3.13 is required to install targets from other directories.
cmake_minimum_required(VERSION 3.13...3.16)
project( MartCommon
VERSION 3.0
LANGUAGES CXX
)
# guard against multiple inclusions in a single super project as we have sometimes in the mart project
if(TARGET mart-common )
get_target_property(PREV_SOURCE_DIR mart-netlib SOURCE_DIR) # NOTE: mart-common is an interface library and hence doesn't have the property SOURCE_DIR
message(WARNING "[MART-COMMON] -- \"${PROJECT_NAME}\" included multiple times --\n-- Only one directory will be built --\n-- Selected dir: ${PREV_SOURCE_DIR}")
return()
endif()
option( MART_COMMON_INCLUDE_TESTS "Build tests" OFF )
option( MART_COMMON_INCLUDE_EXAMPLES "Build examples" OFF)
option( MART_COMMON_INCLUDE_NET_LIB "Also build netlib components (Those are not header only)" ON)
option( MART_COMMON_IGNORE_STD_PARALLEL_ALGORITHMS ON)
####### im_str is a separately devoped library that was copied into mart common for convenience
#
add_subdirectory( im_str )
add_library( Mart::im_str ALIAS mart_im_str )
####### create mart-common library
#
add_library( mart-common INTERFACE )
add_library( Mart::common ALIAS mart-common )
set_target_properties( mart-common PROPERTIES EXPORT_NAME common )
target_link_libraries( mart-common INTERFACE Mart::im_str )
target_include_directories( mart-common
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_compile_features( mart-common INTERFACE cxx_std_17 )
####### create mart-netlib library
#
if( MART_COMMON_INCLUDE_NET_LIB )
# here, only interface properties are set, the build properties are set in src/mart-netlib
add_library( mart-netlib-portlayer STATIC )
add_library( Mart::netlib-portlayer ALIAS mart-netlib-portlayer )
set_target_properties ( mart-netlib-portlayer PROPERTIES EXPORT_NAME netlib-portlayer )
target_include_directories( mart-netlib-portlayer
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
add_library( mart-netlib )
add_library( Mart::netlib ALIAS mart-netlib)
set_target_properties ( mart-netlib PROPERTIES EXPORT_NAME netlib )
target_include_directories( mart-netlib
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries( mart-netlib PUBLIC Mart::common Mart::netlib-portlayer)
target_compile_features( mart-netlib INTERFACE cxx_std_17 )
add_subdirectory( src/mart-netlib )
endif()
if( MART_COMMON_INCLUDE_TESTS )
enable_testing()
add_subdirectory( tests )
endif()
# support installation
get_directory_property( hasParent PARENT_DIRECTORY )
if( NOT hasParent )
include( cmake/mart_install_targets.cmake )
set_target_properties ( mart_im_str PROPERTIES EXPORT_NAME im_str )
mart_install_targets(
PACKAGE_NAME
MartCommon
TARGETS
mart_im_str
mart-common
mart-netlib
mart-netlib-portlayer
HEADER_DIRS
im_str/include/im_str
include/mart-common
include/mart-netlib
NAMESPACE
Mart::
)
endif()
if( MART_COMMON_INCLUDE_EXAMPLES )
add_subdirectory( examples/nw )
endif()