Added module for Boost detection and automatic build-up
This commit is contained in:
committed by
Roberto Di Remigio
parent
ea694c0bdd
commit
1780e4a189
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;
|
||||
}
|
Reference in New Issue
Block a user