forked from pyne/pyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
123 lines (100 loc) · 4.32 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
# Defines the CMake commands/policies
cmake_minimum_required( VERSION 2.8.5 )
# Set the project name
project( pyne )
# Make the scripts available in the 'cmake' directory available for the
# 'include()' command, 'find_package()' command.
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/cmake )
# give an option for whether this should be built as a CI project
option(IS_CI "Is this project being built under continuous integration?" FALSE)
# Include the HDF5 library and c++ headers
find_package( HDF5 COMPONENTS C )
include_directories(${HDF5_INCLUDE_DIRS})
if(WIN32)
# FindHDF5 finds the includes but not the libraries on Windows (MSYS). Annoying!
get_filename_component(_hdf5libdir ${HDF5_INCLUDE_DIRS} PATH)
list(APPEND HDF5_LIBRARY_DIRS "${_hdf5libdir}/bin")
list(APPEND HDF5_LIBRARY_DIRS "${_hdf5libdir}/lib")
endif(WIN32)
link_directories(${HDF5_LIBRARY_DIRS})
add_definitions(${HDF5_DEFINITIONS})
set(LIBS ${LIBS} ${HDF5_C_LIBRARIES})
message("-- HDF5_LIBRARY_DIRS = ${HDF5_LIBRARY_DIRS}")
# Use new Python library finder
find_package(PythonInterp REQUIRED)
find_package(PythonLibsNew REQUIRED)
message("-- PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
# 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 )
# Also, there are some custom pyne macros to make for less verbosity
include( PyneMacros )
# Beware of dragons
print_logo()
# This makes all the libraries build as SHARED
set(BUILD_SHARED_LIBS true)
message("-- CMake Install Prefix: ${CMAKE_INSTALL_PREFIX}")
# RPATH Settings
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(APPLE)
# I think that this is the right thing to do for MacOSX 10.5+ --Anthony
set(CMAKE_INSTALL_RPATH "@rpath/lib")
elseif(WIN32)
if(MSVC)
# ??? Who knows what to do here?! --Anthony
elseif(CMAKE_COMPILER_IS_GNUC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/lib")
endif(MSVC)
else(APPLE)
# For linux
set(CMAKE_INSTALL_RPATH "\$ORIGIN/lib")
endif(APPLE)
message("-- RPATH: ${CMAKE_INSTALL_RPATH}")
# find numpy and include the numpy headers
find_package(Numpy REQUIRED)
include_directories(${NUMPY_INCLUDE_DIR})
# Add JsonCpp Flag
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_IS_AMALGAMATION")
# Add some CI-dependent stuff
message("-- Is CI: ${IS_CI}")
if(${IS_CI})
include_directories("/home/slave/anaconda/include/python2.7")
endif(${IS_CI})
# 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 cython version info to source tree
message("-- Making Cython Version.")
execute_process(COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/configure.py cython_version)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/pyne/_includes/
DESTINATION ${CMAKE_BINARY_DIR}/pyne/_includes/)
add_subdirectory(cpp)
add_subdirectory(pyne)
add_subdirectory(pyne/xs)
# Print include dir
get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
message("-- C_INCLUDE_PATH for ${CMAKE_CURRENT_SOURCE_DIR}: ${inc_dirs}")
message("-- Copying C/C++ header files.")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/cpp/ DESTINATION
${CMAKE_BINARY_DIR}/pyne/include/ FILES_MATCHING PATTERN "*.h")
message("-- Copying Cython header files.")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/pyne/
DESTINATION ${CMAKE_BINARY_DIR}/pyne/
FILES_MATCHING PATTERN "*.pxd"
PATTERN "lib" EXCLUDE
PATTERN "include" EXCLUDE)
message("-- Copying scripts.")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/scripts DESTINATION ${CMAKE_BINARY_DIR})
# Add cython version info to source tree
message("-- Making Metadata.")
execute_process(COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/configure.py metadata)