Skip to content

Commit

Permalink
Merge pull request #72 from darioizzo/master
Browse files Browse the repository at this point in the history
2.1 tentative
  • Loading branch information
darioizzo authored Nov 24, 2017
2 parents b6c746f + ebea555 commit a927fc9
Show file tree
Hide file tree
Showing 30 changed files with 1,093 additions and 418 deletions.
190 changes: 100 additions & 90 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
cmake_minimum_required(VERSION 3.0.0)

PROJECT(pykep VERSION 2.0)
# We enable cmake test capability
ENABLE_TESTING()

# Set default build type to "Release", change it in the GUI if you need to build with debug.
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)

#Some screen output
MESSAGE(STATUS "OS detected: ${CMAKE_SYSTEM_NAME}")
MESSAGE(STATUS "CXX Compiler detected: ${CMAKE_CXX_COMPILER_ID}")

# Setting OS specific cmake variables
# 1 - OSX
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(CMAKE_MACOSX_RPATH OFF)
SET(CMAKE_OSX_ROOT "")
SET(CMAKE_OSX_DEPLOYMENT_TARGET "")
# Homebrew directory added to path
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/lib)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# 2 - NONE

# Some screen output
MESSAGE(STATUS "CMake additional search path for libraries: ${CMAKE_LIBRARY_PATH}")

# We set compiler specific flags
INCLUDE(cmake_scripts/set_compiler_flags.cmake)
# CMake version check.
cmake_minimum_required(VERSION 3.2)

# Main pykep project version.
set(PYKEP_PROJECT_VERSION 2.1)
project(pykep VERSION ${PYKEP_PROJECT_VERSION})
enable_testing()

# Module path setup.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules" "${CMAKE_SOURCE_DIR}/cmake_modules/yacma")

message(STATUS "System name: ${CMAKE_SYSTEM_NAME}")

# Set default build type to "Release".
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()

# Writing some configuration files with version update ...
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/sphinx/conf.py.in" "${CMAKE_CURRENT_SOURCE_DIR}/doc/sphinx/conf.py" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pykep/__init__.py.in" "${CMAKE_CURRENT_SOURCE_DIR}/pykep/__init__.py" @ONLY)

# Initial setup of compiler flags.
include(YACMACompilerLinkerSettings)

# Provides build options to CMake
# Build Option: when active the file main.cpp is built and linked to the pagmo static library
# Build Option: when active the file main.cpp is built and linked to the PYKEP static library
OPTION(BUILD_MAIN "Build 'main.cpp'." ON)

# Build Option: when active builds Python bindings called pykep
Expand All @@ -42,80 +35,97 @@ OPTION(BUILD_PYKEP "Build pykep." OFF)
# Build Option: when active the examples in the folder example are compiled into executables
OPTION(BUILD_TESTS "Build tests'." ON)

# Build Option: when active the JPL SPICE toolbox is used to extend pykep
# Build Option: when active the JPL SPICE toolbox is used to extend pykep. You can choose
# to build the library or use a pre-build library
OPTION(BUILD_SPICE "Interface pykep to JPL SPICE toolbox'." OFF)

# Build Option: when active headers will be installed in the CMAKE_INSTALL_PREFIX/include directory
OPTION(INSTALL_HEADERS "Installs the header files" OFF)

