summaryrefslogtreecommitdiff
path: root/python/gras
diff options
context:
space:
mode:
authorJosh Blum2013-07-07 23:05:56 -0700
committerJosh Blum2013-07-07 23:05:56 -0700
commit07070a8000400ced8dc8ff612c82c418df73f7ef (patch)
treef6ae3606449b44e6518a8f858886cf62cbeaf539 /python/gras
parentd4d411ba6103f3075b7270d741bc5df406714d54 (diff)
downloadsandhi-07070a8000400ced8dc8ff612c82c418df73f7ef.tar.gz
sandhi-07070a8000400ced8dc8ff612c82c418df73f7ef.tar.bz2
sandhi-07070a8000400ced8dc8ff612c82c418df73f7ef.zip
gras: swap out GrSwig for stock cmake swig usage
Diffstat (limited to 'python/gras')
-rw-r--r--python/gras/CMakeLists.txt88
1 files changed, 59 insertions, 29 deletions
diff --git a/python/gras/CMakeLists.txt b/python/gras/CMakeLists.txt
index 273e06d..7d5b9bd 100644
--- a/python/gras/CMakeLists.txt
+++ b/python/gras/CMakeLists.txt
@@ -2,35 +2,41 @@
# Include swig generation macros
########################################################################
find_package(SWIG)
+if(NOT SWIG_FOUND)
+ return()
+endif()
+
find_package(PythonLibs)
-if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND)
+if(NOT PYTHONLIBS_FOUND)
return()
endif()
-include(GrSwig)
+
+include(UseSWIG)
include(GrPython)
-find_package(Boost) #for headers
-
-########################################################################
-# setup SWIG build
-########################################################################
-list(APPEND GR_SWIG_INCLUDE_DIRS ${GRAS_INCLUDE_DIRS})
-list(APPEND GR_SWIG_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
-set(GR_SWIG_LIBRARIES gras)
-file(GLOB GR_SWIG_SOURCE_DEPS "${GRAS_SOURCE_DIR}/include/gras/*.i")
-
-GR_SWIG_MAKE(GRAS_Tags GRAS_Tags.i)
-GR_SWIG_MAKE(GRAS_TimeTag GRAS_TimeTag.i)
-GR_SWIG_MAKE(GRAS_Factory GRAS_Factory.i)
-GR_SWIG_MAKE(GRAS_Element GRAS_Element.i)
-GR_SWIG_MAKE(GRAS_Block GRAS_Block.i)
-GR_SWIG_MAKE(GRAS_HierBlock GRAS_HierBlock.i)
-GR_SWIG_MAKE(GRAS_TopBlock GRAS_TopBlock.i)
-GR_SWIG_MAKE(GRAS_PyBlock GRAS_PyBlock.i)
-GR_SWIG_MAKE(GRAS_PyHierBlocks GRAS_PyHierBlocks.i)
-GR_SWIG_MAKE(GRAS_ThreadPool GRAS_ThreadPool.i)
-GR_SWIG_MAKE(GRAS_SBuffer GRAS_SBuffer.i)
-GR_SWIG_INSTALL(
- TARGETS
+
+########################################################################
+# Local includes
+########################################################################
+list(APPEND CMAKE_SWIG_INC_FLAGS "-I${PMC_SOURCE_DIR}/include")
+list(APPEND CMAKE_SWIG_INC_FLAGS "-I${GRAS_SOURCE_DIR}/include")
+include_directories(${GRAS_INCLUDE_DIRS})
+
+########################################################################
+# Python library setup
+########################################################################
+include_directories(${PYTHON_INCLUDE_PATH})
+include_directories(${PYTHON_INCLUDE_DIRS})
+
+########################################################################
+# Finding Boost headers
+########################################################################
+find_package(Boost)
+include_directories(${Boost_INCLUDE_DIRS})
+
+########################################################################
+# swig build modules
+########################################################################
+set(gras_swig_modules
GRAS_Tags
GRAS_TimeTag
GRAS_Element
@@ -42,14 +48,38 @@ GR_SWIG_INSTALL(
GRAS_TopBlock
GRAS_ThreadPool
GRAS_SBuffer
- DESTINATION ${GR_PYTHON_DIR}/gras
- COMPONENT ${GRAS_COMP_PYTHON}
)
+file(GLOB pmc_i_files "${PMC_SOURCE_DIR}/include/PMC/*.i")
+file(GLOB gras_i_files "${GRAS_SOURCE_DIR}/include/gras/*.i")
+
+foreach(gras_swig_module ${gras_swig_modules})
+ message(STATUS "Configuring swig python module ${gras_swig_module}...")
+
+ #set the C++ property on the swig .i file so it builds
+ set_source_files_properties(${gras_swig_module}.i PROPERTIES CPLUSPLUS ON)
+
+ set(CMAKE_SWIG_FLAGS -fvirtual -module ${gras_swig_module} ${CMAKE_SWIG_INC_FLAGS})
+ set(SWIG_MODULE_${gras_swig_module}_EXTRA_DEPS ${pmc_i_files} ${gras_i_files})
+ SWIG_ADD_MODULE(${gras_swig_module} python ${gras_swig_module}.i)
+ SWIG_LINK_LIBRARIES(${gras_swig_module} ${GRAS_LIBRARIES} ${PYTHON_LIBRARIES})
+
+ install(
+ TARGETS ${SWIG_MODULE_${gras_swig_module}_REAL_NAME}
+ DESTINATION ${GR_PYTHON_DIR}/gras
+ COMPONENT ${GRAS_COMP_PYTHON}
+ )
+ install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/${gras_swig_module}.py
+ DESTINATION ${GR_PYTHON_DIR}/gras
+ COMPONENT ${GRAS_COMP_PYTHON}
+ )
+endforeach(gras_swig_module)
+
########################################################################
-# Install rules
+# install other python files
########################################################################
-GR_PYTHON_INSTALL(
+INSTALL(
FILES __init__.py GRAS_Utils.py
DESTINATION ${GR_PYTHON_DIR}/gras
COMPONENT ${GRAS_COMP_PYTHON}