-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
477 lines (442 loc) · 22.7 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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
cmake_minimum_required(VERSION 3.20)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
project(CASMcode_configuration VERSION 2.0.0 LANGUAGES CXX)
# set CMAKE_INSTALL_X variables
include(GNUInstallDirs)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# try to use ccache
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
##############################################
## Find dependencies
# Should find ZLIB::ZLIB
find_package(ZLIB)
# Find CASM
if(NOT DEFINED CASM_PREFIX)
message(STATUS "CASM_PREFIX not defined")
# try to find Python
find_package (Python COMPONENTS Interpreter Development)
if(DEFINED Python_EXECUTABLE)
# if Python found, obtain CASM_PREFIX from the libcasm.casmglobal
message(STATUS "found Python_EXECUTABLE: ${Python_EXECUTABLE}")
message(STATUS "checking for libcasm-global")
execute_process(
COMMAND pip show libcasm-global
RESULT_VARIABLE EXIT_CODE
OUTPUT_QUIET
)
if (${EXIT_CODE} EQUAL 0)
message(STATUS "found libcasm-global")
execute_process(COMMAND ${Python_EXECUTABLE} -m libcasm.casmglobal --prefix
OUTPUT_VARIABLE CASM_PREFIX_RAW)
string(STRIP ${CASM_PREFIX_RAW} CASM_PREFIX)
message(STATUS "CASM_PREFIX: ${CASM_PREFIX}")
else()
message(STATUS "did not find libcasm-global")
endif()
endif()
endif()
if(DEFINED CASM_PREFIX)
set(CASMcode_global_ROOT ${CASM_PREFIX}/share/CASMcode_global/cmake)
set(CASMcode_crystallography_ROOT ${CASM_PREFIX}/share/CASMcode_crystallography/cmake)
set(CASMcode_clexulator_ROOT ${CASM_PREFIX}/share/CASMcode_clexulator/cmake)
endif()
find_package(CASMcode_global)
if(NOT CASMcode_global_FOUND)
message(FATAL_ERROR "CMake failed to find CASMcode_global")
endif()
# if successful, we have CASM::casm_global
find_package(CASMcode_crystallography)
if(NOT CASMcode_crystallography_FOUND)
message(FATAL_ERROR "CMake failed to find CASMcode_crystallography")
endif()
# if successful, we have CASM::casm_crystallography
find_package(CASMcode_clexulator)
if(NOT CASMcode_clexulator_FOUND)
message(FATAL_ERROR "CMake failed to find CASMcode_clexulator")
endif()
# if successful, we have CASM::casm_clexulator
# if no user CMAKE_INSTALL_PREFIX, use CASM_PREFIX if it exists
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(DEFINED CASM_PREFIX)
message(STATUS "CMAKE_INSTALL_PREFIX initialized to default, so updating CMAKE_INSTALL_PREFIX to CASM_PREFIX")
set(CMAKE_INSTALL_PREFIX ${CASM_PREFIX} CACHE PATH "set CMAKE_INSTALL_PREFIX to CASM_PREFIX" FORCE)
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
endif()
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
##############################################
## Build libcasm_configuration
# create libcasm_configuration
set(
libcasm_configuration_HEADERS
${PROJECT_SOURCE_DIR}/include/casm/configuration/ConfigDoFIsEquivalent.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/ConfigCompare.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/SupercellSet.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/canonical_form.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/PrimMagspinInfo.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/ConfigIsEquivalent.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/SupercellSymOp.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/PrimSymInfo.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/make_simple_structure.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/version.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/definitions.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/misc.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/DoFSpace_functions.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/SupercellSymInfo.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/supercell_name.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/Configuration.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/config_space_analysis.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/Supercell.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/dof_space_analysis.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/copy_configuration.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/FromStructure.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/ConfigurationSet.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/Prim.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/sym_info/factor_group.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/sym_info/local_dof_sym_info.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/sym_info/unitcellcoord_sym_info.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/sym_info/occ_sym_info.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/sym_info/definitions.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/sym_info/global_dof_sym_info.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/sym_info/io/json/SymGroup_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/IrrepDecomposition.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/IrrepWedge.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/VectorSpaceSymReport.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/IrrepDecompositionImpl.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/Symmetrizer.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/SimpleOrbit_impl.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/definitions.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/misc.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/SimpleOrbit.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/VectorSymCompare_v2.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/to_real.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/io/json/IrrepWedge_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/io/json/IrrepDecomposition_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/irreps/io/json/VectorSpaceSymReport_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/OccEvent.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/OccTrajectory.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/OccEventCounter.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/OccSystem.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/definitions.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/orbits.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/OccEventInvariants.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/OccEventRep.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/OccPosition.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/misc/MultiStepMethod.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/misc/LexicographicalCompare.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/io/stream/OccEvent_stream_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/io/stream/OccEventCounter_stream_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/io/json/OccEvent_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/io/json/OccSystem_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/occ_events/io/json/OccEventCounter_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/group/Group.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/group/definitions.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/group/subgroups.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/group/orbits.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/enumeration/OccEventInfo.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/enumeration/background_configuration.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/enumeration/MakeOccEventStructures.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/enumeration/definitions.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/enumeration/perturbations.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/enumeration/ConfigEnumAllOccupations.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/enumeration/ConfigurationFilter.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/io/json/Supercell_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/io/json/analysis_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/io/json/Configuration_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/ClusterSpecs.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/ClusterInvariants.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/impact_neighborhood.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/definitions.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/occ_counter.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/IntegralCluster.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/SubClusterCounter.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/orbits.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/GenericCluster.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/IntegralClusterOrbitGenerator.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/io/json/ClusterSpecs_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/io/json/EquivalentsInfo_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/io/json/IntegralClusterOrbitGenerator_json_io.hh
${PROJECT_SOURCE_DIR}/include/casm/configuration/clusterography/io/json/IntegralCluster_json_io.hh
)
set(
libcasm_configuration_SOURCES
${PROJECT_SOURCE_DIR}/src/casm/configuration/canonical_form.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/SupercellSet.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/PrimMagspinInfo.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/FromStructure.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/copy_configuration.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/Prim.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/ConfigurationSet.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/Supercell.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/dof_space_analysis.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/misc.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/DoFSpace_functions.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/SupercellSymInfo.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/supercell_name.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/config_space_analysis.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/Configuration.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/SupercellSymOp.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/PrimSymInfo.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/make_simple_structure.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/version.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/sym_info/unitcellcoord_sym_info.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/sym_info/occ_sym_info.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/sym_info/local_dof_sym_info.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/sym_info/factor_group.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/sym_info/global_dof_sym_info.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/sym_info/io/json/SymGroup_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/VectorSpaceSymReport.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/IrrepWedge.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/IrrepDecomposition.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/VectorSymCompare_v2.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/Symmetrizer.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/IrrepDecompositionImpl.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/io/json/IrrepDecomposition_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/io/json/VectorSpaceSymReport_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/irreps/io/json/IrrepWedge_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/OccSystem.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/OccEventCounter.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/OccEvent.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/OccTrajectory.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/OccEventRep.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/OccPosition.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/OccEventInvariants.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/orbits.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/io/stream/OccEvent_stream_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/io/stream/OccEventCounter_stream_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/io/json/OccSystem_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/io/json/OccEvent_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/occ_events/io/json/OccEventCounter_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/enumeration/background_configuration.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/enumeration/OccEventInfo.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/enumeration/ConfigurationFilter.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/enumeration/perturbations.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/enumeration/ConfigEnumAllOccupations.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/enumeration/MakeOccEventStructures.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/io/json/analysis_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/io/json/Supercell_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/io/json/Configuration_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/impact_neighborhood.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/ClusterSpecs.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/ClusterInvariants.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/orbits.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/occ_counter.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/IntegralCluster.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/io/json/EquivalentsInfo_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/io/json/IntegralClusterOrbitGenerator_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/io/json/ClusterSpecs_json_io.cc
${PROJECT_SOURCE_DIR}/src/casm/configuration/clusterography/io/json/IntegralCluster_json_io.cc
)
add_library(casm_configuration SHARED ${libcasm_configuration_SOURCES})
target_include_directories(casm_configuration
PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/casm/external>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/casm/external/gzstream>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/casm/external>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/casm/external/gzstream>
)
target_compile_options(casm_configuration
PUBLIC
"-DCASM_CONFIGURATION_TXT_VERSION=\"${CMAKE_PROJECT_VERSION}\""
-DEIGEN_DEFAULT_DENSE_INDEX_TYPE=long
-DGZSTREAM_NAMESPACE=gz
)
target_link_libraries(casm_configuration
ZLIB::ZLIB
${CMAKE_DL_LIBS}
CASM::casm_global
CASM::casm_crystallography
CASM::casm_clexulator
)
if(APPLE)
set_target_properties(
casm_configuration PROPERTIES INSTALL_RPATH "@loader_path")
else()
set_target_properties(
casm_configuration PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
##############################################
## Install libcasm_configuration
# install header files in <prefix>/libcasm/include/,
# while preserving directory structure
foreach ( filevar ${libcasm_configuration_HEADERS} )
file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR}/include/ ${filevar})
get_filename_component( reldir ${relfile} DIRECTORY )
install( FILES ${filevar} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${reldir} )
endforeach()
# install libcasm_configuration in <prefix>/libcasm/lib/
install(
TARGETS casm_configuration
EXPORT CASMcode_configurationTargets
DESTINATION lib)
##############################################
## Python extensions
# The CMake package config and target files are installed under the Python
# package root. This is necessary to ensure that all the relative paths in the
# helloTargets.cmake resolve correctly. It also provides encapsulation.
#
# The actual path used must be selected so that consuming projects can locate it
# via `find_package`. To support finding CMake packages in the Python package
# prefix, using `find_package`s default search path of
# `<prefix>/<name>/share/<name>*/cmake/` is reasonable. Adding the Python
# package installation prefix to CMAKE_PREFIX_PATH in combination with this path
# will allow `find_package` to find this package and any other package installed
# via a Python package if the CMake and Python packages are named the same.
set(CASM_CMAKE_PACKAGE_INSTALL_SUBDIR "share/CASMcode_configuration/cmake")
install(
EXPORT CASMcode_configurationTargets
NAMESPACE CASM::
DESTINATION ${CASM_CMAKE_PACKAGE_INSTALL_SUBDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
CASMcode_configurationConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMinorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/CASMcode_configurationConfig.cmake.in" CASMcode_configurationConfig.cmake
INSTALL_DESTINATION ${CASM_CMAKE_PACKAGE_INSTALL_SUBDIR})
install(FILES "${PROJECT_BINARY_DIR}/CASMcode_configurationConfig.cmake"
"${PROJECT_BINARY_DIR}/CASMcode_configurationConfigVersion.cmake"
DESTINATION ${CASM_CMAKE_PACKAGE_INSTALL_SUBDIR})
# We are using the SKBUILD variable, which is defined when scikit-build is
# running the CMake build, to control building the Python wrapper. This allows
# the C++ project to be installed, standalone, when using the standard CMake
# build flow.
if(DEFINED SKBUILD)
# call pybind11-config to obtain the root of the cmake package
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pybind11 --cmakedir
OUTPUT_VARIABLE pybind11_ROOT_RAW)
string(STRIP ${pybind11_ROOT_RAW} pybind11_ROOT)
find_package(pybind11)
# The extension modules must load:
# - the casm_global library
# - the casm_crystallography library
# - the casm_clexulator library
# - the casm_configuration library
# They can be found by setting a relative rpath
### libcasm.clusterography._clusterography ###
pybind11_add_module(_clusterography MODULE
"${PROJECT_SOURCE_DIR}/python/src/clusterography.cpp")
target_link_libraries(_clusterography PRIVATE
CASM::casm_global
CASM::casm_crystallography
CASM::casm_clexulator
casm_configuration
)
install(TARGETS _clusterography DESTINATION clusterography)
if(APPLE)
set_target_properties(
_clusterography PROPERTIES INSTALL_RPATH "@loader_path/../lib")
else()
set_target_properties(
_clusterography PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
endif()
### libcasm.configuration._configuration ###
pybind11_add_module(_configuration MODULE
"${PROJECT_SOURCE_DIR}/python/src/configuration.cpp")
target_link_libraries(_configuration PRIVATE
CASM::casm_global
CASM::casm_crystallography
CASM::casm_clexulator
casm_configuration
)
install(TARGETS _configuration DESTINATION configuration)
if(APPLE)
set_target_properties(
_configuration PROPERTIES INSTALL_RPATH "@loader_path/../lib")
else()
set_target_properties(
_configuration PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
endif()
### libcasm.local_configuration._local_configuration ###
pybind11_add_module(_local_configuration MODULE
"${PROJECT_SOURCE_DIR}/python/src/local_configuration.cpp")
target_link_libraries(_local_configuration PRIVATE
CASM::casm_global
CASM::casm_crystallography
CASM::casm_clexulator
casm_configuration
)
install(TARGETS _local_configuration DESTINATION local_configuration)
if(APPLE)
set_target_properties(
_local_configuration PROPERTIES INSTALL_RPATH "@loader_path/../lib")
else()
set_target_properties(
_local_configuration PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
endif()
### libcasm.enumerate._enumerate ###
pybind11_add_module(_enumerate MODULE
"${PROJECT_SOURCE_DIR}/python/src/enumerate.cpp")
target_link_libraries(_enumerate PRIVATE
CASM::casm_global
CASM::casm_crystallography
CASM::casm_clexulator
casm_configuration
)
install(TARGETS _enumerate DESTINATION enumerate)
if(APPLE)
set_target_properties(
_enumerate PROPERTIES INSTALL_RPATH "@loader_path/../lib")
else()
set_target_properties(
_enumerate PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
endif()
### libcasm.irreps._irreps ###
pybind11_add_module(_irreps MODULE
"${PROJECT_SOURCE_DIR}/python/src/irreps.cpp")
target_link_libraries(_irreps PRIVATE
CASM::casm_global
CASM::casm_crystallography
CASM::casm_clexulator
casm_configuration
)
install(TARGETS _irreps DESTINATION irreps)
if(APPLE)
set_target_properties(
_irreps PROPERTIES INSTALL_RPATH "@loader_path/../lib")
else()
set_target_properties(
_irreps PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
endif()
### libcasm.occ_events._occ_events ###
pybind11_add_module(_occ_events MODULE
"${PROJECT_SOURCE_DIR}/python/src/occ_events.cpp")
target_link_libraries(_occ_events PRIVATE
CASM::casm_global
CASM::casm_crystallography
CASM::casm_clexulator
casm_configuration
)
install(TARGETS _occ_events DESTINATION occ_events)
if(APPLE)
set_target_properties(
_occ_events PROPERTIES INSTALL_RPATH "@loader_path/../lib")
else()
set_target_properties(
_occ_events PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
endif()
### libcasm.sym_info._sym_info ###
pybind11_add_module(_sym_info MODULE
"${PROJECT_SOURCE_DIR}/python/src/sym_info.cpp")
target_link_libraries(_sym_info PRIVATE
CASM::casm_global
CASM::casm_crystallography
CASM::casm_clexulator
casm_configuration
)
install(TARGETS _sym_info DESTINATION sym_info)
if(APPLE)
set_target_properties(
_sym_info PROPERTIES INSTALL_RPATH "@loader_path/../lib")
else()
set_target_properties(
_sym_info PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
endif()
endif()