forked from njoy/dryad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
122 lines (94 loc) · 3.37 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
114
115
116
117
118
119
120
121
122
########################################################################
# Preamble
########################################################################
cmake_minimum_required( VERSION 3.14 )
set( subproject OFF )
if( DEFINED PROJECT_NAME )
set( subproject ON )
endif()
project( dryad
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(
dryad.tests
"Build the dryad unit tests and integrate with ctest" ON
"BUILD_TESTING AND NOT ${subproject}" OFF
)
cmake_dependent_option(
dryad.python
"Build dryad python bindings" ON
"NOT ${subproject}" OFF
)
if ( dryad.python )
set( require.ENDFtk.python CACHE BOOL ON )
endif()
########################################################################
# 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
########################################################################
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# dryad : library
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add_library( dryad INTERFACE )
add_library( njoy::dryad ALIAS dryad )
target_include_directories( dryad
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries( dryad
INTERFACE
njoy::ENDFtk
njoy::scion
njoy::tools
)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# dryad : python bindings
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if( dryad.python )
FetchContent_MakeAvailable( pybind11 )
pybind11_add_module( dryad.python
python/src/dryad.python.cpp
)
target_link_libraries( dryad.python PRIVATE dryad )
add_dependencies( dryad.python ENDFtk.python )
target_include_directories( dryad.python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/python/src )
target_compile_options( dryad.python PRIVATE "-fvisibility=hidden" )
set_target_properties( dryad.python PROPERTIES OUTPUT_NAME dryad )
set_target_properties( dryad.python PROPERTIES COMPILE_DEFINITIONS "PYBIND11" )
set_target_properties( dryad.python PROPERTIES POSITION_INDEPENDENT_CODE ON )
message( STATUS "Building dryad's python API" )
list( APPEND DRYAD_PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR} )
list( APPEND ENDFTK_PYTHONPATH ${CMAKE_CURRENT_BINARY_DIR}/_deps/endftk-build )
if( dryad.tests )
include( cmake/unit_testing_python.cmake )
endif()
endif()
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
if( dryad.tests )
include( cmake/unit_testing.cmake )
endif()
endif()