# Finding the boost libraries needed for the keplerian_toolbox
SET(REQUIRED_BOOST_LIBS serialization date_time)
IF(BUILD_PYKEP)
INCLUDE(cmake_scripts/python_setup.cmake)
IF(PYTHON_VERSION_MAJOR LESS 3)
SET(REQUIRED_BOOST_LIBS ${REQUIRED_BOOST_LIBS} python)
ELSE(PYTHON_VERSION_MAJOR LESS 3)
SET(REQUIRED_BOOST_LIBS ${REQUIRED_BOOST_LIBS} python3)
ENDIF(PYTHON_VERSION_MAJOR LESS 3)
ENDIF(BUILD_PYKEP)
MESSAGE(STATUS "Required Boost libraries: ${REQUIRED_BOOST_LIBS}")
# Minimum version must have std::array serialization
FIND_PACKAGE(Boost 1.56.0 REQUIRED COMPONENTS "${REQUIRED_BOOST_LIBS}")
MESSAGE(STATUS "Detected Boost version: ${Boost_VERSION}")
MESSAGE(STATUS "Boost include dirs: ${Boost_INCLUDE_DIRS}")
MESSAGE(STATUS "Boost libraries: ${Boost_LIBRARIES}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})

# Initialise (empty) list of libraries to link against.
SET(LIBRARIES_4_STATIC "")
SET(LIBRARIES_4_DYNAMIC "")
SET(LIBRARIES_4_PYTHON_MODULES "")

# Define the libraries to link against.
SET(LIBRARIES_4_STATIC ${LIBRARIES_4_STATIC} ${Boost_DATE_TIME_LIBRARY} ${Boost_SERIALIZATION_LIBRARY})
SET(LIBRARIES_4_DYNAMIC ${LIBRARIES_4_DYNAMIC} ${LIBRARIES_4_STATIC})
IF(PYTHON_VERSION_MAJOR LESS 3)
SET(LIBRARIES_4_PYTHON_MODULES ${LIBRARIES_4_PYTHON_MODULES} ${Boost_PYTHON_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_SERIALIZATION_LIBRARY})
ELSE(PYTHON_VERSION_MAJOR LESS 3)
SET(LIBRARIES_4_PYTHON_MODULES ${LIBRARIES_4_PYTHON_MODULES} ${Boost_PYTHON3_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_SERIALIZATION_LIBRARY})
ENDIF(PYTHON_VERSION_MAJOR LESS 3)
# Assemble the flags.
set(PYKEP_CXX_FLAGS_DEBUG ${YACMA_CXX_FLAGS} ${YACMA_CXX_FLAGS_DEBUG} ${YACMA_THREADING_CXX_FLAGS})
set(PYKEP_CXX_FLAGS_RELEASE ${YACMA_CXX_FLAGS} ${YACMA_THREADING_CXX_FLAGS})
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND YACMA_COMPILER_IS_CLANGXX)
message(STATUS "Clang compiler on OSX detected, setting the standard library to 'libc++'.")
list(APPEND PYKEP_CXX_FLAGS_DEBUG "-stdlib=libc++")
list(APPEND PYKEP_CXX_FLAGS_RELEASE "-stdlib=libc++")
endif()
if(YACMA_COMPILER_IS_MSVC)
# Disable the idiotic minmax macros on MSVC, some annoying warnings,
# and enable the bigobj option.
list(APPEND PYKEP_CXX_FLAGS_DEBUG "-DNOMINMAX" "/wd4459" "/wd4127" "/wd4702" "/bigobj")
list(APPEND PYKEP_CXX_FLAGS_RELEASE "-DNOMINMAX" "/wd4459" "/wd4127" "/wd4702" "/bigobj")
endif()
if(YACMA_COMPILER_IS_INTELXX)
# NOTE: on MSVC we use the push/pop pragmas, but they do not seem to work on Intel (the pragmas
# in icc influence the behaviour at instantiation point, not at definition point).
# These warnings are useful in principle, but they are generated a lot from cereal and we have no
# way of disabling them selectively. Just rely on the other compilers to provde good diagnostic.
list(APPEND PYKEP_CXX_FLAGS_DEBUG "-diag-disable" "2259,1682,68")
list(APPEND PYKEP_CXX_FLAGS_RELEASE "-diag-disable" "2259,1682,68")
endif()
if(MINGW)
# Flag needed to deal with big binaries in MinGW.
message(STATUS "Enabling the '-Wa,-mbig-obj' flag in MinGW builds.")
list(APPEND PYKEP_CXX_FLAGS_DEBUG "-Wa,-mbig-obj")
list(APPEND PYKEP_CXX_FLAGS_RELEASE "-Wa,-mbig-obj")
endif()

