Boost logo

Boost-Commit :

From: dgregor_at_[hidden]
Date: 2007-06-06 08:38:44


Author: dgregor
Date: 2007-06-06 08:38:43 EDT (Wed, 06 Jun 2007)
New Revision: 4471
URL: http://svn.boost.org/trac/boost/changeset/4471

Log:
Very basic building of Python modules, with testing of a single module that doesn't quite work...

Text files modified:
   sandbox-branches/boost-cmake/boost_1_34_0/libs/python/CMakeLists.txt | 20 ++++++++++++++++++++
   sandbox-branches/boost-cmake/boost_1_34_0/libs/python/test/CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++++++++-
   2 files changed, 59 insertions(+), 1 deletions(-)

Modified: sandbox-branches/boost-cmake/boost_1_34_0/libs/python/CMakeLists.txt
==============================================================================
--- sandbox-branches/boost-cmake/boost_1_34_0/libs/python/CMakeLists.txt (original)
+++ sandbox-branches/boost-cmake/boost_1_34_0/libs/python/CMakeLists.txt 2007-06-06 08:38:43 EDT (Wed, 06 Jun 2007)
@@ -3,6 +3,26 @@
 
 if (PYTHON_LIBRARIES)
   include_directories(${PYTHON_INCLUDE_PATH})
+
+ macro(boost_python_extension MODULE_NAME)
+ parse_arguments(BPL_EXT
+ ""
+ ""
+ ${ARGN})
+
+ # Create the library target itself
+ add_library(${MODULE_NAME} MODULE ${BPL_EXT_DEFAULT_ARGS} )
+
+ # Miscellaneous target properties
+ set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
+
+ # Link against Boost.Python library
+ target_link_libraries(${MODULE_NAME} boost_python-shared)
+
+ # Link against Python libraries
+ target_link_libraries(${MODULE_NAME} ${PYTHON_LIBRARIES})
+ endmacro(boost_python_extension)
+
   boost_library_project(
     Python
     SRCDIRS src

Modified: sandbox-branches/boost-cmake/boost_1_34_0/libs/python/test/CMakeLists.txt
==============================================================================
--- sandbox-branches/boost-cmake/boost_1_34_0/libs/python/test/CMakeLists.txt (original)
+++ sandbox-branches/boost-cmake/boost_1_34_0/libs/python/test/CMakeLists.txt 2007-06-06 08:38:43 EDT (Wed, 06 Jun 2007)
@@ -1,3 +1,27 @@
+macro(bpl_test TESTNAME)
+ parse_arguments(BPL_TEST
+ "ARGS"
+ ""
+ ${ARGN})
+
+ # Determine the Python and C++ source files for this test
+ if (BPL_TEST_DEFAULT_ARGS)
+ car(BPL_TEST_PYSOURCE ${BPL_TEST_DEFAULT_ARGS})
+ cdr(BPL_TEST_SOURCES ${BPL_TEST_DEFAULT_ARGS})
+ else (BPL_TEST_DEFAULT_ARGS)
+ set(BPL_TEST_PYSOURCE "${TESTNAME}.py")
+ set(BPL_TEST_SOURCES "${TESTNAME}.cpp")
+ endif(BPL_TEST_DEFAULT_ARGS)
+ set(BPL_TEST_PYSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/${BPL_TEST_PYSOURCE})
+
+ # Build the Python extension module we need
+ boost_python_extension(${TESTNAME}_ext ${BPL_TEST_SOURCES})
+
+ # Run the test itself
+ add_test("${PROJECT_NAME}::${TESTNAME}"
+ ${PYTHON_EXECUTABLE} ${BPL_TEST_PYSOURCE} ${BPL_TEST_ARGS})
+endmacro(bpl_test)
+
 boost_test_run(exec
   DEPENDS boost_python-static
   ARGS "${CMAKE_CURRENT_SOURCE_DIR}/exec.py"
@@ -6,4 +30,18 @@
   SOURCES exec.cpp
   ARGS "${CMAKE_CURRENT_SOURCE_DIR}/exec.py"
   DEPENDS boost_python-shared
- LINK_LIBS ${PYTHON_LIBRARIES})
\ No newline at end of file
+ LINK_LIBS ${PYTHON_LIBRARIES})
+
+# Setup the paths we need to run Python tests
+file(TO_NATIVE_PATH ${LIBRARY_OUTPUT_PATH} PYTHONPATH)
+message(STATUS ${PYTHONPATH})
+set(ENV{PYTHONPATH} "${PYTHONPATH}")
+set(CTEST_ENVIRONMENT "PYTHONPATH=${PYTHONPATH}")
+
+#[
+#bpl-test crossmod_exception
+# : crossmod_exception.py crossmod_exception_a.cpp crossmod_exception_b.cpp
+#]
+
+
+bpl_test(injected)
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk