find_package(SWIG 1.3.39 REQUIRED) # Broken in cmake 2.4 find_package(SimTK REQUIRED) set(SimTK_PYTHON_REGENERATE_SWIG_INPUT_FILES ON CACHE BOOL "Whether to recreate .i files for SWIG") if(SimTK_PYTHON_REGENERATE_SWIG_INPUT_FILES) # Run Doxygen and xslt to generate an xml file describing the SimTK API set(SimTK_PYTHON_REGENERATE_DOXYGEN_XML ON CACHE BOOL "Whether to recreate xml API data") if(SimTK_PYTHON_REGENERATE_DOXYGEN_XML) set(SIMTK_XML_1 "${CMAKE_CURRENT_BINARY_DIR}/doxygen/SimTK_headers.xml") add_subdirectory(doxygen) # ... or use premade xml file else(SimTK_PYTHON_REGENERATE_DOXYGEN_XML) set(SIMTK_XML_1 "${CMAKE_CURRENT_SOURCE_DIR}/SimTK_headers.xml") endif(SimTK_PYTHON_REGENERATE_DOXYGEN_XML) # Copy SimTK_headers.xml to current directory configure_file("${SIMTK_XML_1}" "${CMAKE_CURRENT_BINARY_DIR}/SimTK_headers.xml" COPYONLY) # Files which will be created by python script and used by swig (dynamically generated) set(SWIG_INPUT_FILES "${CMAKE_CURRENT_BINARY_DIR}/swig_lib/python/pythonprepend.i" "${CMAKE_CURRENT_BINARY_DIR}/swig_lib/python/pythonappend.i" "${CMAKE_CURRENT_BINARY_DIR}/SimTK_docstring.i" "${CMAKE_CURRENT_BINARY_DIR}/SimTK_headers.i" ) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/swigInputConfig.py" "${CMAKE_CURRENT_BINARY_DIR}/swigInputConfig.py" COPYONLY) # Create input files for swig add_custom_command( OUTPUT ${SWIG_INPUT_FILES} COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/swigInputBuilder.py" -i SimTK_headers.xml -c swigInputConfig.py -d SimTK_docstring.i -o SimTK_headers.i -a swig_lib/python/pythonprepend.i -z swig_lib/python/pythonappend.i DEPENDS swigInputBuilder.py "${CMAKE_CURRENT_BINARY_DIR}/swigInputConfig.py" ${PACKAGE_FILES} "${CMAKE_CURRENT_BINARY_DIR}/SimTK_headers.xml" COMMENT "Creating SimTK module swig input files..." ) add_custom_target(SwigInputFiles ALL DEPENDS ${SWIG_INPUT_FILES}) endif(SimTK_PYTHON_REGENERATE_SWIG_INPUT_FILES) # Run swig add_custom_command( OUTPUT "${PY_STAGING_DIR}/src/SimTKSwig.cxx" "${PY_STAGING_DIR}/simtk/simtk.py" COMMAND ${SWIG_EXECUTABLE} -python -c++ -outdir "${PY_STAGING_DIR}/simtk/chem" -o "${PY_STAGING_DIR}/src/SimTKSwig.cxx" "${CMAKE_CURRENT_SOURCE_DIR}/SimTK.i" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/SimTK.i" ${PACKAGE_FILES} ${SWIG_INPUT_FILES} COMMENT "Creating PySimTK reference platform module sources with swig..." ) add_custom_target(PysimtkPackage ALL DEPENDS "${PY_STAGING_DIR}/src/SimTKSwig.cxx" ${PACKAGE_FILES} )