if(BUILD_PYKEP)
# pygmo dependencies.
include(YACMAPythonSetup)

# Python version check.
if(${PYTHON_VERSION_MAJOR} LESS 2 OR (${PYTHON_VERSION_MAJOR} EQUAL 2 AND ${PYTHON_VERSION_MINOR} LESS 7))
message(FATAL_ERROR "Minimum supported Python version is 2.7.")
endif()

# Internal variable that will be used to tell PYKEPFindBoost to locate Boost.Python.
set(_PYKEP_FIND_BOOST_PYTHON TRUE)
endif()

# Boost setup. Will allow using Boost::library_name for the needed components
include(PykepFindBoost)

# We build cspice static library and link it in pykep libraries
IF(BUILD_SPICE)
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/src/third_party/cspice")
SET(LIBRARIES_4_STATIC ${LIBRARIES_4_STATIC} cspice)
SET(LIBRARIES_4_DYNAMIC ${LIBRARIES_4_DYNAMIC} cspice)
ADD_DEFINITIONS(-DPYKEP_USING_SPICE)
ENDIF(BUILD_SPICE)
if(BUILD_SPICE)
add_subdirectory("${CMAKE_SOURCE_DIR}/src/third_party/cspice")
add_definitions(-DPYKEP_USING_SPICE)
endif(BUILD_SPICE)

# Here we define the file list and make the static and dynamic library
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/src")
add_subdirectory("${CMAKE_SOURCE_DIR}/src")

# Build main and link it to static library.
IF(BUILD_MAIN)
ADD_EXECUTABLE(main main.cpp)
TARGET_LINK_LIBRARIES(main keplerian_toolbox_static ${LIBRARIES_4_STATIC})
ENDIF(BUILD_MAIN)
if(BUILD_MAIN)
add_executable(main main.cpp)
target_link_libraries(main keplerian_toolbox_static Boost::boost Boost::serialization Boost::date_time)
set_property(TARGET main PROPERTY CXX_STANDARD 11)
set_property(TARGET main PROPERTY CXX_STANDARD_REQUIRED YES)
set_property(TARGET main PROPERTY CXX_EXTENSIONS NO)
endif(BUILD_MAIN)

# Build Tests and link them to static library.
if(BUILD_TESTS)
add_subdirectory("${CMAKE_SOURCE_DIR}/tests")
file(COPY "${CMAKE_SOURCE_DIR}/tests/data/sgp4_test.txt" DESTINATION "${CMAKE_BINARY_DIR}/tests")
file(COPY "${CMAKE_SOURCE_DIR}/tests/data/C_G_1000012_2012_2017.bsp" DESTINATION "${CMAKE_BINARY_DIR}/tests")
file(COPY "${CMAKE_SOURCE_DIR}/tests/data/pck00010.tpc" DESTINATION "${CMAKE_BINARY_DIR}/tests")
FILE(COPY "${CMAKE_SOURCE_DIR}/tests/data/gm_de431.tpc" DESTINATION "${CMAKE_BINARY_DIR}/tests")
endif(BUILD_TESTS)

# Build pykep and link it to dynamic library.
IF(BUILD_PYKEP)
SET(LIBRARIES_4_PYTHON_MODULES keplerian_toolbox ${LIBRARIES_4_PYTHON_MODULES})
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/pykep")
if(BUILD_PYKEP)
add_subdirectory("${CMAKE_SOURCE_DIR}/pykep")
if(MINGW)
message(STATUS "Creating the files for the generation of a binary wheel for MinGW.")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/mingw_wheel_setup.py" "${CMAKE_CURRENT_BINARY_DIR}/wheel/setup.py")
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")
else(MINGW)
message(STATUS "Creating the files for the generation of a manylinux binary wheel.")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/manylinux_wheel_setup.py" "${CMAKE_CURRENT_BINARY_DIR}/wheel/setup.py")
endif()
ENDIF(BUILD_PYKEP)
endif()
endif()



