Added module for Boost detection and automatic build-up
This commit is contained in:
parent
ea694c0bdd
commit
1780e4a189
12
.travis.yml
12
.travis.yml
@ -1,5 +1,8 @@
|
||||
sudo: false
|
||||
language: cpp
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@ -21,10 +24,17 @@ addons:
|
||||
- libopenmpi-dev
|
||||
# Python library, development version
|
||||
- libpython2.7
|
||||
before_install:
|
||||
- if test ${TRAVIS_OS_NAME} = osx; then brew update; fi
|
||||
- if test ${TRAVIS_OS_NAME} = osx; then brew outdated xctool || brew upgrade xctool; fi
|
||||
- if test ${TRAVIS_OS_NAME} = osx; then brew install python open-mpi; fi
|
||||
- if test ${TRAVIS_OS_NAME} = osx; then brew linkapps python; fi
|
||||
before_script:
|
||||
- export PATH=$HOME/.local/bin:$PATH
|
||||
# PEP8 and py.test
|
||||
- pip install pytest pep8 --user `whoami`
|
||||
- if test ${TRAVIS_OS_NAME} = linux;
|
||||
then pip install --upgrade pip setuptools pytest pep8 --user `whoami`;
|
||||
else sudo pip install --upgrade pip setuptools pytest pep8; fi
|
||||
script:
|
||||
# test PEP8 conformity
|
||||
- pep8 --ignore=E501 update.py
|
||||
|
161
modules/boost/boost.cmake
Normal file
161
modules/boost/boost.cmake
Normal file
@ -0,0 +1,161 @@
|
||||
#.rst:
|
||||
#
|
||||
# Boost libraries detection and automatic build-up.
|
||||
# Minimum required version of Boost and required components have to
|
||||
# be specified separately in ``custom/boost_version-components.cmake``
|
||||
# By "required components" we here mean compiled Boost libraries.
|
||||
# This modules downloads the .zip archive from sourceforge at project
|
||||
# bootstrap.
|
||||
# Your autocmake.cfg should look like this::
|
||||
#
|
||||
# [custom]
|
||||
# source: custom/boost_version-components.cmake
|
||||
#
|
||||
# [boost]
|
||||
# source: https://github.com/robertodr/autocmake/raw/booster/modules/boost/boost.cmake
|
||||
# fetch: http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.zip
|
||||
#
|
||||
# The ``custom/boost_version-components.cmake`` should look like this::
|
||||
#
|
||||
# set(BOOST_MINIMUM_REQUIRED 1.58.0)
|
||||
# list(APPEND BOOST_COMPONENTS_REQUIRED chrono timer system)
|
||||
#
|
||||
# Caveats:
|
||||
#
|
||||
# #. cross-dependencies between required components are not checked for.
|
||||
# For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you
|
||||
# should ask explicitly for all three
|
||||
# #. the project admin has to make sure that ``BOOST_MINIMUM_REQUIRED`` and the
|
||||
# ``fetch`` directive point to the same version of Boost
|
||||
#
|
||||
# Dependencies::
|
||||
#
|
||||
# mpi - Only if the Boost.MPI library is a needed component
|
||||
# python_libs - Only if the Boost.Python library is a needed component
|
||||
#
|
||||
# Variables used::
|
||||
#
|
||||
# BOOST_MINIMUM_REQUIRED - Minimum required version of Boost, set in ``custom/boost_version-components.cmake``
|
||||
# BOOST_COMPONENTS_REQUIRED - Components (compiled Boost libraries) required
|
||||
# PROJECT_SOURCE_DIR
|
||||
# PROJECT_BINARY_DIR
|
||||
# CMAKE_BUILD_TYPE
|
||||
# MPI_FOUND
|
||||
#
|
||||
# Variables set::
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
#
|
||||
# fetch: https://github.com/robertodr/autocmake/raw/booster/modules/boost/boost_unpack.cmake
|
||||
# https://github.com/robertodr/autocmake/raw/booster/modules/boost/boost_userconfig.cmake
|
||||
# https://github.com/robertodr/autocmake/raw/booster/modules/boost/boost_configure.cmake
|
||||
# https://github.com/robertodr/autocmake/raw/booster/modules/boost/boost_build.cmake
|
||||
# https://github.com/robertodr/autocmake/raw/booster/modules/boost/boost_install.cmake
|
||||
# https://github.com/robertodr/autocmake/raw/booster/modules/boost/boost_headers.cmake
|
||||
# https://github.com/robertodr/autocmake/raw/booster/modules/boost/boost_cleanup.cmake
|
||||
# docopt: --boost-headers=<BOOST_INCLUDEDIR> Include directories for Boost [default: ''].
|
||||
# --boost-libraries=<BOOST_LIBRARYDIR> Library directories for Boost [default: ''].
|
||||
# --build-boost=<FORCE_CUSTOM_BOOST> Deactivate Boost detection and build on-the-fly <ON/OFF> [default: OFF].
|
||||
# define: '-DBOOST_INCLUDEDIR="%s"' % arguments['--boost-headers']
|
||||
# '-DBOOST_LIBRARYDIR="%s"' % arguments['--boost-libraries']
|
||||
# '-DFORCE_CUSTOM_BOOST="%s"' % arguments['--build-boost']
|
||||
|
||||
# FIXME Maintainer should be able to choose between fail (end-user has to satisfy dependency
|
||||
# on its own) and soft-fail (self-build of Boost)
|
||||
# Underscore-separated version number
|
||||
string(REGEX REPLACE "\\." "_" BOOSTVER ${BOOST_MINIMUM_REQUIRED})
|
||||
# Where the Boost .zip archive is located
|
||||
set(BOOST_ARCHIVE_LOCATION ${CMAKE_CURRENT_LIST_DIR})
|
||||
set(BOOST_ARCHIVE boost_${BOOSTVER}.zip)
|
||||
|
||||
# FIXME These are possibly not always good settings
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
set(Boost_DEBUG OFF)
|
||||
set(Boost_DETAILED_FAILURE_MESSAGE OFF)
|
||||
|
||||
set(BUILD_CUSTOM_BOOST FALSE)
|
||||
if(FORCE_CUSTOM_BOOST)
|
||||
set(BUILD_CUSTOM_BOOST TRUE)
|
||||
# Just to avoid unused variable warning from CMake
|
||||
set(BOOST_INCLUDEDIR "")
|
||||
set(BOOST_LIBRARYDIR "")
|
||||
else(FORCE_CUSTOM_BOOST)
|
||||
find_package(Boost QUIET ${BOOST_MINIMUM_REQUIRED} COMPONENTS "${BOOST_COMPONENTS_REQUIRED}")
|
||||
if(NOT Boost_FOUND)
|
||||
set(BUILD_CUSTOM_BOOST TRUE)
|
||||
endif(NOT Boost_FOUND)
|
||||
endif(FORCE_CUSTOM_BOOST)
|
||||
|
||||
if(BUILD_CUSTOM_BOOST)
|
||||
## Preliminary work
|
||||
# 0. Root directory for the custom build
|
||||
set(CUSTOM_BOOST_LOCATION ${PROJECT_BINARY_DIR}/boost)
|
||||
file(MAKE_DIRECTORY ${CUSTOM_BOOST_LOCATION})
|
||||
# 1. Where Boost will be built
|
||||
set(BOOST_BUILD_DIR ${CUSTOM_BOOST_LOCATION}/boost_${BOOSTVER})
|
||||
# 2. Select toolset according to compilers specified by the user
|
||||
set(toolset "")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
set(toolset "intel-linux")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
set(toolset "clang")
|
||||
else()
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Darwin)
|
||||
set(toolset "darwin")
|
||||
else()
|
||||
set(toolset "gcc")
|
||||
endif()
|
||||
endif()
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} type)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_unpack.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_userconfig.cmake)
|
||||
if(BOOST_COMPONENTS_REQUIRED)
|
||||
# Non-empty list. Compiled libraries needed
|
||||
# Transform the ;-separated list to a ,-separated list (digested by the Boost build toolchain!)
|
||||
string(REPLACE ";" "," b2_needed_components "${BOOST_COMPONENTS_REQUIRED}")
|
||||
# Replace unit_test_framework (used by CMake's find_package) with test (understood by Boost build toolchain)
|
||||
string(REPLACE "unit_test_framework" "test" b2_needed_components "${b2_needed_components}")
|
||||
set(select_libraries "--with-libraries=${b2_needed_components}")
|
||||
string(REPLACE ";" ", " printout "${BOOST_COMPONENTS_REQUIRED}")
|
||||
message(STATUS "Could NOT find Boost ${BOOST_MINIMUM_REQUIRED}")
|
||||
message(STATUS " Libraries to be built: ${printout}")
|
||||
message(STATUS " Toolset to be used: ${toolset}")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_configure.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_build.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_install.cmake)
|
||||
else(BOOST_COMPONENTS_REQUIRED)
|
||||
# Empty list. Header-only libraries needed
|
||||
# Just unpack to known location
|
||||
message(STATUS "Could NOT find Boost ${BOOST_MINIMUM_REQUIRED}")
|
||||
message(STATUS " No libraries required, installing headers")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_headers.cmake)
|
||||
endif(BOOST_COMPONENTS_REQUIRED)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boost_cleanup.cmake)
|
||||
add_custom_target(custom_boost DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.cleanedup)
|
||||
# 4. Set all variables related to Boost that find_package would have set
|
||||
set(Boost_FOUND TRUE)
|
||||
string(REGEX REPLACE "\\." "0" Boost_VERSION ${BOOST_MINIMUM_REQUIRED})
|
||||
math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
|
||||
math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
|
||||
math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
|
||||
set(Boost_LIB_VERSION ${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION})
|
||||
set(Boost_INCLUDE_DIR ${CUSTOM_BOOST_LOCATION}/include CACHE PATH "Boost include directory" FORCE)
|
||||
set(Boost_LIBRARY_DIR ${CUSTOM_BOOST_LOCATION}/lib CACHE PATH "Boost library directory" FORCE)
|
||||
foreach(_component ${BOOST_COMPONENTS_REQUIRED})
|
||||
string(TOUPPER ${_component} _COMP)
|
||||
set(Boost_${_COMP}_FOUND TRUE)
|
||||
set(Boost_${_COMP}_LIBRARY libboost_${_component}.a)
|
||||
set(Boost_${_COMP}_LIBRARY_DEBUG ${Boost_LIBRARY_DIR}/${Boost_${_COMP}_LIBRARY} CACHE FILEPATH "Boost ${_component} library (debug)" FORCE)
|
||||
set(Boost_${_COMP}_LIBRARY_RELEASE ${Boost_LIBRARY_DIR}/${Boost_${_COMP}_LIBRARY} CACHE FILEPATH "Boost ${_component} library (release)" FORCE)
|
||||
list(APPEND Boost_LIBRARIES ${Boost_${_COMP}_LIBRARY})
|
||||
endforeach()
|
||||
set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
||||
set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR})
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
list(APPEND Boost_LIBRARIES rt)
|
||||
endif()
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
endif(BUILD_CUSTOM_BOOST)
|
9
modules/boost/boost_build.cmake
Normal file
9
modules/boost/boost_build.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
# Build Boost
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.built
|
||||
COMMAND ./b2 toolset=${toolset} variant=${type} link=static cxxflags=-fPIC
|
||||
threading=multi --user-config=user-config.jam 1> ${CUSTOM_BOOST_LOCATION}/boost.built.log 2> ${CUSTOM_BOOST_LOCATION}/boost.built.err
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.built
|
||||
WORKING_DIRECTORY ${BOOST_BUILD_DIR}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.configured
|
||||
COMMENT "Building Boost")
|
8
modules/boost/boost_cleanup.cmake
Normal file
8
modules/boost/boost_cleanup.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
# Clean-up
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.cleanedup
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${BOOST_BUILD_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.cleanedup
|
||||
WORKING_DIRECTORY ${CUSTOM_BOOST_LOCATION}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
COMMENT "Clean-up Boost")
|
11
modules/boost/boost_configure.cmake
Normal file
11
modules/boost/boost_configure.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
# Run bootstrap.sh to configure the build. We will install in ${PROJECT_BINARY_DIR}/boost
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.configured
|
||||
COMMAND ./bootstrap.sh --with-toolset=${toolset}
|
||||
${select_libraries}
|
||||
--with-python=${PYTHON_EXECUTABLE}
|
||||
--prefix=${CUSTOM_BOOST_LOCATION} 1> ${CUSTOM_BOOST_LOCATION}/boost.configured.log 2> ${CUSTOM_BOOST_LOCATION}/boost.configured.err
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.configured
|
||||
WORKING_DIRECTORY ${BOOST_BUILD_DIR}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.user-config
|
||||
COMMENT "Configuring Boost")
|
8
modules/boost/boost_headers.cmake
Normal file
8
modules/boost/boost_headers.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
# Install Boost
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${BOOST_BUILD_DIR}/boost ${CUSTOM_BOOST_LOCATION}/include
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
WORKING_DIRECTORY ${BOOST_BUILD_DIR}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.user-config
|
||||
COMMENT "Installing Boost headers")
|
9
modules/boost/boost_install.cmake
Normal file
9
modules/boost/boost_install.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
# Install Boost
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
COMMAND ./b2 install toolset=${toolset} variant=${type} link=static
|
||||
threading=multi --user-config=user-config.jam 1> ${CUSTOM_BOOST_LOCATION}/boost.installed.log 2> ${CUSTOM_BOOST_LOCATION}/boost.installed.err
|
||||
COMMAND ${CMAKE_COMMAND} -E touch ${CUSTOM_BOOST_LOCATION}/boost.installed
|
||||
WORKING_DIRECTORY ${BOOST_BUILD_DIR}
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.built
|
||||
COMMENT "Installing Boost headers and libs")
|
8
modules/boost/boost_unpack.cmake
Normal file
8
modules/boost/boost_unpack.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
# Unpack Boost
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.unpacked
|
||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${BOOST_ARCHIVE_LOCATION}/${BOOST_ARCHIVE}
|
||||
COMMAND touch boost.unpacked
|
||||
DEPENDS ${BOOST_ARCHIVE_LOCATION}/${BOOST_ARCHIVE}
|
||||
WORKING_DIRECTORY ${CUSTOM_BOOST_LOCATION}
|
||||
COMMENT "Unpacking Boost")
|
15
modules/boost/boost_userconfig.cmake
Normal file
15
modules/boost/boost_userconfig.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
# To get boost to compile MPI we need to append "using mpi ;" to the end of the
|
||||
# user-config.jam file. MPI_SENT will be the command we append
|
||||
set(MPI_SENT "")
|
||||
if(ENABLE_MPI AND MPI_FOUND)
|
||||
set(MPI_SENT "using mpi \;")
|
||||
endif()
|
||||
file(WRITE ${CUSTOM_BOOST_LOCATION}/user-config.jam ${MPI_SENT})
|
||||
# Write user-config.jam
|
||||
add_custom_command(
|
||||
OUTPUT ${CUSTOM_BOOST_LOCATION}/boost.user-config
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CUSTOM_BOOST_LOCATION}/user-config.jam ${BOOST_BUILD_DIR}/user-config.jam
|
||||
COMMAND touch boost.user-config
|
||||
DEPENDS ${CUSTOM_BOOST_LOCATION}/boost.unpacked
|
||||
WORKING_DIRECTORY ${CUSTOM_BOOST_LOCATION}
|
||||
COMMENT "Generating user-config.jam")
|
@ -10,6 +10,8 @@
|
||||
# Variables modified (provided the corresponding language is enabled)::
|
||||
#
|
||||
# CMAKE_Fortran_FLAGS
|
||||
# CMAKE_C_FLAGS
|
||||
# CMAKE_CXX_FLAGS
|
||||
#
|
||||
# autocmake.cfg configuration::
|
||||
#
|
||||
@ -25,6 +27,12 @@ if(ENABLE_MPI AND NOT MPI_FOUND)
|
||||
if(DEFINED CMAKE_Fortran_COMPILER_ID)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${MPI_COMPILE_FLAGS}")
|
||||
endif()
|
||||
if(DEFINED CMAKE_C_COMPILER_ID)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_COMPILE_FLAGS}")
|
||||
endif()
|
||||
if(DEFINED CMAKE_CXX_COMPILER_ID)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_COMPILE_FLAGS}")
|
||||
endif()
|
||||
include_directories(${MPI_INCLUDE_PATH})
|
||||
else()
|
||||
message(FATAL_ERROR "-- You asked for MPI, but CMake could not find any MPI installation, check $PATH")
|
||||
|
19
test/boost_header_only/cmake/autocmake.cfg
Normal file
19
test/boost_header_only/cmake/autocmake.cfg
Normal file
@ -0,0 +1,19 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[custom]
|
||||
source: custom/boost_version-components.cmake
|
||||
|
||||
[boost]
|
||||
source: ../../../modules/boost/boost.cmake
|
||||
fetch: http://sourceforge.net/projects/boost/files/boost/1.48.0/boost_1_48_0.zip
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
@ -0,0 +1,2 @@
|
||||
set(BOOST_MINIMUM_REQUIRED 1.48.0)
|
||||
list(APPEND BOOST_COMPONENTS_REQUIRED)
|
1
test/boost_header_only/src/CMakeLists.txt
Normal file
1
test/boost_header_only/src/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_executable(example example.cpp)
|
17
test/boost_header_only/src/example.cpp
Normal file
17
test/boost_header_only/src/example.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include <iostream>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Boost version: "
|
||||
<< BOOST_VERSION / 100000
|
||||
<< "."
|
||||
<< BOOST_VERSION / 100 % 1000
|
||||
<< "."
|
||||
<< BOOST_VERSION % 100
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
19
test/boost_libs/cmake/autocmake.cfg
Normal file
19
test/boost_libs/cmake/autocmake.cfg
Normal file
@ -0,0 +1,19 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[custom]
|
||||
source: custom/boost_version-components.cmake
|
||||
|
||||
[boost]
|
||||
source: ../../../modules/boost/boost.cmake
|
||||
fetch: http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.zip
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
@ -0,0 +1,2 @@
|
||||
set(BOOST_MINIMUM_REQUIRED 1.59.0)
|
||||
list(APPEND BOOST_COMPONENTS_REQUIRED chrono timer system)
|
5
test/boost_libs/src/CMakeLists.txt
Normal file
5
test/boost_libs/src/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
add_executable(example example.cpp)
|
||||
if(BUILD_CUSTOM_BOOST)
|
||||
add_dependencies(example custom_boost)
|
||||
endif()
|
||||
target_link_libraries(example ${Boost_TIMER_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_SYSTEM_LIBRARY})
|
28
test/boost_libs/src/example.cpp
Normal file
28
test/boost_libs/src/example.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <boost/timer/timer.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::timer::auto_cpu_timer t;
|
||||
|
||||
std::cout << "Boost version: "
|
||||
<< BOOST_VERSION / 100000
|
||||
<< "."
|
||||
<< BOOST_VERSION / 100 % 1000
|
||||
<< "."
|
||||
<< BOOST_VERSION % 100
|
||||
<< std::endl;
|
||||
|
||||
|
||||
std::cout << "Measuring some timings..." << std::endl;
|
||||
for (long i = 0; i < 100000000; ++i)
|
||||
std::sqrt(123.456L); // burn some time
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
22
test/boost_mpi_libs/cmake/autocmake.cfg
Normal file
22
test/boost_mpi_libs/cmake/autocmake.cfg
Normal file
@ -0,0 +1,22 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[mpi]
|
||||
source: ../../../modules/mpi.cmake
|
||||
|
||||
[custom]
|
||||
source: custom/boost_version-components.cmake
|
||||
|
||||
[boost]
|
||||
source: ../../../modules/boost/boost.cmake
|
||||
fetch: http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.zip
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
@ -0,0 +1,2 @@
|
||||
set(BOOST_MINIMUM_REQUIRED 1.59.0)
|
||||
list(APPEND BOOST_COMPONENTS_REQUIRED mpi serialization)
|
5
test/boost_mpi_libs/src/CMakeLists.txt
Normal file
5
test/boost_mpi_libs/src/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
add_executable(example example.cpp)
|
||||
if(BUILD_CUSTOM_BOOST)
|
||||
add_dependencies(example custom_boost)
|
||||
endif()
|
||||
target_link_libraries(example ${Boost_MPI_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} ${MPI_CXX_LIBRARIES})
|
26
test/boost_mpi_libs/src/example.cpp
Normal file
26
test/boost_mpi_libs/src/example.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/mpi/environment.hpp>
|
||||
#include <boost/mpi/communicator.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace mpi = boost::mpi;
|
||||
std::cout << "Boost version: "
|
||||
<< BOOST_VERSION / 100000
|
||||
<< "."
|
||||
<< BOOST_VERSION / 100 % 1000
|
||||
<< "."
|
||||
<< BOOST_VERSION % 100
|
||||
<< std::endl;
|
||||
|
||||
mpi::environment env;
|
||||
mpi::communicator world;
|
||||
std::cout << "I am process " << world.rank() << " of " << world.size()
|
||||
<< "." << std::endl;
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
25
test/boost_python_libs/cmake/autocmake.cfg
Normal file
25
test/boost_python_libs/cmake/autocmake.cfg
Normal file
@ -0,0 +1,25 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[python_interpreter]
|
||||
source: ../../../modules/python_interpreter.cmake
|
||||
|
||||
[python_libs]
|
||||
source: ../../../modules/python_libs.cmake
|
||||
|
||||
[custom]
|
||||
source: custom/boost_version-components.cmake
|
||||
|
||||
[boost]
|
||||
source: ../../../modules/boost/boost.cmake
|
||||
fetch: http://sourceforge.net/projects/boost/files/boost/1.56.0/boost_1_56_0.zip
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
@ -0,0 +1,2 @@
|
||||
set(BOOST_MINIMUM_REQUIRED 1.56.0)
|
||||
list(APPEND BOOST_COMPONENTS_REQUIRED python)
|
5
test/boost_python_libs/src/CMakeLists.txt
Normal file
5
test/boost_python_libs/src/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
add_executable(example example.cpp)
|
||||
if(BUILD_CUSTOM_BOOST)
|
||||
add_dependencies(example custom_boost)
|
||||
endif()
|
||||
target_link_libraries(example ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES})
|
38
test/boost_python_libs/src/example.cpp
Normal file
38
test/boost_python_libs/src/example.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
std::cout << "Boost version: "
|
||||
<< BOOST_VERSION / 100000
|
||||
<< "."
|
||||
<< BOOST_VERSION / 100 % 1000
|
||||
<< "."
|
||||
<< BOOST_VERSION % 100
|
||||
<< std::endl;
|
||||
|
||||
try {
|
||||
Py_Initialize();
|
||||
|
||||
object main_module((
|
||||
handle<>(borrowed(PyImport_AddModule("__main__")))));
|
||||
|
||||
object main_namespace = main_module.attr("__dict__");
|
||||
|
||||
handle<> ignored(( PyRun_String( "print \"Hello, World\"",
|
||||
Py_file_input,
|
||||
main_namespace.ptr(),
|
||||
main_namespace.ptr() ) ));
|
||||
} catch( error_already_set ) {
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cc]
|
||||
source: ../../../modules/cc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cc]
|
||||
source: ../../../modules/cc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: ../../../modules/fc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: ../../../modules/fc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: ../../../modules/fc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: ../../../modules/fc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: ../../../modules/fc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: ../../../modules/fc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[fc]
|
||||
source: ../../../modules/fc.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name: example
|
||||
minimum_cmake_version: 2.8
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
24
test/test.py
24
test/test.py
@ -230,5 +230,25 @@ def test_python_libs():
|
||||
|
||||
|
||||
def test_python_libs_custom():
|
||||
setup = 'python setup.py --cxx=g++ --python=%s' % sys.executable
|
||||
configure_build_and_exe('python_libs_custom', setup)
|
||||
python_executable = sys.executable
|
||||
configure_build_and_exe('python_libs_custom', 'python setup.py --cxx=g++ --python={}'.format(python_executable))
|
||||
|
||||
|
||||
@skip_on_windows
|
||||
def test_boost_header_only():
|
||||
configure_build_and_exe('boost_header_only', 'python setup.py --cxx=g++')
|
||||
|
||||
|
||||
@skip_on_windows
|
||||
def test_boost_libs():
|
||||
configure_build_and_exe('boost_libs', 'python setup.py --cxx=g++')
|
||||
|
||||
|
||||
@skip_on_windows
|
||||
def test_boost_mpi_libs():
|
||||
configure_build_and_exe('boost_mpi_libs', 'python setup.py --cxx=g++ --mpi')
|
||||
|
||||
|
||||
@skip_on_windows
|
||||
def test_boost_python_libs():
|
||||
configure_build_and_exe('boost_python_libs', 'python setup.py --cxx=g++')
|
||||
|
12
update.py
12
update.py
@ -180,7 +180,7 @@ def gen_setup(config, relative_path):
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def gen_cmakelists(project_name, minimum_cmake_version, relative_path, modules):
|
||||
def gen_cmakelists(project_name, min_cmake_version, relative_path, modules):
|
||||
"""
|
||||
Generate CMakeLists.txt.
|
||||
"""
|
||||
@ -189,7 +189,7 @@ def gen_cmakelists(project_name, minimum_cmake_version, relative_path, modules):
|
||||
s.append(autogenerated_notice())
|
||||
|
||||
s.append('\n# set minimum cmake version')
|
||||
s.append('cmake_minimum_required(VERSION %s FATAL_ERROR)' % minimum_cmake_version)
|
||||
s.append('cmake_minimum_required(VERSION %s FATAL_ERROR)' % min_cmake_version)
|
||||
|
||||
s.append('\n# project name')
|
||||
s.append('project(%s)' % project_name)
|
||||
@ -377,11 +377,11 @@ def main(argv):
|
||||
sys.exit(-1)
|
||||
project_name = config.get('project', 'name')
|
||||
|
||||
if not config.has_option('project', 'minimum_cmake_version'):
|
||||
sys.stderr.write("ERROR: you have to specify the minimum_cmake_version for CMake\n")
|
||||
if not config.has_option('project', 'min_cmake_version'):
|
||||
sys.stderr.write("ERROR: you have to specify the min_cmake_version for CMake\n")
|
||||
sys.stderr.write(" in autocmake.cfg under [project]\n")
|
||||
sys.exit(-1)
|
||||
minimum_cmake_version = config.get('project', 'minimum_cmake_version')
|
||||
min_cmake_version = config.get('project', 'min_cmake_version')
|
||||
|
||||
# get relative path from setup.py script to this directory
|
||||
relative_path = os.path.relpath(os.path.abspath('.'), project_root)
|
||||
@ -391,7 +391,7 @@ def main(argv):
|
||||
|
||||
# create CMakeLists.txt
|
||||
print('- generating CMakeLists.txt')
|
||||
s = gen_cmakelists(project_name, minimum_cmake_version, relative_path, modules)
|
||||
s = gen_cmakelists(project_name, min_cmake_version, relative_path, modules)
|
||||
with open(os.path.join(project_root, 'CMakeLists.txt'), 'w') as f:
|
||||
f.write('%s\n' % '\n'.join(s))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user