Streamline Boost tests for compiled libraries and add documentation on Boost module usage
This commit is contained in:
parent
cff0797b7b
commit
ae87734faf
@ -1,7 +1,7 @@
|
|||||||
#.rst:
|
#.rst:
|
||||||
#
|
#
|
||||||
# Detect, build, and link Boost libraries.
|
# Detect, build, and link Boost libraries.
|
||||||
# This modules downloads the .zip archive from SourceForge
|
# This modules downloads the .zip archive from SourceForge at
|
||||||
# Autocmake update time.
|
# Autocmake update time.
|
||||||
#
|
#
|
||||||
# Your autocmake.cfg should look like this::
|
# Your autocmake.cfg should look like this::
|
||||||
@ -13,6 +13,19 @@
|
|||||||
# Cross-dependencies between required components are not checked for.
|
# Cross-dependencies between required components are not checked for.
|
||||||
# For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you
|
# For example, Boost.Timer depends on Boost.Chrono and Boost.System thus you
|
||||||
# should ask explicitly for all three.
|
# should ask explicitly for all three.
|
||||||
|
# If the self-build of Boost components is triggered the `BUILD_CUSTOM_BOOST` variable is set
|
||||||
|
# to `TRUE`. The CMake target `custom_boost` is also added.
|
||||||
|
# You should use these two to ensure the right dependencies between your targets
|
||||||
|
# and the Boost headers/libraries, in case the self-build is triggered.
|
||||||
|
# For example::
|
||||||
|
#
|
||||||
|
# if(BUILD_CUSTOM_BOOST)
|
||||||
|
# add_dependencies(your_target custom_boost)
|
||||||
|
# endif()
|
||||||
|
#
|
||||||
|
# will ensure that `your_target` is built after `custom_boost` if and only if the self-build
|
||||||
|
# of Boost took place. This is an important step to avoid race conditions when building
|
||||||
|
# on multiple processes.
|
||||||
#
|
#
|
||||||
# Dependencies::
|
# Dependencies::
|
||||||
#
|
#
|
||||||
@ -27,6 +40,7 @@
|
|||||||
# PROJECT_BINARY_DIR
|
# PROJECT_BINARY_DIR
|
||||||
# CMAKE_BUILD_TYPE
|
# CMAKE_BUILD_TYPE
|
||||||
# MPI_FOUND
|
# MPI_FOUND
|
||||||
|
# BUILD_CUSTOM_BOOST
|
||||||
#
|
#
|
||||||
# autocmake.cfg configuration::
|
# autocmake.cfg configuration::
|
||||||
#
|
#
|
||||||
|
@ -5,8 +5,17 @@ min_cmake_version: 2.8
|
|||||||
[cxx]
|
[cxx]
|
||||||
source: ../../../modules/cxx.cmake
|
source: ../../../modules/cxx.cmake
|
||||||
|
|
||||||
|
[mpi]
|
||||||
|
source: ../../../modules/mpi.cmake
|
||||||
|
|
||||||
|
[python_interpreter]
|
||||||
|
source: ../../../modules/python_interpreter.cmake
|
||||||
|
|
||||||
|
[python_libs]
|
||||||
|
source: ../../../modules/python_libs.cmake
|
||||||
|
|
||||||
[boost]
|
[boost]
|
||||||
override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'chrono;timer;system'}
|
override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'mpi;serialization;python'}
|
||||||
source: ../../../modules/boost/boost.cmake
|
source: ../../../modules/boost/boost.cmake
|
||||||
|
|
||||||
[default_build_paths]
|
[default_build_paths]
|
||||||
|
@ -4,10 +4,5 @@ if(BUILD_CUSTOM_BOOST)
|
|||||||
add_dependencies(example custom_boost)
|
add_dependencies(example custom_boost)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(_libs ${Boost_TIMER_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_SYSTEM_LIBRARY})
|
target_link_libraries(example ${Boost_MPI_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} ${MPI_CXX_LIBRARIES}
|
||||||
|
${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES})
|
||||||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
||||||
set(_libs ${_libs} rt)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(example ${_libs})
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
#include <cmath>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
#include <boost/timer/timer.hpp>
|
#include <boost/mpi/environment.hpp>
|
||||||
|
#include <boost/mpi/communicator.hpp>
|
||||||
|
#include <boost/python.hpp>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
boost::timer::auto_cpu_timer t;
|
using namespace boost::python;
|
||||||
|
namespace mpi = boost::mpi;
|
||||||
|
|
||||||
std::cout << "Boost version: "
|
std::cout << "Boost version: "
|
||||||
<< BOOST_VERSION / 100000
|
<< BOOST_VERSION / 100000
|
||||||
@ -17,10 +18,26 @@ int main()
|
|||||||
<< BOOST_VERSION % 100
|
<< BOOST_VERSION % 100
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Py_Initialize();
|
||||||
|
|
||||||
std::cout << "Measuring some timings..." << std::endl;
|
object main_module((
|
||||||
for (long i = 0; i < 100000000; ++i)
|
handle<>(borrowed(PyImport_AddModule("__main__")))));
|
||||||
std::sqrt(123.456L); // burn some time
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
mpi::environment env;
|
||||||
|
mpi::communicator world;
|
||||||
|
std::cout << "I am process " << world.rank() << " of " << world.size()
|
||||||
|
<< "." << std::endl;
|
||||||
|
|
||||||
std::cout << "PASSED" << std::endl;
|
std::cout << "PASSED" << std::endl;
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
[project]
|
|
||||||
name: example
|
|
||||||
min_cmake_version: 2.8
|
|
||||||
|
|
||||||
[cxx]
|
|
||||||
source: ../../../modules/cxx.cmake
|
|
||||||
|
|
||||||
[mpi]
|
|
||||||
source: ../../../modules/mpi.cmake
|
|
||||||
|
|
||||||
[boost]
|
|
||||||
override: {'major': 1, 'minor': 59, 'patch': 0, 'components': 'mpi;serialization'}
|
|
||||||
source: ../../../modules/boost/boost.cmake
|
|
||||||
|
|
||||||
[default_build_paths]
|
|
||||||
source: ../../../modules/default_build_paths.cmake
|
|
||||||
|
|
||||||
[src]
|
|
||||||
source: ../../../modules/src.cmake
|
|
@ -1,7 +0,0 @@
|
|||||||
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})
|
|
@ -1,26 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
[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
|
|
||||||
|
|
||||||
[boost]
|
|
||||||
override: {'major': 1, 'minor': 56, 'patch': 0, 'components': 'python'}
|
|
||||||
source: ../../../modules/boost/boost.cmake
|
|
||||||
|
|
||||||
[default_build_paths]
|
|
||||||
source: ../../../modules/default_build_paths.cmake
|
|
||||||
|
|
||||||
[src]
|
|
||||||
source: ../../../modules/src.cmake
|
|
@ -1,7 +0,0 @@
|
|||||||
add_executable(example example.cpp)
|
|
||||||
|
|
||||||
if(BUILD_CUSTOM_BOOST)
|
|
||||||
add_dependencies(example custom_boost)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(example ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES})
|
|
@ -1,38 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
10
test/test.py
10
test/test.py
@ -175,12 +175,4 @@ def test_boost_header_only():
|
|||||||
|
|
||||||
|
|
||||||
def test_boost_libs():
|
def test_boost_libs():
|
||||||
configure_build_and_exe('boost_libs', 'python setup --cxx=g++')
|
configure_build_and_exe('boost_libs', 'python setup --cxx=g++ --mpi')
|
||||||
|
|
||||||
|
|
||||||
def test_boost_mpi_libs():
|
|
||||||
configure_build_and_exe('boost_mpi_libs', 'python setup --cxx=g++ --mpi')
|
|
||||||
|
|
||||||
|
|
||||||
def test_boost_python_libs():
|
|
||||||
configure_build_and_exe('boost_python_libs', 'python setup --cxx=g++')
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user