# Build Tests and link them to static library.
IF(BUILD_TESTS)
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/tests")
FILE(COPY "${CMAKE_SOURCE_DIR}/tests/data/sgp4_test.txt" DESTINATION "${CMAKE_BINARY_DIR}/tests")
FILE(COPY "${CMAKE_SOURCE_DIR}/tests/data/C_G_1000012_2012_2017.bsp" DESTINATION "${CMAKE_BINARY_DIR}/tests")
FILE(COPY "${CMAKE_SOURCE_DIR}/tests/data/pck00010.tpc" DESTINATION "${CMAKE_BINARY_DIR}/tests")
FILE(COPY "${CMAKE_SOURCE_DIR}/tests/data/gm_de431.tpc" DESTINATION "${CMAKE_BINARY_DIR}/tests")
ENDIF(BUILD_TESTS)
36 changes: 30 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,48 @@ environment:
TWINE_PASSWORD:
secure: UGpLM1eTRobLbka7TwQ3LA==
matrix:
#- BUILD_TYPE: "MSVC_64_Python36" # Still issues with python .... also many warning from conversions
# COMPILER: MSVC15
# PLATFORM: "x64"
#- BUILD_TYPE: "Release"
- BUILD_TYPE: "Python27"
- BUILD_TYPE: "Python34"
- BUILD_TYPE: "Python35"
- BUILD_TYPE: "Python36"


install:
- if [%BUILD_TYPE%]==[MSVC_64_Python36] set PATH=C:\Miniconda36-x64\Scripts;%PATH%
- if [%BUILD_TYPE%]==[MSVC_64_Python36] conda config --add channels conda-forge --force
- if [%BUILD_TYPE%]==[MSVC_64_Python36] conda clean --all -y
- if [%BUILD_TYPE%]==[MSVC_64_Python36] conda update conda -y
- if [%BUILD_TYPE%]==[MSVC_64_Python36] conda update --all -y
- if [%BUILD_TYPE%]==[MSVC_64_Python36] conda create -y --name pykep python=3.6 cmake boost
- if [%BUILD_TYPE%]==[MSVC_64_Python36] call activate pykep

- if [%BUILD_TYPE%]==[Python27] rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
- if [%BUILD_TYPE%]==[Python34] rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
- if [%BUILD_TYPE%]==[Python35] rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
- if [%BUILD_TYPE%]==[Python36] rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"

# Rename sh.exe as sh.exe in PATH interferes with MinGW.
- rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
# Get a Python version to run the script.
- call tools\appveyor-download.cmd "https://github.com/bluescarni/binary_deps/raw/master/python35_mingw_64.7z" -FileName python.7z
- 7z x -aoa -oC:\python4appveyor\ python.7z > NUL
# - call tools\appveyor-download.cmd "https://github.com/bluescarni/binary_deps/raw/master/python35_mingw_64.7z" -FileName python.7z
# - 7z x -aoa -oC:\python4appveyor\ python.7z > NUL

build_script:
- if [%BUILD_TYPE%]==[MSVC_64_Python36] mkdir build
- if [%BUILD_TYPE%]==[MSVC_64_Python36] cd build
- if [%BUILD_TYPE%]==[MSVC_64_Python36] cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%/Library -DCMAKE_BUILD_TYPE=Release -DBUILD_MAIN=no -DBUILD_TESTS=yes -DBUILD_SPICE=no -DBUILD_PYKEP=yes ..
- if [%BUILD_TYPE%]==[MSVC_64_Python36] cmake --build . --config Release --target install

