forked from njoy/NDItk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
113 lines (85 loc) · 3.11 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
101
102
103
104
105
106
107
108
109
110
111
112
113
########################################################################
# Preamble
########################################################################
cmake_minimum_required( VERSION 3.14 )
set( subproject OFF )
if( DEFINED PROJECT_NAME )
set( subproject ON )
endif()
project( NDItk
VERSION 0.1.0
LANGUAGES CXX
)
include( CTest )
include( CMakeDependentOption )
include( GNUInstallDirs )
########################################################################
# Project-wide setup
########################################################################
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED YES )
cmake_dependent_option(
NDItk.tests
"Build the NDItk unit tests and integrate with ctest" ON
"BUILD_TESTING AND NOT ${subproject}" OFF
)
cmake_dependent_option(
NDItk.python
"Build NDItk python bindings" ON
"NOT ${subproject}" OFF
)
########################################################################
# Dependencies
########################################################################
set( REPOSITORIES "release"
CACHE STRING
"Options for where to fetch repositories: develop, release, local"
)
message( STATUS "Using ${REPOSITORIES} repositories" )
if( REPOSITORIES STREQUAL "develop" )
include( cmake/develop_dependencies.cmake )
elseif( REPOSITORIES STREQUAL "release" )
include( cmake/release_dependencies.cmake )
elseif( REPOSITORIES STREQUAL "local" )
include( cmake/local_dependencies.cmake )
endif()
########################################################################
# Project targets
########################################################################
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# NDItk : library
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add_library( NDItk INTERFACE )
add_library( njoy::NDItk ALIAS NDItk )
target_include_directories( NDItk
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries( NDItk
INTERFACE
njoy::tools
)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# NDItk : python bindings
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if( NDItk.python )
FetchContent_MakeAvailable( pybind11 )
pybind11_add_module( NDItk.python
python/src/NDItk.python.cpp
)
target_link_libraries( NDItk.python PRIVATE NDItk )
target_include_directories( NDItk.python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/python/src )
target_compile_options( NDItk.python PRIVATE "-fvisibility=hidden" )
set_target_properties( NDItk.python PROPERTIES OUTPUT_NAME NDItk )
set_target_properties( NDItk.python PROPERTIES COMPILE_DEFINITIONS "PYBIND11" )
set_target_properties( NDItk.python PROPERTIES POSITION_INDEPENDENT_CODE ON )
message( STATUS "Building NDItk's python API" )
list( APPEND NDItk_PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR} )
include( cmake/unit_testing_python.cmake )
endif()
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
if( NDItk.tests )
include( cmake/unit_testing.cmake )
endif()
endif()