forked from ndarray/Boost.NumPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
156 lines (129 loc) · 4.29 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
cmake_minimum_required(VERSION 2.8.12)
project( boost.numpy )
set(BUILD_TESTS ON CACHE BOOL "Build Boost.NumPy Tests")
set(BUILD_EXAMPLES ON CACHE BOOL "Build Boost.NumPy Examples")
# put our local cmake find scripts at the beginning of the cmake
# module search path
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/libs/numpy/cmake ${CMAKE_MODULE_PATH})
IF (NOT DEFINED LIB_SUFFIX)
EXECUTE_PROCESS(
COMMAND uname -m
COMMAND tr -d '\n'
OUTPUT_VARIABLE ARCH
)
message(STATUS "Detected architecture '" ${ARCH} "'")
IF (ARCH STREQUAL x86_64)
SET(LIB_SUFFIX 64)
ENDIF (ARCH STREQUAL x86_64)
ENDIF (NOT DEFINED LIB_SUFFIX)
# configure output folders so artifacts are built into a single set of
# top-level folders rather than the default cmake build structure that
# matches the source tree.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
CACHE PATH "Output directory for static libraries.")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
CACHE PATH "Output directory for shared libraries.")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
CACHE PATH "Output directory for executables and DLL's.")
# find required python packages
find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)
find_package(NumPy REQUIRED)
# find boost
#
# set(Boost_USE_STATIC_LIBS ON)
# set(Boost_USE_MULTITHREADED ON)
# set(Boost_USE_STATIC_RUNTIME ON)
set(CMAKE_MACOSX_RPATH 1)
if(${PYTHON_VERSION_STRING} GREATER 3.0)
message(STATUS "Using Python3")
find_package(Boost COMPONENTS python3 REQUIRED)
else()
message(STATUS "Using Python2")
find_package(Boost COMPONENTS python REQUIRED)
endif()
message( STATUS "Boost Paths:")
message( STATUS "Include : " ${Boost_INCLUDE_DIRS})
message( STATUS "Libraries: " ${Boost_LIBRARIES})
if(MSVC)
# With Visual Studio remove the automatic linking
# feature
add_definitions( -DBOOST_ALL_NO_LIB )
endif()
if(Boost_USE_STATIC_LIBS)
# if the user specified he wants to link to static libraries
# force linking to static boost python
add_definitions( -DBOOST_PYTHON_STATIC_LIB )
endif()
# In some cases, you may need to explicitly specify that a dynamic Boost is used; if so use:
# add_definitions( -DBOOST_ALL_DYN_LINK )
# variable controlling whether the boost_numpy is a shared or static library
if (WIN32)
set(LIBRARY_TYPE STATIC CACHE STRING "type of library to make for boost_numpy")
else()
set(LIBRARY_TYPE SHARED CACHE STRING "type of library to make for boost_numpy")
endif()
# variable controlling building of documentation
set(BUILD_DOCS OFF CACHE BOOL "Build Boost.NumPy Documentation")
# logic for configuring documentation generation
if(BUILD_DOCS)
# find sphinx
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sphinx; print sphinx.__version__"
RESULT_VARIABLE SPHINX_PROCESS
OUTPUT_VARIABLE SPHINX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(HAVE_SPHINX 0)
if(SPHINX_PROCESS EQUAL 0)
FIND_PROGRAM(SPHINX_BUILD sphinx-build)
if(SPHINX_BUILD)
set(HAVE_SPHINX 1)
message(STATUS " Found Sphinx ${SPHINX_VERSION}: ${SPHINX_BUILD}")
else()
# sphinx is required to generate documention, so it is an error
# if we cannot find it
MESSAGE(SEND_ERROR "must be able to find sphinx-build when BUILD_DOCS is enabled")
endif()
endif()
# find pdflatex, which is only required for doc-pdf
FIND_PACKAGE(LATEX)
if (PDFLATEX_COMPILER)
message( STATUS "Found PDFLATEX_COMPILER=${PDFLATEX_COMPILER}" )
else()
message( STATUS "Found PDFLATEX_COMPILER NOT found" )
endif()
endif()
# compiler definitions for non-windows builds
if (NOT WIN32)
add_definitions(-fPIC)
endif()
if (BUILD_TESTS)
# enable ctest targets
ENABLE_TESTING()
endif()
# turn on visual studio solution folders
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
# global settings for include paths
include_directories(
${PROJECT_SOURCE_DIR}
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
# install headers
install(DIRECTORY boost
DESTINATION "include"
FILES_MATCHING
PATTERN "*.hpp"
${INSTALL_PERMISSIONS_SRC}
)
# add submodules
ADD_SUBDIRECTORY(libs/numpy/src)
if (BUILD_EXAMPLES)
ADD_SUBDIRECTORY(libs/numpy/example)
endif()
if (BUILD_TESTS)
ADD_SUBDIRECTORY(libs/numpy/test)
endif()
if (BUILD_DOCS)
ADD_SUBDIRECTORY(libs/numpy/doc)
endif()