1
1
cmake_minimum_required (VERSION 3.13)
2
2
3
3
option (BUILD_PYTHON "Build the python module for the library" ON )
4
- option (USE_SPHINX "Use sphinx for documentation" ON )
4
+ option (USE_SPHINX "Use sphinx for documentation" OFF )
5
5
option (BUILD_SHARED_LIBS "Build shared libraries" ON )
6
6
7
7
# By default, build in Release mode. Must appear before project() command
@@ -32,9 +32,6 @@ message(STATUS "Found aGrUM: ${AGRUM_ROOTDIR} (found version \"${AGRUM_VERSION_S
32
32
33
33
find_package (OpenTURNS 1.23 CONFIG REQUIRED)
34
34
message (STATUS "Found OpenTURNS: ${OPENTURNS_ROOT_DIR} (found version \" ${OPENTURNS_VERSION_STRING} \" )" )
35
- if (NOT DEFINED OPENTURNS_PYTHON_MODULE_PATH)
36
- set (OPENTURNS_PYTHON_MODULE_PATH ${OPENTURNS_PYTHON3_MODULE_PATH} )
37
- endif ()
38
35
39
36
set (OTAGRUM_DEFINITIONS ${OPENTURNS_DEFINITIONS} )
40
37
if (NOT BUILD_SHARED_LIBS )
@@ -75,7 +72,8 @@ if (BUILD_PYTHON)
75
72
if (USE_SPHINX)
76
73
find_program (SPHINX_EXECUTABLE NAMES sphinx-build DOC "Sphinx Documentation Builder (sphinx-doc.org)" )
77
74
find_python_module (numpydoc)
78
- if (SPHINX_EXECUTABLE AND NUMPYDOC_FOUND AND MATPLOTLIB_FOUND)
75
+ find_python_module (sphinx_copybutton)
76
+ if (SPHINX_EXECUTABLE AND NUMPYDOC_FOUND AND SPHINX_COPYBUTTON_FOUND AND MATPLOTLIB_FOUND)
79
77
find_python_module (sphinx 1.1)
80
78
endif ()
81
79
if (NOT SPHINX_FOUND)
@@ -92,7 +90,11 @@ if (BUILD_PYTHON)
92
90
endif ()
93
91
94
92
# Guess agrum python module path
95
- set (AGRUM_PYTHON_MODULE_PATH ${AGRUM_ROOTDIR} /${OTAGRUM_PYTHON_MODULE_PATH} )
93
+ if (EXISTS ${AGRUM_ROOTDIR} /${CMAKE_INSTALL_LIBDIR} /python${Python_VERSION_MAJOR} .${Python_VERSION_MINOR} /site-packages)
94
+ set (AGRUM_PYTHON_MODULE_PATH ${AGRUM_ROOTDIR} /${CMAKE_INSTALL_LIBDIR} /python${Python_VERSION_MAJOR} .${Python_VERSION_MINOR} /site-packages)
95
+ elseif (EXISTS ${AGRUM_ROOTDIR} /${CMAKE_INSTALL_LIBDIR} /python${Python_VERSION_MAJOR} .${Python_VERSION_MINOR} /dist-packages)
96
+ set (AGRUM_PYTHON_MODULE_PATH ${AGRUM_ROOTDIR} /${CMAKE_INSTALL_LIBDIR} /python${Python_VERSION_MAJOR} .${Python_VERSION_MINOR} /dist-packages)
97
+ endif ()
96
98
97
99
# Define variables without OTAGRUM_ prefix with absolute paths
98
100
foreach (_var PYTHON_MODULE_PATH LIBRARY_PATH INCLUDE_PATH CONFIG_CMAKE_PATH)
@@ -107,19 +109,8 @@ foreach (_var PYTHON_MODULE_PATH LIBRARY_PATH INCLUDE_PATH CONFIG_CMAKE_PATH)
107
109
endforeach ()
108
110
109
111
# RPATH settings
110
- set (CMAKE_INSTALL_RPATH ${LIBRARY_PATH} )
111
- set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
112
- if (POLICY CMP0042)
113
- # Set MACOSX_RPATH to ON
114
- cmake_policy (SET CMP0042 NEW)
115
- endif ()
116
- if (POLICY CMP0078)
117
- # Set MACOSX_RPATH to ON
118
- cmake_policy (SET CMP0078 NEW)
119
- endif ()
120
- if (POLICY CMP0086)
121
- cmake_policy (SET CMP0086 NEW)
122
- endif ()
112
+ set (CMAKE_INSTALL_RPATH ${LIBRARY_PATH} )
113
+ set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
123
114
124
115
# Some useful macros to ease CMakeLists.txt file writing
125
116
set (SOURCEFILES "" CACHE INTERNAL "List of source files to compile" )
@@ -162,30 +153,30 @@ set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION})
162
153
163
154
164
155
# The tests can't be run if this function is absent
165
- enable_testing ()
166
- add_custom_target (tests COMMENT "Build tests" )
167
- add_custom_target (check COMMENT "Run pre-installation tests" )
168
- add_custom_target (installcheck COMMENT "Run post-installation tests" )
156
+ enable_testing ()
157
+ add_custom_target (tests COMMENT "Build tests" )
158
+ add_custom_target (check COMMENT "Run pre-installation tests" )
159
+ add_custom_target (installcheck COMMENT "Run post-installation tests" )
169
160
170
- add_subdirectory (lib)
171
- add_dependencies (check cppcheck)
161
+ add_subdirectory (lib)
162
+ add_dependencies (check cppcheck)
172
163
173
- if (Python_FOUND)
174
- add_subdirectory (python)
175
- add_dependencies (installcheck pyinstallcheck)
164
+ if (Python_FOUND AND SWIG_FOUND )
165
+ add_subdirectory (python)
166
+ add_dependencies (installcheck pyinstallcheck)
176
167
endif ()
177
168
178
169
179
170
# uninstall target
180
- configure_file (
181
- ${CMAKE_CURRENT_SOURCE_DIR} /cmake/cmake_uninstall.cmake.in
182
- ${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake
183
- IMMEDIATE @ONLY
171
+ configure_file (
172
+ ${CMAKE_CURRENT_SOURCE_DIR} /cmake/cmake_uninstall.cmake.in
173
+ ${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake
174
+ IMMEDIATE @ONLY
184
175
)
185
176
186
- add_custom_target ( uninstall
187
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake
188
- )
177
+ add_custom_target ( uninstall
178
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake
179
+ )
189
180
190
181
set ( OTAGRUM_LIBRARY otagrum )
191
182
set ( OTAGRUM_LIBRARIES ${OPENTURNS_LIBRARIES} )
0 commit comments