-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
248 lines (203 loc) · 7.76 KB
/
CMakeLists.txt
File metadata and controls
248 lines (203 loc) · 7.76 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# CMake build configuration for Access Layer core
cmake_minimum_required(VERSION 3.21)
if(POLICY CMP0144)
cmake_policy(SET CMP0144 NEW)
endif()
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.30)
cmake_policy(SET CMP0167 NEW) # Use system BoostConfig instead of cmake FindBoost
endif()
# Capture scikit build cmake.args
include(./skbuild-cmake-args.cmake)
# Supress a warning
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
# Configuration options for IMAS Core Backends
# ##############################################################################
option(AL_BACKEND_MDSPLUS "Build the MDSplus backend" OFF)
option(AL_BACKEND_HDF5 "Build the HDF5 backend" ON)
option(AL_BACKEND_UDA "Build the UDA backend" OFF)
option(AL_BACKEND_UDAFAT "Build the UDA backend (use FAT UDA)" OFF)
include(CMakeDependentOption)
cmake_dependent_option(AL_BUILD_MDSPLUS_MODELS "Build MDSplus models" ON
AL_BACKEND_MDSPLUS OFF)
# Configuration options for python bindings
# ##############################################################################
option(AL_PYTHON_BINDINGS "Build Python bindings" OFF)
# Configuration options for shared libraries
# ##############################################################################
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(CMAKE_INSTALL_RPATH_USE_LINK_PATH
"Append the runtime search path (rpath) to external installed binaries" TRUE)
# Configuration option for automatic download of common third party libraries
# ##############################################################################
# include(./vcpkg.cmake)
# Load common assets
# ##############################################################################
add_subdirectory(common)
# Stop here when building documentation only
if( AL_DOCS_ONLY )
return()
endif()
# Define project
# ##############################################################################
if(SKBUILD)
set(VERSION ${SKBUILD_PROJECT_VERSION})
set(FULL_VERSION ${SKBUILD_PROJECT_VERSION_FULL})
else()
# Set VERSION and FULL_VERSION from `git describe`:
include(./GitArchiveDescribe.cmake)
include(ALDetermineVersion)
endif()
project(
al-core
VERSION ${VERSION}
DESCRIPTION "Core component of the IMAS Access Layer"
HOMEPAGE_URL "https://imas.iter.org/"
LANGUAGES C CXX)
if(NOT PROJECT_VERSION_TWEAK EQUAL 0)
message("Building a development version of the Access Layer core")
endif()
if(APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
# Disable MDSPlus:
message(STATUS "Disabling MDSPlus backend on macOS")
set(AL_BACKEND_MDSPLUS OFF CACHE BOOL "MDSPlus backend" FORCE)
endif()
# Dependencies
# ##############################################################################
if(WIN32)
# Ensure vcpkg paths are in CMAKE_PREFIX_PATH for finding packages
if(DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET)
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}")
message(STATUS "al-core: Added CMAKE_PREFIX_PATH: ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}")
else()
# Try to auto-detect vcpkg installed directory from build path
if(CMAKE_CURRENT_BINARY_DIR MATCHES "(.*/build)/")
set(_BUILD_DIR "${CMAKE_MATCH_1}")
set(_VCPKG_PATH "${_BUILD_DIR}/vcpkg_installed/x64-windows")
if(EXISTS "${_VCPKG_PATH}")
list(APPEND CMAKE_PREFIX_PATH "${_VCPKG_PATH}")
message(STATUS "al-core: Auto-detected vcpkg path: ${_VCPKG_PATH}")
# Set PKG_CONFIG_EXECUTABLE for vcpkg's pkgconf
if(EXISTS "${_VCPKG_PATH}/tools/pkgconf/pkgconf.exe")
set(PKG_CONFIG_EXECUTABLE "${_VCPKG_PATH}/tools/pkgconf/pkgconf.exe" CACHE FILEPATH "pkg-config executable")
message(STATUS "al-core: Set PKG_CONFIG_EXECUTABLE to ${PKG_CONFIG_EXECUTABLE}")
endif()
endif()
endif()
endif()
message(STATUS "al-core: CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
# Add cmake module path for FindPThreads4W.cmake fallback
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/common/cmake")
# Try CONFIG mode first, fall back to MODULE mode
find_package(PThreads4W CONFIG QUIET)
if(NOT PThreads4W_FOUND)
message(STATUS "PThreads4W CONFIG not found, trying MODULE mode")
find_package(PThreads4W MODULE REQUIRED)
else()
message(STATUS "Found PThreads4W via CONFIG mode")
endif()
find_package(dlfcn-win32 CONFIG REQUIRED)
endif()
# Core dependencies
set(Boost_USE_MULTITHREADED FALSE)
find_package(
Boost
COMPONENTS filesystem
REQUIRED)
# Target
# ##############################################################################
# Compiler settings
include(ALSetCompilerFlags)
configure_file("include/al_defs.h.in" "include/al_defs.h" @ONLY)
set(PUBLIC_HEADER_FILES
include/access_layer_base_plugin.h
include/access_layer_plugin.h
include/access_layer_plugin_manager.h
include/extended_access_layer_plugin.h
include/al_backend.h
include/al_const.h
include/al_context.h
include/al_exception.h
include/al_lowlevel.h
include/provenance_plugin_feature.h
include/readback_plugin_feature.h
include/uri_parser.h
include/data_interpolation.h
include/fix_include_windows.h
# al_defs.h is generated in the binary folder with configure_file:
${CMAKE_CURRENT_BINARY_DIR}/include/al_defs.h)
# Define library target
add_library(al SHARED)
# Note: sources are added by the CMakeFiles in the src/ folder
target_link_libraries(al PRIVATE Boost::filesystem)
set_target_properties(al PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
# Enable ASCII backend
target_compile_definitions(al PRIVATE -DASCII)
if(NOT WIN32)
target_link_libraries(al PRIVATE dl)
else()
target_link_libraries(al PRIVATE dlfcn-win32::dl PThreads4W::PThreads4W ws2_32)
endif()
add_subdirectory(src)
# Dummy Executable
# ##############################################################################
set( EXE_FLAG )
set( EXE_EXT )
add_executable( imas_print_version ${EXE_FLAG} tests/imas_print_version.cpp )
target_link_libraries( imas_print_version PRIVATE al )
if(NOT WIN32 AND NOT APPLE)
# stdc++fs is only needed on Linux with older GCC
# On macOS, filesystem is part of libc++
# On Windows, filesystem is part of the standard library
target_link_libraries( imas_print_version PRIVATE stdc++fs )
endif()
add_dependencies( imas_print_version al )
# Install
# ##############################################################################
# Install al library
install(
TARGETS al
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT core
)
# TODO: put public heades in a separate directory?
install(
FILES ${PUBLIC_HEADER_FILES}
TYPE INCLUDE
)
target_include_directories(
al
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include> # <prefix>/include
)
# Generate and install .pc file
configure_file(pkgconfig/al-core.pc.in al-core.pc @ONLY)
include(GNUInstallDirs)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/al-core.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
# Install mdsplusIMASDB4to5
install(
PROGRAMS mdsplusIMASDB4to5
TYPE BIN
)
# Install common files
# Note: The environment variable $AL_COMMON_PATH must be set to this installation directory at runtime
install(DIRECTORY common TYPE DATA)
# Install Dummy
install(TARGETS imas_print_version DESTINATION bin)
# Scikit-build-core entry point for python bindings
# ##############################################################################
if(AL_PYTHON_BINDINGS)
include(skbuild.cmake)
endif()
# MDSplus models
# ##############################################################################
if(AL_BUILD_MDSPLUS_MODELS)
add_subdirectory(models/mdsplus)
endif()