libcasm-mapping 2.0a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. libcasm-mapping-2.0a1/CHANGELOG.md +34 -0
  2. libcasm-mapping-2.0a1/CMakeLists.txt +277 -0
  3. libcasm-mapping-2.0a1/CMakeLists.txt.in +239 -0
  4. libcasm-mapping-2.0a1/LICENSE +484 -0
  5. libcasm-mapping-2.0a1/MANIFEST.in +19 -0
  6. libcasm-mapping-2.0a1/PKG-INFO +56 -0
  7. libcasm-mapping-2.0a1/README.md +39 -0
  8. libcasm-mapping-2.0a1/build_requirements.txt +8 -0
  9. libcasm-mapping-2.0a1/cmake/CASMcode_mappingConfig.cmake.in +3 -0
  10. libcasm-mapping-2.0a1/dev_requirements.txt +4 -0
  11. libcasm-mapping-2.0a1/doc/customdoxygen.css +1441 -0
  12. libcasm-mapping-2.0a1/doc/doxygen_config +2306 -0
  13. libcasm-mapping-2.0a1/doc_requirements.txt +6 -0
  14. libcasm-mapping-2.0a1/include/casm/mapping/AtomMapping.hh +56 -0
  15. libcasm-mapping-2.0a1/include/casm/mapping/LatticeMapping.hh +80 -0
  16. libcasm-mapping-2.0a1/include/casm/mapping/MappingSearch.hh +280 -0
  17. libcasm-mapping-2.0a1/include/casm/mapping/SearchData.hh +259 -0
  18. libcasm-mapping-2.0a1/include/casm/mapping/StructureMapping.hh +118 -0
  19. libcasm-mapping-2.0a1/include/casm/mapping/atom_cost.hh +49 -0
  20. libcasm-mapping-2.0a1/include/casm/mapping/hungarian.hh +25 -0
  21. libcasm-mapping-2.0a1/include/casm/mapping/impl/LatticeMap.hh +212 -0
  22. libcasm-mapping-2.0a1/include/casm/mapping/impl/SimpleStrucMapCalculator.hh +116 -0
  23. libcasm-mapping-2.0a1/include/casm/mapping/impl/StrucMapCalculatorInterface.hh +260 -0
  24. libcasm-mapping-2.0a1/include/casm/mapping/impl/StrucMapping.hh +800 -0
  25. libcasm-mapping-2.0a1/include/casm/mapping/impl/io/json/StrucMapping_json_io.hh +17 -0
  26. libcasm-mapping-2.0a1/include/casm/mapping/io/json_io.hh +142 -0
  27. libcasm-mapping-2.0a1/include/casm/mapping/lattice_cost.hh +39 -0
  28. libcasm-mapping-2.0a1/include/casm/mapping/map_atoms.hh +52 -0
  29. libcasm-mapping-2.0a1/include/casm/mapping/map_lattices.hh +37 -0
  30. libcasm-mapping-2.0a1/include/casm/mapping/map_structures.hh +56 -0
  31. libcasm-mapping-2.0a1/include/casm/mapping/misc.hh +59 -0
  32. libcasm-mapping-2.0a1/include/casm/mapping/murty.hh +115 -0
  33. libcasm-mapping-2.0a1/include/casm/mapping/version.hh +24 -0
  34. libcasm-mapping-2.0a1/make_CMakeLists.py +174 -0
  35. libcasm-mapping-2.0a1/pre-commit +22 -0
  36. libcasm-mapping-2.0a1/pyproject.toml +75 -0
  37. libcasm-mapping-2.0a1/python/doc/.gitignore +2 -0
  38. libcasm-mapping-2.0a1/python/doc/_static/css/custom.css +79 -0
  39. libcasm-mapping-2.0a1/python/doc/_static/logo.pdf +1477 -4
  40. libcasm-mapping-2.0a1/python/doc/_static/logo.svg +1 -0
  41. libcasm-mapping-2.0a1/python/doc/_static/small_logo.pdf +1351 -4
  42. libcasm-mapping-2.0a1/python/doc/_static/small_logo.svg +1 -0
  43. libcasm-mapping-2.0a1/python/doc/_templates/base.rst +5 -0
  44. libcasm-mapping-2.0a1/python/doc/_templates/custom-attr-template.rst +5 -0
  45. libcasm-mapping-2.0a1/python/doc/_templates/custom-class-template.rst +36 -0
  46. libcasm-mapping-2.0a1/python/doc/_templates/custom-function-template.rst +5 -0
  47. libcasm-mapping-2.0a1/python/doc/_templates/custom-module-template.rst +71 -0
  48. libcasm-mapping-2.0a1/python/doc/bibliography.rst +4 -0
  49. libcasm-mapping-2.0a1/python/doc/conf.py +223 -0
  50. libcasm-mapping-2.0a1/python/doc/index.rst +46 -0
  51. libcasm-mapping-2.0a1/python/doc/installation.rst +31 -0
  52. libcasm-mapping-2.0a1/python/doc/reference/libcasm/index.rst +12 -0
  53. libcasm-mapping-2.0a1/python/doc/refs.bib +34 -0
  54. libcasm-mapping-2.0a1/python/doc/usage.rst +292 -0
  55. libcasm-mapping-2.0a1/python/examples/example_1.py +25 -0
  56. libcasm-mapping-2.0a1/python/examples/example_2.py +31 -0
  57. libcasm-mapping-2.0a1/python/examples/example_3.py +25 -0
  58. libcasm-mapping-2.0a1/python/examples/example_4.py +34 -0
  59. libcasm-mapping-2.0a1/python/libcasm/mapping/__init__.py +1 -0
  60. libcasm-mapping-2.0a1/python/libcasm/mapping/info/__init__.py +15 -0
  61. libcasm-mapping-2.0a1/python/libcasm/mapping/mapsearch/__init__.py +16 -0
  62. libcasm-mapping-2.0a1/python/libcasm/mapping/methods/__init__.py +8 -0
  63. libcasm-mapping-2.0a1/python/libcasm_mapping.egg-info/PKG-INFO +56 -0
  64. libcasm-mapping-2.0a1/python/libcasm_mapping.egg-info/SOURCES.txt +119 -0
  65. libcasm-mapping-2.0a1/python/libcasm_mapping.egg-info/dependency_links.txt +1 -0
  66. libcasm-mapping-2.0a1/python/libcasm_mapping.egg-info/requires.txt +3 -0
  67. libcasm-mapping-2.0a1/python/libcasm_mapping.egg-info/top_level.txt +1 -0
  68. libcasm-mapping-2.0a1/python/pyproject.toml +10 -0
  69. libcasm-mapping-2.0a1/python/setup.py +99 -0
  70. libcasm-mapping-2.0a1/python/src/mapping_info.cpp +778 -0
  71. libcasm-mapping-2.0a1/python/src/mapping_mapsearch.cpp +847 -0
  72. libcasm-mapping-2.0a1/python/src/mapping_methods.cpp +437 -0
  73. libcasm-mapping-2.0a1/python/tests/conftest.py +0 -0
  74. libcasm-mapping-2.0a1/python/tests/test_info_io.py +145 -0
  75. libcasm-mapping-2.0a1/python/tests/test_interpolate_lattices.py +139 -0
  76. libcasm-mapping-2.0a1/python/tests/test_interpolate_structures.py +216 -0
  77. libcasm-mapping-2.0a1/python/tests/test_map_lattices.py +94 -0
  78. libcasm-mapping-2.0a1/python/tests/test_map_structures.py +392 -0
  79. libcasm-mapping-2.0a1/setup.cfg +4 -0
  80. libcasm-mapping-2.0a1/setup.py +16 -0
  81. libcasm-mapping-2.0a1/src/casm/mapping/AtomMapping.cc +92 -0
  82. libcasm-mapping-2.0a1/src/casm/mapping/LatticeMapping.cc +128 -0
  83. libcasm-mapping-2.0a1/src/casm/mapping/MappingSearch.cc +513 -0
  84. libcasm-mapping-2.0a1/src/casm/mapping/SearchData.cc +713 -0
  85. libcasm-mapping-2.0a1/src/casm/mapping/StructureMapping.cc +381 -0
  86. libcasm-mapping-2.0a1/src/casm/mapping/atom_cost.cc +198 -0
  87. libcasm-mapping-2.0a1/src/casm/mapping/hungarian.cc +475 -0
  88. libcasm-mapping-2.0a1/src/casm/mapping/impl/LatticeMap.cc +805 -0
  89. libcasm-mapping-2.0a1/src/casm/mapping/impl/SimpleStrucMapCalculator.cc +607 -0
  90. libcasm-mapping-2.0a1/src/casm/mapping/impl/StrucMapping.cc +1989 -0
  91. libcasm-mapping-2.0a1/src/casm/mapping/impl/io/json/StrucMapping_json_io.cc +88 -0
  92. libcasm-mapping-2.0a1/src/casm/mapping/io/json_io.cc +221 -0
  93. libcasm-mapping-2.0a1/src/casm/mapping/lattice_cost.cc +167 -0
  94. libcasm-mapping-2.0a1/src/casm/mapping/map_atoms.cc +182 -0
  95. libcasm-mapping-2.0a1/src/casm/mapping/map_lattices.cc +156 -0
  96. libcasm-mapping-2.0a1/src/casm/mapping/map_structures.cc +187 -0
  97. libcasm-mapping-2.0a1/src/casm/mapping/murty.cc +339 -0
  98. libcasm-mapping-2.0a1/src/casm/mapping/version.cc +13 -0
  99. libcasm-mapping-2.0a1/stylize.sh +18 -0
  100. libcasm-mapping-2.0a1/test_requirements.txt +4 -0
  101. libcasm-mapping-2.0a1/tests/CMakeLists.txt +156 -0
  102. libcasm-mapping-2.0a1/tests/CMakeLists.txt.in +141 -0
  103. libcasm-mapping-2.0a1/tests/unit/SearchTestData.hh +227 -0
  104. libcasm-mapping-2.0a1/tests/unit/autotools.cc +28 -0
  105. libcasm-mapping-2.0a1/tests/unit/autotools.hh +25 -0
  106. libcasm-mapping-2.0a1/tests/unit/gtest_main_run_all.cpp +6 -0
  107. libcasm-mapping-2.0a1/tests/unit/mapping/AtomMappingSearchData_test.cpp +113 -0
  108. libcasm-mapping-2.0a1/tests/unit/mapping/LatticeMap_test.cpp +364 -0
  109. libcasm-mapping-2.0a1/tests/unit/mapping/LatticeMappingSearchData_test.cpp +114 -0
  110. libcasm-mapping-2.0a1/tests/unit/mapping/MappingSearch_test.cpp +434 -0
  111. libcasm-mapping-2.0a1/tests/unit/mapping/PrimSearchData_test.cpp +130 -0
  112. libcasm-mapping-2.0a1/tests/unit/mapping/StrucMapper_test.cpp +481 -0
  113. libcasm-mapping-2.0a1/tests/unit/mapping/StrucMapping_test.cpp +510 -0
  114. libcasm-mapping-2.0a1/tests/unit/mapping/StructureSearchData_test.cpp +41 -0
  115. libcasm-mapping-2.0a1/tests/unit/mapping/hungarian_test.cpp +35 -0
  116. libcasm-mapping-2.0a1/tests/unit/mapping/make_trial_translations_test.cpp +89 -0
  117. libcasm-mapping-2.0a1/tests/unit/mapping/murty_test.cpp +123 -0
  118. libcasm-mapping-2.0a1/tests/unit/mapping/version_test.cpp +62 -0
  119. libcasm-mapping-2.0a1/tests/unit/testdir.cc +49 -0
  120. libcasm-mapping-2.0a1/tests/unit/testdir.hh +46 -0
  121. libcasm-mapping-2.0a1/tests/unit/teststructures.hh +192 -0
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ All notable changes to `libcasm-mapping` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [v2.0a1] - 2023-08-17
9
+
10
+ This release separates out mapping methods from CASM crystallography v1, adds data structures for holding results, adds additional methods for working with mapping results, and provides an alternative mapping search implementation that can be used to construct custom searches. It creates a Python package, libcasm.mapping, that enables using the mapping methods and may be installed via pip install, using scikit-build, CMake, and pybind11. This release also includes usage examples and API documentation for using libcasm.mapping, built using Sphinx.
11
+
12
+ ### Added
13
+
14
+ - Added the casm/mapping C++ module with new data structures and methods in namespace CASM::mapping, and with CASM v1 mapping code under namespace CASM::mapping::impl
15
+ - Added mapping::LatticeMapping, mapping::AtomMapping, and mapping::StructureMapping data structures for holding individual mapping results
16
+ - Added mapping::ScoredLatticeMapping, mapping::ScoredAtomMapping, and mapping::ScoredStructureMapping data structures for holding mapping results along with mapping costs
17
+ - Added mapping::LatticeMappingResults, mapping::AtomMappingResults, and mapping::StructureMappingResults data structures for holding multiple mapping results along with mapping costs
18
+ - Added mapping::interpolated_mapping for constructing structures that are interpolated between two structures along a particular mapping path
19
+ - Added mapping::make_mapping_to_equivalent_structure to generate symmetrically equivalent mappings
20
+ - Added mapping::make_mapping_to_equivalent_superlattice to generate mappings to a different, but symmetrically equivalent superlattice of the prim
21
+ - Added mapping::make_mapped_structure for applying a mapping::StructureMapping result to an unmapped structure to construct the mapped structure aligned to the parent crystal structure, with implied vacancies, strain, and atomic displacement; This can be used be copied to configuration degree of freedom (DoF) values and calculated properties.
22
+ - Added mapping::MappingSearch class and related data structures and methods to perform the mapping search method
23
+ - Added Python package libcasm.mapping.info for mapping data structures
24
+ - Added Python package libcasm.mapping.methods for the existing lattice, atom, and structure mapping methods
25
+ - Added Python package libcasm.mapping.mapsearch for the customizeable mapping search data structures and methods
26
+ - Added GitHub Actions for unit testing
27
+ - Added GitHub Action build_wheels.yml for Python wheel building using cibuildwheel
28
+ - Added Python documentation
29
+
30
+
31
+ ### Removed
32
+
33
+ - Removed autotools build process
34
+ - Removed boost dependencies
@@ -0,0 +1,277 @@
1
+ cmake_minimum_required(VERSION 3.20)
2
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
3
+
4
+ project(CASMcode_mapping VERSION 2.0.0 LANGUAGES CXX)
5
+
6
+ # set CMAKE_INSTALL_X variables
7
+ include(GNUInstallDirs)
8
+
9
+ # specify the C++ standard
10
+ set(CMAKE_CXX_STANDARD 17)
11
+ set(CMAKE_CXX_STANDARD_REQUIRED True)
12
+
13
+ # try to use ccache
14
+ find_program(CCACHE_PROGRAM ccache)
15
+ if(CCACHE_PROGRAM)
16
+ set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
17
+ endif()
18
+
19
+ ##############################################
20
+ ## Find dependencies
21
+
22
+ # Should find ZLIB::ZLIB
23
+ find_package(ZLIB)
24
+
25
+ # Find CASM
26
+ if(NOT DEFINED CASM_PREFIX)
27
+ message(STATUS "CASM_PREFIX not defined")
28
+ # try to find Python
29
+ find_package (Python COMPONENTS Interpreter Development)
30
+ if(DEFINED Python_EXECUTABLE)
31
+ # if Python found, obtain CASM_PREFIX from the libcasm.casmglobal
32
+ message(STATUS "found Python_EXECUTABLE: ${Python_EXECUTABLE}")
33
+ message(STATUS "checking for libcasm-global")
34
+ execute_process(
35
+ COMMAND pip show libcasm-global
36
+ RESULT_VARIABLE EXIT_CODE
37
+ OUTPUT_QUIET
38
+ )
39
+ if (${EXIT_CODE} EQUAL 0)
40
+ message(STATUS "found libcasm-global")
41
+ execute_process(COMMAND ${Python_EXECUTABLE} -m libcasm.casmglobal --prefix
42
+ OUTPUT_VARIABLE CASM_PREFIX_RAW)
43
+ string(STRIP ${CASM_PREFIX_RAW} CASM_PREFIX)
44
+ message(STATUS "CASM_PREFIX: ${CASM_PREFIX}")
45
+ else()
46
+ message(STATUS "did not find libcasm-global")
47
+ endif()
48
+ endif()
49
+ endif()
50
+ if(DEFINED CASM_PREFIX)
51
+ set(CASMcode_global_ROOT ${CASM_PREFIX}/share/CASMcode_global/cmake)
52
+ set(CASMcode_crystallography_ROOT ${CASM_PREFIX}/share/CASMcode_crystallography/cmake)
53
+ endif()
54
+
55
+ find_package(CASMcode_global)
56
+ if(NOT CASMcode_global_FOUND)
57
+ message(FATAL_ERROR "CMake failed to find CASMcode_global")
58
+ endif()
59
+ # if successful, we have CASM::casm_global
60
+
61
+ find_package(CASMcode_crystallography)
62
+ if(NOT CASMcode_crystallography_FOUND)
63
+ message(FATAL_ERROR "CMake failed to find CASMcode_crystallography")
64
+ endif()
65
+ # if successful, we have CASM::casm_crystallography
66
+
67
+ # if no user CMAKE_INSTALL_PREFIX, use CASM_PREFIX if it exists
68
+ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
69
+ if(DEFINED CASM_PREFIX)
70
+ message(STATUS "CMAKE_INSTALL_PREFIX initialized to default, so updating CMAKE_INSTALL_PREFIX to CASM_PREFIX")
71
+ set(CMAKE_INSTALL_PREFIX ${CASM_PREFIX} CACHE PATH "set CMAKE_INSTALL_PREFIX to CASM_PREFIX" FORCE)
72
+ message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
73
+ endif()
74
+ ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
75
+
76
+ ##############################################
77
+ ## Build libcasm_mapping
78
+
79
+ # create libcasm_mapping
80
+ set(
81
+ libcasm_mapping_HEADERS
82
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/murty.hh
83
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/map_lattices.hh
84
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/map_atoms.hh
85
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/atom_cost.hh
86
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/MappingSearch.hh
87
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/hungarian.hh
88
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/AtomMapping.hh
89
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/version.hh
90
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/misc.hh
91
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/LatticeMapping.hh
92
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/map_structures.hh
93
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/lattice_cost.hh
94
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/StructureMapping.hh
95
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/SearchData.hh
96
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/impl/StrucMapCalculatorInterface.hh
97
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/impl/SimpleStrucMapCalculator.hh
98
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/impl/LatticeMap.hh
99
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/impl/StrucMapping.hh
100
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/impl/io/json/StrucMapping_json_io.hh
101
+ ${PROJECT_SOURCE_DIR}/include/casm/mapping/io/json_io.hh
102
+ )
103
+ set(
104
+ libcasm_mapping_SOURCES
105
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/MappingSearch.cc
106
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/atom_cost.cc
107
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/map_atoms.cc
108
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/map_lattices.cc
109
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/murty.cc
110
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/SearchData.cc
111
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/lattice_cost.cc
112
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/StructureMapping.cc
113
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/LatticeMapping.cc
114
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/map_structures.cc
115
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/AtomMapping.cc
116
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/hungarian.cc
117
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/version.cc
118
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/impl/LatticeMap.cc
119
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/impl/SimpleStrucMapCalculator.cc
120
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/impl/StrucMapping.cc
121
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/impl/io/json/StrucMapping_json_io.cc
122
+ ${PROJECT_SOURCE_DIR}/src/casm/mapping/io/json_io.cc
123
+ )
124
+ add_library(casm_mapping SHARED ${libcasm_mapping_SOURCES})
125
+ target_include_directories(casm_mapping
126
+ PUBLIC
127
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
128
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/casm/external>
129
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/casm/external/gzstream>
130
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
131
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/casm/external>
132
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/casm/external/gzstream>
133
+ )
134
+ target_compile_options(casm_mapping
135
+ PUBLIC
136
+ "-DCASM_MAPPING_TXT_VERSION=\"${CMAKE_PROJECT_VERSION}\""
137
+ -DEIGEN_DEFAULT_DENSE_INDEX_TYPE=long
138
+ -DGZSTREAM_NAMESPACE=gz
139
+ )
140
+ target_link_libraries(casm_mapping
141
+ ZLIB::ZLIB
142
+ ${CMAKE_DL_LIBS}
143
+ CASM::casm_global
144
+ CASM::casm_crystallography
145
+ )
146
+ if(APPLE)
147
+ set_target_properties(
148
+ casm_mapping PROPERTIES INSTALL_RPATH "@loader_path")
149
+ else()
150
+ set_target_properties(
151
+ casm_mapping PROPERTIES INSTALL_RPATH "$ORIGIN")
152
+ endif()
153
+
154
+
155
+ ##############################################
156
+ ## Install libcasm_mapping
157
+
158
+ # install header files in <prefix>/libcasm/include/,
159
+ # while preserving directory structure
160
+ foreach ( filevar ${libcasm_mapping_HEADERS} )
161
+ file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR}/include/ ${filevar})
162
+ get_filename_component( reldir ${relfile} DIRECTORY )
163
+ install( FILES ${filevar} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${reldir} )
164
+ endforeach()
165
+
166
+ # install libcasm_mapping in <prefix>/libcasm/lib/
167
+ install(
168
+ TARGETS casm_mapping
169
+ EXPORT CASMcode_mappingTargets
170
+ DESTINATION lib)
171
+
172
+ ##############################################
173
+ ## Python extensions
174
+
175
+ # The CMake package config and target files are installed under the Python
176
+ # package root. This is necessary to ensure that all the relative paths in the
177
+ # helloTargets.cmake resolve correctly. It also provides encapsulation.
178
+ #
179
+ # The actual path used must be selected so that consuming projects can locate it
180
+ # via `find_package`. To support finding CMake packages in the Python package
181
+ # prefix, using `find_package`s default search path of
182
+ # `<prefix>/<name>/share/<name>*/cmake/` is reasonable. Adding the Python
183
+ # package installation prefix to CMAKE_PREFIX_PATH in combination with this path
184
+ # will allow `find_package` to find this package and any other package installed
185
+ # via a Python package if the CMake and Python packages are named the same.
186
+ set(CASM_CRYSTALLOGRAPHY_CMAKE_PACKAGE_INSTALL_SUBDIR "share/CASMcode_mapping/cmake")
187
+
188
+ install(
189
+ EXPORT CASMcode_mappingTargets
190
+ NAMESPACE CASM::
191
+ DESTINATION ${CASM_CRYSTALLOGRAPHY_CMAKE_PACKAGE_INSTALL_SUBDIR})
192
+
193
+ include(CMakePackageConfigHelpers)
194
+
195
+ write_basic_package_version_file(
196
+ CASMcode_mappingConfigVersion.cmake
197
+ VERSION ${PROJECT_VERSION}
198
+ COMPATIBILITY SameMinorVersion)
199
+
200
+ configure_package_config_file(
201
+ "${PROJECT_SOURCE_DIR}/cmake/CASMcode_mappingConfig.cmake.in" CASMcode_mappingConfig.cmake
202
+ INSTALL_DESTINATION ${CASM_CRYSTALLOGRAPHY_CMAKE_PACKAGE_INSTALL_SUBDIR})
203
+
204
+ install(FILES "${PROJECT_BINARY_DIR}/CASMcode_mappingConfig.cmake"
205
+ "${PROJECT_BINARY_DIR}/CASMcode_mappingConfigVersion.cmake"
206
+ DESTINATION ${CASM_CRYSTALLOGRAPHY_CMAKE_PACKAGE_INSTALL_SUBDIR})
207
+
208
+ # We are using the SKBUILD variable, which is defined when scikit-build is
209
+ # running the CMake build, to control building the Python wrapper. This allows
210
+ # the C++ project to be installed, standalone, when using the standard CMake
211
+ # build flow.
212
+ if(DEFINED SKBUILD)
213
+
214
+ # call pybind11-config to obtain the root of the cmake package
215
+ execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pybind11 --cmakedir
216
+ OUTPUT_VARIABLE pybind11_ROOT_RAW)
217
+ string(STRIP ${pybind11_ROOT_RAW} pybind11_ROOT)
218
+ find_package(pybind11)
219
+
220
+ # The extension modules must load:
221
+ # - the casm_global library
222
+ # - the casm_crystallography library
223
+ # - the casm_mapping library
224
+ # They can be found by setting a relative rpath
225
+
226
+ ### libcasm.mapping.info._mapping_info ###
227
+ pybind11_add_module(_mapping_info MODULE
228
+ "${PROJECT_SOURCE_DIR}/python/src/mapping_info.cpp")
229
+ target_link_libraries(_mapping_info PRIVATE
230
+ CASM::casm_global
231
+ CASM::casm_crystallography
232
+ casm_mapping
233
+ )
234
+ install(TARGETS _mapping_info DESTINATION mapping/info)
235
+ if(APPLE)
236
+ set_target_properties(
237
+ _mapping_info PROPERTIES INSTALL_RPATH "@loader_path/../../lib")
238
+ else()
239
+ set_target_properties(
240
+ _mapping_info PROPERTIES INSTALL_RPATH "$ORIGIN/../../lib")
241
+ endif()
242
+
243
+ ### libcasm.mapping.mapsearch._mapping_mapsearch ###
244
+ pybind11_add_module(_mapping_mapsearch MODULE
245
+ "${PROJECT_SOURCE_DIR}/python/src/mapping_mapsearch.cpp")
246
+ target_link_libraries(_mapping_mapsearch PRIVATE
247
+ CASM::casm_global
248
+ CASM::casm_crystallography
249
+ casm_mapping
250
+ )
251
+ install(TARGETS _mapping_mapsearch DESTINATION mapping/mapsearch)
252
+ if(APPLE)
253
+ set_target_properties(
254
+ _mapping_mapsearch PROPERTIES INSTALL_RPATH "@loader_path/../../lib")
255
+ else()
256
+ set_target_properties(
257
+ _mapping_mapsearch PROPERTIES INSTALL_RPATH "$ORIGIN/../../lib")
258
+ endif()
259
+
260
+ ### libcasm.mapping.methods._mapping_methods ###
261
+ pybind11_add_module(_mapping_methods MODULE
262
+ "${PROJECT_SOURCE_DIR}/python/src/mapping_methods.cpp")
263
+ target_link_libraries(_mapping_methods PRIVATE
264
+ CASM::casm_global
265
+ CASM::casm_crystallography
266
+ casm_mapping
267
+ )
268
+ install(TARGETS _mapping_methods DESTINATION mapping/methods)
269
+ if(APPLE)
270
+ set_target_properties(
271
+ _mapping_methods PROPERTIES INSTALL_RPATH "@loader_path/../../lib")
272
+ else()
273
+ set_target_properties(
274
+ _mapping_methods PROPERTIES INSTALL_RPATH "$ORIGIN/../../lib")
275
+ endif()
276
+
277
+ endif()
@@ -0,0 +1,239 @@
1
+ cmake_minimum_required(VERSION 3.20)
2
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
3
+
4
+ project(CASMcode_mapping VERSION 2.0.0 LANGUAGES CXX)
5
+
6
+ # set CMAKE_INSTALL_X variables
7
+ include(GNUInstallDirs)
8
+
9
+ # specify the C++ standard
10
+ set(CMAKE_CXX_STANDARD 17)
11
+ set(CMAKE_CXX_STANDARD_REQUIRED True)
12
+
13
+ # try to use ccache
14
+ find_program(CCACHE_PROGRAM ccache)
15
+ if(CCACHE_PROGRAM)
16
+ set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
17
+ endif()
18
+
19
+ ##############################################
20
+ ## Find dependencies
21
+
22
+ # Should find ZLIB::ZLIB
23
+ find_package(ZLIB)
24
+
25
+ # Find CASM
26
+ if(NOT DEFINED CASM_PREFIX)
27
+ message(STATUS "CASM_PREFIX not defined")
28
+ # try to find Python
29
+ find_package (Python COMPONENTS Interpreter Development)
30
+ if(DEFINED Python_EXECUTABLE)
31
+ # if Python found, obtain CASM_PREFIX from the libcasm.casmglobal
32
+ message(STATUS "found Python_EXECUTABLE: ${Python_EXECUTABLE}")
33
+ message(STATUS "checking for libcasm-global")
34
+ execute_process(
35
+ COMMAND pip show libcasm-global
36
+ RESULT_VARIABLE EXIT_CODE
37
+ OUTPUT_QUIET
38
+ )
39
+ if (${EXIT_CODE} EQUAL 0)
40
+ message(STATUS "found libcasm-global")
41
+ execute_process(COMMAND ${Python_EXECUTABLE} -m libcasm.casmglobal --prefix
42
+ OUTPUT_VARIABLE CASM_PREFIX_RAW)
43
+ string(STRIP ${CASM_PREFIX_RAW} CASM_PREFIX)
44
+ message(STATUS "CASM_PREFIX: ${CASM_PREFIX}")
45
+ else()
46
+ message(STATUS "did not find libcasm-global")
47
+ endif()
48
+ endif()
49
+ endif()
50
+ if(DEFINED CASM_PREFIX)
51
+ set(CASMcode_global_ROOT ${CASM_PREFIX}/share/CASMcode_global/cmake)
52
+ set(CASMcode_crystallography_ROOT ${CASM_PREFIX}/share/CASMcode_crystallography/cmake)
53
+ endif()
54
+
55
+ find_package(CASMcode_global)
56
+ if(NOT CASMcode_global_FOUND)
57
+ message(FATAL_ERROR "CMake failed to find CASMcode_global")
58
+ endif()
59
+ # if successful, we have CASM::casm_global
60
+
61
+ find_package(CASMcode_crystallography)
62
+ if(NOT CASMcode_crystallography_FOUND)
63
+ message(FATAL_ERROR "CMake failed to find CASMcode_crystallography")
64
+ endif()
65
+ # if successful, we have CASM::casm_crystallography
66
+
67
+ # if no user CMAKE_INSTALL_PREFIX, use CASM_PREFIX if it exists
68
+ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
69
+ if(DEFINED CASM_PREFIX)
70
+ message(STATUS "CMAKE_INSTALL_PREFIX initialized to default, so updating CMAKE_INSTALL_PREFIX to CASM_PREFIX")
71
+ set(CMAKE_INSTALL_PREFIX ${CASM_PREFIX} CACHE PATH "set CMAKE_INSTALL_PREFIX to CASM_PREFIX" FORCE)
72
+ message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
73
+ endif()
74
+ ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
75
+
76
+ ##############################################
77
+ ## Build libcasm_mapping
78
+
79
+ # create libcasm_mapping
80
+ set(
81
+ libcasm_mapping_HEADERS
82
+ @header_files@)
83
+ set(
84
+ libcasm_mapping_SOURCES
85
+ @source_files@)
86
+ add_library(casm_mapping SHARED ${libcasm_mapping_SOURCES})
87
+ target_include_directories(casm_mapping
88
+ PUBLIC
89
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
90
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/casm/external>
91
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/casm/external/gzstream>
92
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
93
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/casm/external>
94
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/casm/external/gzstream>
95
+ )
96
+ target_compile_options(casm_mapping
97
+ PUBLIC
98
+ "-DCASM_MAPPING_TXT_VERSION=\"${CMAKE_PROJECT_VERSION}\""
99
+ -DEIGEN_DEFAULT_DENSE_INDEX_TYPE=long
100
+ -DGZSTREAM_NAMESPACE=gz
101
+ )
102
+ target_link_libraries(casm_mapping
103
+ ZLIB::ZLIB
104
+ ${CMAKE_DL_LIBS}
105
+ CASM::casm_global
106
+ CASM::casm_crystallography
107
+ )
108
+ if(APPLE)
109
+ set_target_properties(
110
+ casm_mapping PROPERTIES INSTALL_RPATH "@loader_path")
111
+ else()
112
+ set_target_properties(
113
+ casm_mapping PROPERTIES INSTALL_RPATH "$ORIGIN")
114
+ endif()
115
+
116
+
117
+ ##############################################
118
+ ## Install libcasm_mapping
119
+
120
+ # install header files in <prefix>/libcasm/include/,
121
+ # while preserving directory structure
122
+ foreach ( filevar ${libcasm_mapping_HEADERS} )
123
+ file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR}/include/ ${filevar})
124
+ get_filename_component( reldir ${relfile} DIRECTORY )
125
+ install( FILES ${filevar} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${reldir} )
126
+ endforeach()
127
+
128
+ # install libcasm_mapping in <prefix>/libcasm/lib/
129
+ install(
130
+ TARGETS casm_mapping
131
+ EXPORT CASMcode_mappingTargets
132
+ DESTINATION lib)
133
+
134
+ ##############################################
135
+ ## Python extensions
136
+
137
+ # The CMake package config and target files are installed under the Python
138
+ # package root. This is necessary to ensure that all the relative paths in the
139
+ # helloTargets.cmake resolve correctly. It also provides encapsulation.
140
+ #
141
+ # The actual path used must be selected so that consuming projects can locate it
142
+ # via `find_package`. To support finding CMake packages in the Python package
143
+ # prefix, using `find_package`s default search path of
144
+ # `<prefix>/<name>/share/<name>*/cmake/` is reasonable. Adding the Python
145
+ # package installation prefix to CMAKE_PREFIX_PATH in combination with this path
146
+ # will allow `find_package` to find this package and any other package installed
147
+ # via a Python package if the CMake and Python packages are named the same.
148
+ set(CASM_CRYSTALLOGRAPHY_CMAKE_PACKAGE_INSTALL_SUBDIR "share/CASMcode_mapping/cmake")
149
+
150
+ install(
151
+ EXPORT CASMcode_mappingTargets
152
+ NAMESPACE CASM::
153
+ DESTINATION ${CASM_CRYSTALLOGRAPHY_CMAKE_PACKAGE_INSTALL_SUBDIR})
154
+
155
+ include(CMakePackageConfigHelpers)
156
+
157
+ write_basic_package_version_file(
158
+ CASMcode_mappingConfigVersion.cmake
159
+ VERSION ${PROJECT_VERSION}
160
+ COMPATIBILITY SameMinorVersion)
161
+
162
+ configure_package_config_file(
163
+ "${PROJECT_SOURCE_DIR}/cmake/CASMcode_mappingConfig.cmake.in" CASMcode_mappingConfig.cmake
164
+ INSTALL_DESTINATION ${CASM_CRYSTALLOGRAPHY_CMAKE_PACKAGE_INSTALL_SUBDIR})
165
+
166
+ install(FILES "${PROJECT_BINARY_DIR}/CASMcode_mappingConfig.cmake"
167
+ "${PROJECT_BINARY_DIR}/CASMcode_mappingConfigVersion.cmake"
168
+ DESTINATION ${CASM_CRYSTALLOGRAPHY_CMAKE_PACKAGE_INSTALL_SUBDIR})
169
+
170
+ # We are using the SKBUILD variable, which is defined when scikit-build is
171
+ # running the CMake build, to control building the Python wrapper. This allows
172
+ # the C++ project to be installed, standalone, when using the standard CMake
173
+ # build flow.
174
+ if(DEFINED SKBUILD)
175
+
176
+ # call pybind11-config to obtain the root of the cmake package
177
+ execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pybind11 --cmakedir
178
+ OUTPUT_VARIABLE pybind11_ROOT_RAW)
179
+ string(STRIP ${pybind11_ROOT_RAW} pybind11_ROOT)
180
+ find_package(pybind11)
181
+
182
+ # The extension modules must load:
183
+ # - the casm_global library
184
+ # - the casm_crystallography library
185
+ # - the casm_mapping library
186
+ # They can be found by setting a relative rpath
187
+
188
+ ### libcasm.mapping.info._mapping_info ###
189
+ pybind11_add_module(_mapping_info MODULE
190
+ "${PROJECT_SOURCE_DIR}/python/src/mapping_info.cpp")
191
+ target_link_libraries(_mapping_info PRIVATE
192
+ CASM::casm_global
193
+ CASM::casm_crystallography
194
+ casm_mapping
195
+ )
196
+ install(TARGETS _mapping_info DESTINATION mapping/info)
197
+ if(APPLE)
198
+ set_target_properties(
199
+ _mapping_info PROPERTIES INSTALL_RPATH "@loader_path/../../lib")
200
+ else()
201
+ set_target_properties(
202
+ _mapping_info PROPERTIES INSTALL_RPATH "$ORIGIN/../../lib")
203
+ endif()
204
+
205
+ ### libcasm.mapping.mapsearch._mapping_mapsearch ###
206
+ pybind11_add_module(_mapping_mapsearch MODULE
207
+ "${PROJECT_SOURCE_DIR}/python/src/mapping_mapsearch.cpp")
208
+ target_link_libraries(_mapping_mapsearch PRIVATE
209
+ CASM::casm_global
210
+ CASM::casm_crystallography
211
+ casm_mapping
212
+ )
213
+ install(TARGETS _mapping_mapsearch DESTINATION mapping/mapsearch)
214
+ if(APPLE)
215
+ set_target_properties(
216
+ _mapping_mapsearch PROPERTIES INSTALL_RPATH "@loader_path/../../lib")
217
+ else()
218
+ set_target_properties(
219
+ _mapping_mapsearch PROPERTIES INSTALL_RPATH "$ORIGIN/../../lib")
220
+ endif()
221
+
222
+ ### libcasm.mapping.methods._mapping_methods ###
223
+ pybind11_add_module(_mapping_methods MODULE
224
+ "${PROJECT_SOURCE_DIR}/python/src/mapping_methods.cpp")
225
+ target_link_libraries(_mapping_methods PRIVATE
226
+ CASM::casm_global
227
+ CASM::casm_crystallography
228
+ casm_mapping
229
+ )
230
+ install(TARGETS _mapping_methods DESTINATION mapping/methods)
231
+ if(APPLE)
232
+ set_target_properties(
233
+ _mapping_methods PROPERTIES INSTALL_RPATH "@loader_path/../../lib")
234
+ else()
235
+ set_target_properties(
236
+ _mapping_methods PROPERTIES INSTALL_RPATH "$ORIGIN/../../lib")
237
+ endif()
238
+
239
+ endif()