- if [%BUILD_TYPE%]==[Python27] C:\Python36-x64\python.exe tools\install_appveyor.py
- if [%BUILD_TYPE%]==[Python34] C:\Python36-x64\python.exe tools\install_appveyor.py
- if [%BUILD_TYPE%]==[Python35] C:\Python36-x64\python.exe tools\install_appveyor.py
- if [%BUILD_TYPE%]==[Python36] C:\Python36-x64\python.exe tools\install_appveyor.py

- cd C:\projects\pykep
- C:\python4appveyor\Python35\python.exe tools\install_appveyor.py
test_script:
- if [%BUILD_TYPE%]==[MSVC_64_Python36] ctest --output-on-failure
- if [%BUILD_TYPE%]==[MSVC_64_Python36] python -c "import pykep as pk; e = pk.epoch(0)"

# Enable this to be able to login to the build worker. You can use the
# `remmina` program in Ubuntu, or Microsoft Remote Desktop app in osx
Expand Down
46 changes: 46 additions & 0 deletions cmake_modules/PykepFindBoost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
set(_PYKEP_REQUIRED_BOOST_LIBS)
list(APPEND _PYKEP_REQUIRED_BOOST_LIBS date_time serialization)
if(_PYKEP_FIND_BOOST_PYTHON)
if(${PYTHON_VERSION_MAJOR} EQUAL 2)
list(APPEND _PYKEP_REQUIRED_BOOST_LIBS python)
else()
list(APPEND _PYKEP_REQUIRED_BOOST_LIBS python3)
endif()
endif()

message(STATUS "Required Boost libraries: ${_PYKEP_REQUIRED_BOOST_LIBS}")
find_package(Boost 1.55.0 REQUIRED COMPONENTS "${_PYKEP_REQUIRED_BOOST_LIBS}")
if(NOT Boost_FOUND)
message(FATAL_ERROR "Not all requested Boost components were found, exiting.")
endif()
message(STATUS "Detected Boost version: ${Boost_VERSION}")
message(STATUS "Boost include dirs: ${Boost_INCLUDE_DIRS}")
# Might need to recreate targets if they are missing (e.g., older CMake versions).
if(NOT TARGET Boost::boost)
message(STATUS "The 'Boost::boost' target is missing, creating it.")
add_library(Boost::boost INTERFACE IMPORTED)
set_target_properties(Boost::boost PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
endif()
if(NOT TARGET Boost::disable_autolinking)
message(STATUS "The 'Boost::disable_autolinking' target is missing, creating it.")
add_library(Boost::disable_autolinking INTERFACE IMPORTED)
if(WIN32)
set_target_properties(Boost::disable_autolinking PROPERTIES INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB")
endif()
endif()
foreach(_PYKEP_BOOST_COMPONENT ${_PYKEP_REQUIRED_BOOST_LIBS})
if(NOT TARGET Boost::${_PYKEP_BOOST_COMPONENT})
message(STATUS "The 'Boost::${_PYKEP_BOOST_COMPONENT}' imported target is missing, creating it.")
string(TOUPPER ${_PYKEP_BOOST_COMPONENT} _PYKEP_BOOST_UPPER_COMPONENT)
if(Boost_USE_STATIC_LIBS)
add_library(Boost::${_PYKEP_BOOST_COMPONENT} STATIC IMPORTED)
else()
add_library(Boost::${_PYKEP_BOOST_COMPONENT} UNKNOWN IMPORTED)
endif()
set_target_properties(Boost::${_PYKEP_BOOST_COMPONENT} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
set_target_properties(Boost::${_PYKEP_BOOST_COMPONENT} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${Boost_${_PYKEP_BOOST_UPPER_COMPONENT}_LIBRARY}")
endif()
endforeach()
21 changes: 21 additions & 0 deletions cmake_modules/yacma/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016-2017 Francesco Biscani

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions cmake_modules/yacma/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# yacma

Yet another CMake modules archive.
Loading

0 comments on commit a927fc9

Please sign in to comment.