1
- cmake_minimum_required (VERSION 3.0.0 )
2
-
3
- PROJECT (pykep VERSION 2.0 )
4
- # We enable cmake test capability
5
- ENABLE_TESTING ()
6
-
7
- # Set default build type to "Release", change it in the GUI if you need to build with debug.
8
- IF (NOT CMAKE_BUILD_TYPE )
9
- SET (CMAKE_BUILD_TYPE Release CACHE STRING
10
- "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
11
- FORCE )
12
- ENDIF (NOT CMAKE_BUILD_TYPE )
13
-
14
- #Some screen output
15
- MESSAGE (STATUS "OS detected: ${CMAKE_SYSTEM_NAME} " )
16
- MESSAGE (STATUS "CXX Compiler detected: ${CMAKE_CXX_COMPILER_ID} " )
17
-
18
- # Setting OS specific cmake variables
19
- # 1 - OSX
20
- IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
21
- SET (CMAKE_MACOSX_RPATH OFF )
22
- SET (CMAKE_OSX_ROOT "" )
23
- SET (CMAKE_OSX_DEPLOYMENT_TARGET "" )
24
- # Homebrew directory added to path
25
- SET (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/lib )
26
- ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
27
- # 2 - NONE
28
-
29
- # Some screen output
30
- MESSAGE (STATUS "CMake additional search path for libraries: ${CMAKE_LIBRARY_PATH} " )
31
-
32
- # We set compiler specific flags
33
- INCLUDE (cmake_scripts/set_compiler_flags.cmake )
1
+ # CMake version check.
2
+ cmake_minimum_required (VERSION 3.2 )
3
+
4
+ # Main pykep project version.
5
+ set (PYKEP_PROJECT_VERSION 2.1 )
6
+ project (pykep VERSION ${PYKEP_PROJECT_VERSION} )
7
+ enable_testing ()
8
+
9
+ # Module path setup.
10
+ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR} /cmake_modules" "${CMAKE_SOURCE_DIR} /cmake_modules/yacma" )
11
+
12
+ message (STATUS "System name: ${CMAKE_SYSTEM_NAME} " )
13
+
14
+ # Set default build type to "Release".
15
+ if (NOT CMAKE_BUILD_TYPE )
16
+ set (CMAKE_BUILD_TYPE Release CACHE STRING
17
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
18
+ FORCE )
19
+ endif ()
20
+
21
+ # Writing some configuration files with version update ...
22
+ configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /doc/sphinx/conf.py.in" "${CMAKE_CURRENT_SOURCE_DIR} /doc/sphinx/conf.py" @ONLY )
23
+ configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /pykep/__init__.py.in" "${CMAKE_CURRENT_SOURCE_DIR} /pykep/__init__.py" @ONLY )
24
+
25
+ # Initial setup of compiler flags.
26
+ include (YACMACompilerLinkerSettings )
34
27
35
28
# Provides build options to CMake
36
- # Build Option: when active the file main.cpp is built and linked to the pagmo static library
29
+ # Build Option: when active the file main.cpp is built and linked to the PYKEP static library
37
30
OPTION (BUILD_MAIN "Build 'main.cpp'." ON )
38
31
39
32
# Build Option: when active builds Python bindings called pykep
@@ -42,80 +35,97 @@ OPTION(BUILD_PYKEP "Build pykep." OFF)
42
35
# Build Option: when active the examples in the folder example are compiled into executables
43
36
OPTION (BUILD_TESTS "Build tests'." ON )
44
37
45
- # Build Option: when active the JPL SPICE toolbox is used to extend pykep
38
+ # Build Option: when active the JPL SPICE toolbox is used to extend pykep. You can choose
39
+ # to build the library or use a pre-build library
46
40
OPTION (BUILD_SPICE "Interface pykep to JPL SPICE toolbox'." OFF )
47
41
48
42
# Build Option: when active headers will be installed in the CMAKE_INSTALL_PREFIX/include directory
49
43
OPTION (INSTALL_HEADERS "Installs the header files" OFF )
50
44
51
- # Finding the boost libraries needed for the keplerian_toolbox
52
- SET (REQUIRED_BOOST_LIBS serialization date_time )
53
- IF (BUILD_PYKEP )
54
- INCLUDE (cmake_scripts/python_setup.cmake )
55
- IF (PYTHON_VERSION_MAJOR LESS 3 )
56
- SET (REQUIRED_BOOST_LIBS ${REQUIRED_BOOST_LIBS} python )
57
- ELSE (PYTHON_VERSION_MAJOR LESS 3 )
58
- SET (REQUIRED_BOOST_LIBS ${REQUIRED_BOOST_LIBS} python3 )
59
- ENDIF (PYTHON_VERSION_MAJOR LESS 3 )
60
- ENDIF (BUILD_PYKEP )
61
- MESSAGE (STATUS "Required Boost libraries: ${REQUIRED_BOOST_LIBS} " )
62
- # Minimum version must have std::array serialization
63
- FIND_PACKAGE (Boost 1.56.0 REQUIRED COMPONENTS "${REQUIRED_BOOST_LIBS} " )
64
- MESSAGE (STATUS "Detected Boost version: ${Boost_VERSION} " )
65
- MESSAGE (STATUS "Boost include dirs: ${Boost_INCLUDE_DIRS} " )
66
- MESSAGE (STATUS "Boost libraries: ${Boost_LIBRARIES} " )
67
- INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS} )
68
-
69
- # Initialise (empty) list of libraries to link against.
70
- SET (LIBRARIES_4_STATIC "" )
71
- SET (LIBRARIES_4_DYNAMIC "" )
72
- SET (LIBRARIES_4_PYTHON_MODULES "" )
73
-
74
- # Define the libraries to link against.
75
- SET (LIBRARIES_4_STATIC ${LIBRARIES_4_STATIC} ${Boost_DATE_TIME_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} )
76
- SET (LIBRARIES_4_DYNAMIC ${LIBRARIES_4_DYNAMIC} ${LIBRARIES_4_STATIC} )
77
- IF (PYTHON_VERSION_MAJOR LESS 3 )
78
- SET (LIBRARIES_4_PYTHON_MODULES ${LIBRARIES_4_PYTHON_MODULES} ${Boost_PYTHON_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} )
79
- ELSE (PYTHON_VERSION_MAJOR LESS 3 )
80
- SET (LIBRARIES_4_PYTHON_MODULES ${LIBRARIES_4_PYTHON_MODULES} ${Boost_PYTHON3_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} )
81
- ENDIF (PYTHON_VERSION_MAJOR LESS 3 )
45
+ # Assemble the flags.
46
+ set (PYKEP_CXX_FLAGS_DEBUG ${YACMA_CXX_FLAGS} ${YACMA_CXX_FLAGS_DEBUG} ${YACMA_THREADING_CXX_FLAGS} )
47
+ set (PYKEP_CXX_FLAGS_RELEASE ${YACMA_CXX_FLAGS} ${YACMA_THREADING_CXX_FLAGS} )
48
+ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND YACMA_COMPILER_IS_CLANGXX )
49
+ message (STATUS "Clang compiler on OSX detected, setting the standard library to 'libc++'." )
50
+ list (APPEND PYKEP_CXX_FLAGS_DEBUG "-stdlib=libc++" )
51
+ list (APPEND PYKEP_CXX_FLAGS_RELEASE "-stdlib=libc++" )
52
+ endif ()
53
+ if (YACMA_COMPILER_IS_MSVC )
54
+ # Disable the idiotic minmax macros on MSVC, some annoying warnings,
55
+ # and enable the bigobj option.
56
+ list (APPEND PYKEP_CXX_FLAGS_DEBUG "-DNOMINMAX" "/wd4459" "/wd4127" "/wd4702" "/bigobj" )
57
+ list (APPEND PYKEP_CXX_FLAGS_RELEASE "-DNOMINMAX" "/wd4459" "/wd4127" "/wd4702" "/bigobj" )
58
+ endif ()
59
+ if (YACMA_COMPILER_IS_INTELXX )
60
+ # NOTE: on MSVC we use the push/pop pragmas, but they do not seem to work on Intel (the pragmas
61
+ # in icc influence the behaviour at instantiation point, not at definition point).
62
+ # These warnings are useful in principle, but they are generated a lot from cereal and we have no
63
+ # way of disabling them selectively. Just rely on the other compilers to provde good diagnostic.
64
+ list (APPEND PYKEP_CXX_FLAGS_DEBUG "-diag-disable" "2259,1682,68" )
65
+ list (APPEND PYKEP_CXX_FLAGS_RELEASE "-diag-disable" "2259,1682,68" )
66
+ endif ()
67
+ if (MINGW )
68
+ # Flag needed to deal with big binaries in MinGW.
69
+ message (STATUS "Enabling the '-Wa,-mbig-obj' flag in MinGW builds." )
70
+ list (APPEND PYKEP_CXX_FLAGS_DEBUG "-Wa,-mbig-obj" )
71
+ list (APPEND PYKEP_CXX_FLAGS_RELEASE "-Wa,-mbig-obj" )
72
+ endif ()
73
+
74
+ if (BUILD_PYKEP )
75
+ # pygmo dependencies.
76
+ include (YACMAPythonSetup )
77
+
78
+ # Python version check.
79
+ if (${PYTHON_VERSION_MAJOR} LESS 2 OR (${PYTHON_VERSION_MAJOR} EQUAL 2 AND ${PYTHON_VERSION_MINOR} LESS 7 ))
80
+ message (FATAL_ERROR "Minimum supported Python version is 2.7." )
81
+ endif ()
82
+
83
+ # Internal variable that will be used to tell PYKEPFindBoost to locate Boost.Python.
84
+ set (_PYKEP_FIND_BOOST_PYTHON TRUE )
85
+ endif ()
86
+
87
+ # Boost setup. Will allow using Boost::library_name for the needed components
88
+ include (PykepFindBoost )
82
89
83
90
# We build cspice static library and link it in pykep libraries
84
- IF (BUILD_SPICE )
85
- ADD_SUBDIRECTORY ("${CMAKE_SOURCE_DIR} /src/third_party/cspice" )
86
- SET (LIBRARIES_4_STATIC ${LIBRARIES_4_STATIC} cspice )
87
- SET (LIBRARIES_4_DYNAMIC ${LIBRARIES_4_DYNAMIC} cspice )
88
- ADD_DEFINITIONS (-DPYKEP_USING_SPICE )
89
- ENDIF (BUILD_SPICE )
91
+ if (BUILD_SPICE )
92
+ add_subdirectory ("${CMAKE_SOURCE_DIR} /src/third_party/cspice" )
93
+ add_definitions (-DPYKEP_USING_SPICE )
94
+ endif (BUILD_SPICE )
90
95
91
96
# Here we define the file list and make the static and dynamic library
92
- ADD_SUBDIRECTORY ("${CMAKE_SOURCE_DIR} /src" )
97
+ add_subdirectory ("${CMAKE_SOURCE_DIR} /src" )
93
98
94
99
# Build main and link it to static library.
95
- IF (BUILD_MAIN )
96
- ADD_EXECUTABLE (main main.cpp )
97
- TARGET_LINK_LIBRARIES (main keplerian_toolbox_static ${LIBRARIES_4_STATIC} )
98
- ENDIF (BUILD_MAIN )
100
+ if (BUILD_MAIN )
101
+ add_executable (main main.cpp )
102
+ target_link_libraries (main keplerian_toolbox_static Boost::boost Boost::serialization Boost::date_time )
103
+ set_property (TARGET main PROPERTY CXX_STANDARD 11 )
104
+ set_property (TARGET main PROPERTY CXX_STANDARD_REQUIRED YES )
105
+ set_property (TARGET main PROPERTY CXX_EXTENSIONS NO )
106
+ endif (BUILD_MAIN )
107
+
108
+ # Build Tests and link them to static library.
109
+ if (BUILD_TESTS )
110
+ add_subdirectory ("${CMAKE_SOURCE_DIR} /tests" )
111
+ file (COPY "${CMAKE_SOURCE_DIR} /tests/data/sgp4_test.txt" DESTINATION "${CMAKE_BINARY_DIR} /tests" )
112
+ file (COPY "${CMAKE_SOURCE_DIR} /tests/data/C_G_1000012_2012_2017.bsp" DESTINATION "${CMAKE_BINARY_DIR} /tests" )
113
+ file (COPY "${CMAKE_SOURCE_DIR} /tests/data/pck00010.tpc" DESTINATION "${CMAKE_BINARY_DIR} /tests" )
114
+ FILE (COPY "${CMAKE_SOURCE_DIR} /tests/data/gm_de431.tpc" DESTINATION "${CMAKE_BINARY_DIR} /tests" )
115
+ endif (BUILD_TESTS )
99
116
100
117
# Build pykep and link it to dynamic library.
101
- IF (BUILD_PYKEP )
102
- SET (LIBRARIES_4_PYTHON_MODULES keplerian_toolbox ${LIBRARIES_4_PYTHON_MODULES} )
103
- ADD_SUBDIRECTORY ("${CMAKE_SOURCE_DIR} /pykep" )
118
+ if (BUILD_PYKEP )
119
+ add_subdirectory ("${CMAKE_SOURCE_DIR} /pykep" )
104
120
if (MINGW )
105
121
message (STATUS "Creating the files for the generation of a binary wheel for MinGW." )
106
122
configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /tools/mingw_wheel_setup.py" "${CMAKE_CURRENT_BINARY_DIR} /wheel/setup.py" )
107
123
configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /tools/mingw_wheel_libs_python${PYTHON_VERSION_MAJOR} .txt" "${CMAKE_CURRENT_BINARY_DIR} /wheel/mingw_wheel_libs_python${PYTHON_VERSION_MAJOR} .txt" )
108
124
else (MINGW )
109
125
message (STATUS "Creating the files for the generation of a manylinux binary wheel." )
110
126
configure_file ("${CMAKE_CURRENT_SOURCE_DIR} /tools/manylinux_wheel_setup.py" "${CMAKE_CURRENT_BINARY_DIR} /wheel/setup.py" )
111
- endif ()
112
- ENDIF (BUILD_PYKEP )
127
+ endif ()
128
+ endif ()
129
+
130
+
113
131
114
- # Build Tests and link them to static library.
115
- IF (BUILD_TESTS )
116
- ADD_SUBDIRECTORY ("${CMAKE_SOURCE_DIR} /tests" )
117
- FILE (COPY "${CMAKE_SOURCE_DIR} /tests/data/sgp4_test.txt" DESTINATION "${CMAKE_BINARY_DIR} /tests" )
118
- FILE (COPY "${CMAKE_SOURCE_DIR} /tests/data/C_G_1000012_2012_2017.bsp" DESTINATION "${CMAKE_BINARY_DIR} /tests" )
119
- FILE (COPY "${CMAKE_SOURCE_DIR} /tests/data/pck00010.tpc" DESTINATION "${CMAKE_BINARY_DIR} /tests" )
120
- FILE (COPY "${CMAKE_SOURCE_DIR} /tests/data/gm_de431.tpc" DESTINATION "${CMAKE_BINARY_DIR} /tests" )
121
- ENDIF (BUILD_TESTS )
0 commit comments