summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2012-04-09 18:09:07 (GMT)
committerChristian Mollekopf <chrigi_1@fastmail.fm>2012-04-09 18:09:07 (GMT)
commite10e31aa721a5336f4d1c3f6598d18dd7f3b9cc5 (patch)
tree07e65071ddb5d1ff7a713440068fb5de20c094a1
parenta66401cf13a72caf6ee5a256f614f2ee96bc593c (diff)
downloadlibkolabxml-e10e31aa721a5336f4d1c3f6598d18dd7f3b9cc5.tar.gz
fixed python building, use the functions provided by FindPythonLibs.cmake
-rw-r--r--src/python/CMakeLists.txt56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt
index ac5deed..4ef88db 100644
--- a/src/python/CMakeLists.txt
+++ b/src/python/CMakeLists.txt
@@ -1,9 +1,19 @@
# Generate Python wrapper
include_directories(../)
-set(KOLAB_SWIG_PYTHON_SOURCE_FILE python_kolabformat_wrapper.cpp)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PYTHON_SOURCE_FILE}
- COMMAND ${SWIG} -v -c++ -python -o ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PYTHON_SOURCE_FILE} ../kolabformat.i
+# Compile Python Bindings
+find_package(PythonLibs)
+
+if (NOT PYTHONLIBS_FOUND)
+ message("python libs not found, not building python bindings")
+ return()
+endif()
+
+set(KOLAB_SWIG_PYTHON_SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/python_kolabformat_wrapper.cpp)
+set(KOLAB_SWIG_PYTHON_HEADER_FILE ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.py)
+
+add_custom_command(OUTPUT ${KOLAB_SWIG_PYTHON_SOURCE_FILE} ${KOLAB_SWIG_PYTHON_HEADER_FILE}
+ COMMAND ${SWIG} -v -c++ -python -o ${KOLAB_SWIG_PYTHON_SOURCE_FILE} ../kolabformat.i
COMMENT "Generating python bindings"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ../kolabformat.i kolabxml
@@ -11,33 +21,23 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PYTHON_SOURCE
)
SET_SOURCE_FILES_PROPERTIES(${KOLAB_SWIG_PYTHON_SOURCE_FILE} PROPERTIES GENERATED 1)
-ADD_CUSTOM_TARGET(generate_python_bindings ALL DEPENDS ${KOLAB_SWIG_PYTHON_SOURCE_FILE})
-# Compile Python Bindings
-find_package(PythonLibs)
-
-if (PythonLibs_FOUND)
- include_directories(${PYTHON_INCLUDE_DIRS})
-
- # python_add_module(kolabformat ${KOLAB_SWIG_PYTHON_SOURCE_FILE})
+include_directories(${PYTHON_INCLUDE_DIRS})
- add_library(pythonbindings SHARED ${KOLAB_SWIG_PYTHON_SOURCE_FILE})
- target_link_libraries(pythonbindings kolabxml ${PYTHON_LIBRARY})
- SET_TARGET_PROPERTIES(pythonbindings PROPERTIES OUTPUT_NAME "_kolabformat")
- SET_TARGET_PROPERTIES(pythonbindings PROPERTIES PREFIX "")
+set(PYTHON_MODULE_PREFIX "_")
+python_add_module(kolabformat ${KOLAB_SWIG_PYTHON_SOURCE_FILE})
+target_link_libraries(kolabformat kolabxml ${PYTHON_LIBRARIES})
+configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
- configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+if (KOLAB_PYTHON_INSTALL_DIR)
+ set(PYTHON_INSTALL_DIR ${KOLAB_PYTHON_INSTALL_DIR})
+else (KOLAB_PYTHON_INSTALL_DIR)
+ set(PYTHON_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythonbindings)
+endif (KOLAB_PYTHON_INSTALL_DIR)
- if (KOLAB_PYTHON_INSTALL_DIR)
- set(PYTHON_INSTALL_DIR ${KOLAB_PYTHON_INSTALL_DIR})
- else (KOLAB_PYTHON_INSTALL_DIR)
- set(PYTHON_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythonbindings)
- endif (KOLAB_PYTHON_INSTALL_DIR)
+install(TARGETS kolabformat LIBRARY DESTINATION ${PYTHON_INSTALL_DIR})
- install(TARGETS pythonbindings LIBRARY DESTINATION ${PYTHON_INSTALL_DIR})
-
- install( FILES
- ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.py
- DESTINATION ${PYTHON_INSTALL_DIR}
- )
-endif (PythonLibs_FOUND)
+install( FILES
+ ${KOLAB_SWIG_PYTHON_HEADER_FILE}
+ DESTINATION ${PYTHON_INSTALL_DIR}
+ )