-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
153 lines (119 loc) · 4.31 KB
/
CMakeLists.txt
File metadata and controls
153 lines (119 loc) · 4.31 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
########################################################################
# Preamble
########################################################################
cmake_minimum_required( VERSION 3.27 )
set( subproject OFF )
if( DEFINED PROJECT_NAME )
set( subproject ON )
endif()
project( ACEtk
VERSION 1.0.4
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(
ACEtk.tests
"Build the ACEtk unit tests and integrate with ctest" ON
"BUILD_TESTING AND NOT ${subproject}" OFF
)
cmake_dependent_option(
ACEtk.python
"Build ACEtk python bindings" ON
"NOT ${subproject} OR DEFINED require.ACEtk.python " OFF
)
if ( ACEtk.python )
set( require.tools.python CACHE BOOL ON )
endif()
option( ACEtk.installation "Install ACEtk" ON )
########################################################################
# Dependencies
########################################################################
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/.cmake)
include( cmake/dependencies.cmake )
########################################################################
# Project targets
########################################################################
string( CONCAT prefix
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# ACEtk : library
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add_library( ACEtk INTERFACE )
add_library( njoy::ACEtk ALIAS ACEtk)
target_include_directories( ACEtk INTERFACE ${prefix} )
target_link_libraries( ACEtk
INTERFACE
njoy::tools
)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# ACEtk : python bindings
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (ACEtk.python AND NOT TARGET njoy::tools.python)
message(WARNING "njoy::tools was not built with python enabled. Disabling build of ACEtk's python API.")
set(ACEtk.python OFF)
endif()
if ( ACEtk.python )
add_subdirectory( python )
endif()
if( ACEtk.tests )
add_subdirectory( test )
endif()
#######################################################################
# Installation
#######################################################################
if(ACEtk.installation)
include(CMakePackageConfigHelpers)
install(TARGETS ACEtk EXPORT ACEtk-targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
install(EXPORT ACEtk-targets
FILE "ACEtk-targets.cmake"
NAMESPACE njoy::
DESTINATION share/cmake/ACEtk
)
install(DIRECTORY src/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING PATTERN "*.hpp"
PATTERN "*test*" EXCLUDE
)
string(TOLOWER ACEtk lowercasePackageName)
write_basic_package_version_file("${lowercasePackageName}-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${lowercasePackageName}-config.cmake.in
${PROJECT_BINARY_DIR}/${lowercasePackageName}-config.cmake
INSTALL_DESTINATION share/cmake/ACEtk
)
install(FILES
"${PROJECT_BINARY_DIR}/${lowercasePackageName}-config.cmake"
"${PROJECT_BINARY_DIR}/${lowercasePackageName}-config-version.cmake"
DESTINATION share/cmake/ACEtk
)
if(NOT subproject)
set(CPACK_PACKAGE_VENDOR "Los Alamos National Laboratory")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
include(CPack)
endif()
endif()
########################################################################
# Windows-specific setup
########################################################################
# enable Edit and Continue in Visual Studio (for debugging)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(MSVC)
target_compile_options(${PROJECT_NAME} INTERFACE "/ZI")
target_link_options(${PROJECT_NAME} INTERFACE "/INCREMENTAL")
endif()
endif()