-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
206 lines (178 loc) · 6.87 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
# Defines the CMake commands/policies
cmake_minimum_required(VERSION 3.0.0)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
cmake_policy(SET CMP0074 NEW)
endif()
# Make the scripts available in the 'cmake' directory available for the
# 'include()' command, 'find_package()' command.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Setup the project
project(pyne)
# check for and enable c++11 support
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
IF(COMPILER_SUPPORTS_CXX11)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ELSE()
MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
ENDIF()
option ( ENABLE_SPATIAL_SOLVERS "Should build AHOT spatial solvers?" OFF )
option ( ENABLE_ENSDF_PROCESSIONG "Should build ENSDF processing tools?" OFF )
include(PyneMacros)
pyne_print_logo() # Beware of dragons
pyne_set_platform()
pyne_setup_cxx()
pyne_set_asm_platform()
pyne_set_build_spatial_solver()
pyne_set_build_type()
pyne_set_fast_compile()
pyne_configure_rpath()
# enable assembly
enable_language(ASM)
# This makes all the libraries build as SHARED
set(BUILD_SHARED_LIBS true)
message("-- CMake Install Prefix: ${CMAKE_INSTALL_PREFIX}")
#
# Allow for dependnecies to exist in non-install location
#
if (NOT DEPS_ROOT_DIR)
get_filename_component(compdir ${CMAKE_CXX_COMPILER} DIRECTORY)
get_filename_component(DEPS_ROOT_DIR ${compdir} DIRECTORY)
endif (NOT DEPS_ROOT_DIR)
SET(DEPS_HINTS HINTS "${DEPS_ROOT_DIR}")
SET(DEPS_BIN_HINTS ${DEPS_HINTS} "${DEPS_ROOT_DIR}/bin")
SET(DEPS_LIB_HINTS ${DEPS_HINTS} "${DEPS_ROOT_DIR}/lib")
SET(DEPS_INCLUDE_HINTS HINTS "${DEPS_ROOT_DIR}/include")
MESSAGE("-- Dependency Root Dir (DEPS_ROOT_DIR): ${DEPS_ROOT_DIR}")
MESSAGE("-- Dependency Hints (DEPS_HINTS): ${DEPS_HINTS}")
MESSAGE("-- Dependency Binary Hints (DEPS_BIN_HINTS): ${DEPS_BIN_HINTS}")
MESSAGE("-- Dependency Library Hints (DEPS_LIB_HINTS): ${DEPS_LIB_HINTS}")
MESSAGE("-- Dependency Include Hints (DEPS_INCLUDE_HINTS): ${DEPS_INCLUDE_HINTS}")
#
# Find Libraries
#
# Find HDF5
MESSAGE("-- HDF5 Root: ${HDF5_ROOT}")
if(HDF5_ROOT)
FIND_PACKAGE(HDF5 REQUIRED)
else()
FIND_PACKAGE(HDF5)
endif()
if(NOT HDF5_FOUND AND NOT HDF5_ROOT)
MESSAGE("-- HDF5 not found on empty HDF5_ROOT, "
"setting to DEPS_ROOT_DIR: ${DEPS_ROOT_DIR}")
set(HDF5_ROOT "${DEPS_ROOT_DIR}")
FIND_PACKAGE(HDF5 REQUIRED)
endif()
ADD_DEFINITIONS(${HDF5_DEFINITIONS})
include_directories("${HDF5_INCLUDE_DIRS}")
if(NOT HDF5_LIBRARY_DIRS STREQUAL "")
link_directories(${HDF5_LIBRARY_DIRS})
endif()
set(LIBS_HDF5 ${HDF5_C_LIBRARIES})
set(LIBS ${LIBS} ${HDF5_C_LIBRARIES})
MESSAGE("-- HDF5 Include directory: ${HDF5_INCLUDE_DIRS}")
MESSAGE("-- HDF5 Library directories: ${HDF5_LIBRARY_DIRS}")
MESSAGE("-- HDF5 Libraries: ${HDF5_C_LIBRARIES}")
MESSAGE("-- HDF5 library version: ${HDF5_VERSION}")
# Version 1.12 of HDF5 deprecates the H5Oget_info_by_idx(),
# H5O_info_t() and H5Oget_info_by_name() interfaces.
# Thus, we give these flags to allow usage of the old interface in newer
# versions of HDF5.
if(NOT (${HDF5_VERSION} VERSION_LESS 1.12.0))
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DH5Oget_info_by_idx_vers=1 -DH5O_info_t_vers=1 -DH5Oget_info_by_name_vers=1")
endif()
# Look for MOAB if requested
if(WITH_MOAB)
# user may have set a search path
if(NOT MOAB_ROOT)
set(MOAB_ROOT "${DEPS_ROOT_DIR}")
endif()
MESSAGE("-- MOAB Root: ${MOAB_ROOT}")
find_package(MOAB)
message("-- MOAB Found: ${MOAB_FOUND}")
if(${MOAB_FOUND})
include_directories(${MOAB_INCLUDE_DIRS})
get_filename_component(MOAB_LIBRARY_DIRS ${MOAB_LIBRARY} PATH)
if(APPLE)
link_directories(${MOAB_LIBRARY_DIRS})
else(APPLE)
link_directories(${MOAB_LIBRARY_DIRS})
endif(APPLE)
endif(${MOAB_FOUND})
endif()
# Look for DAGMC if requested
if(WITH_DAGMC)
if(${MOAB_FOUND})
# Always look for DAGMC library
if(NOT DAGMC_ROOT)
set(DAGMC_ROOT "${DEPS_ROOT_DIR}")
endif()
MESSAGE("-- DAGMC Root: ${DAGMC_ROOT}")
find_package(DAGMC)
message("-- DAGMC Found: ${DAGMC_FOUND}")
if(${DAGMC_FOUND})
include_directories(${DAGMC_INCLUDE_DIRS})
link_directories(${DAGMC_LIBRARY_DIRS})
endif(${DAGMC_FOUND})
else(${MOAB_FOUND})
message("-- DAGMC: Not searching because MOAB was not found.")
endif(${MOAB_FOUND})
endif()
# Find Python
find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)
if(PYTHON_VERSION_MAJOR EQUAL 2)
set(SITE_PACKAGES_CODE
"import site; print site.getusersitepackages().replace(site.USER_BASE, '${CMAKE_INSTALL_PREFIX}', 1)")
else(PYTHON_VERSION_MAJOR EQUAL 2)
set(SITE_PACKAGES_CODE
"import site; print(site.getsitepackages(['${CMAKE_INSTALL_PREFIX}'])[0])")
endif(PYTHON_VERSION_MAJOR EQUAL 2)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "${SITE_PACKAGES_CODE}"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LIBS ${LIBS} ${PYTHON_LIBRARIES})
message("-- PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
message("-- PYTHON_SITE_PACKAGES: ${PYTHON_SITE_PACKAGES}")
# Find NumPy
find_package(Numpy REQUIRED)
include_directories("${NUMPY_INCLUDE_DIR}")
pyne_setup_fortran()
# Find f2py, if building spatial solver
IF(BUILD_SPATIAL_SOLVER)
find_package(F2py REQUIRED)
message("-- F2PY Executable: ${F2PY_EXECUTABLE}")
message("-- F2PY Version: ${F2PY_VERSION}")
FIND_PACKAGE(LAPACK REQUIRED)
MESSAGE("-- Found LAPACK Linker Flags: ${LAPACK_LINKER_FLAGS}")
MESSAGE("-- Found LAPACK Libraries: ${LAPACK_LIBRARIES}")
MESSAGE("-- Found BLAS Libraries: ${BLAS_LIBRARIES}")
ENDIF(BUILD_SPATIAL_SOLVER)
# Include the CMake script UseCython.cmake. This defines add_cython_module().
# Instruction for use can be found at the top of cmake/UseCython.cmake.
include(UseCython)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/pyne")
# Add JsonCpp Flag
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_IS_AMALGAMATION")
#
# Build and install!
#
message(STATUS "LIBS: ${LIBS}")
# With CMake, a clean separation can be made between the source tree and the
# build tree. When all source is compiled, as with pure C/C++, the source is
# no-longer needed in the build tree. However, with pure *.py source, the
# source is processed directly. To handle this, we reproduce the availability
# of the source files in the build tree.
add_custom_target(ReplicatePythonSourceTree ALL "${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/ReplicatePythonSourceTree.cmake"
"${CMAKE_CURRENT_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
# add sub dirs
add_subdirectory(src)
add_subdirectory(pyne)
add_subdirectory(pyne/xs)
# install python package
set(pyinstallscript "${CMAKE_CURRENT_BINARY_DIR}/cmake/SetupSubPyInstall.cmake")
configure_file(cmake/SetupSubPyInstall.cmake.in ${pyinstallscript} @ONLY)
install(SCRIPT ${pyinstallscript})