From: Diane Trout Date: Tue, 5 Dec 2006 02:22:00 +0000 (+0000) Subject: directly build the python extension modules X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=commitdiff_plain;h=7c3bf26770d10c90e1b40c60479114f42a84edf0 directly build the python extension modules I learned about SET_TARGET_PROPERTIES( ... PREFIX ) to change the starting prefix for a library, which means that I don't need to copy the libX.so to X.so to make something a python importable module. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 51249ce..a5888b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ IF(USE_PYTHON) TARGET_LINK_LIBRARIES(mussagl mussa_py ${QT_LIBRARIES} - mussa_qui_py + mussaqui_py ${BOOST_PYTHON_LIBRARY} ${PYTHON_LIBRARIES} ${PYTHON_LINK_LIBRARIES}) diff --git a/py/CMakeLists.txt b/py/CMakeLists.txt index 869faad..a2466f9 100644 --- a/py/CMakeLists.txt +++ b/py/CMakeLists.txt @@ -24,40 +24,56 @@ IF(BOOST_PYTHON_LIBRARY) SET(QUI_SOURCES module_qui.cpp MussaWindow.cpp - ) - ADD_LIBRARY(mussa MODULE ${SOURCES}) + ) + SET(MUSSA_LIBRARIES + mussa_core + ${BOOST_PYTHON_LIBRARY} + ${BOOST_FILESYSTEM_LIBRARY} + ${BOOST_SERIALIZATION_LIBRARY} + ${OPENGL_gl_LIBRARY} + ${PYTHON_LIBRARIES} + optimized ${QT_QTCORE_LIBRARY} + debug ${QT_QTCORE_LIBRARY_DEBUG} + ) + SET(STATIC_PYTHON_TARGETS "") + SET(SHARED_PYTHON_TARGETS "") + ADD_LIBRARY(mussa_py STATIC ${SOURCES}) - ADD_LIBRARY(mussa_qui_py STATIC ${QUI_SOURCES}) - # Any suggestions for a more elegant solution to this? -diane - IF(WIN32) - ADD_CUSTOM_TARGET(mussa.dll ALL - COMMAND copy libmussa.dll mussa.dll - DEPENDS mussa) - ELSE(WIN32) - # Not win32, aka linux and mac - ADD_CUSTOM_TARGET(mussa.so ALL - COMMAND cp libmussa.so mussa.so - DEPENDS mussa) - ENDIF(WIN32) - TARGET_LINK_LIBRARIES(mussa - mussa_core - ${BOOST_PYTHON_LIBRARY} - ${BOOST_FILESYSTEM_LIBRARY} - ${BOOST_SERIALIZATION_LIBRARY} - ${OPENGL_gl_LIBRARY} - ${PYTHON_LIBRARIES} - optimized ${QT_QTCORE_LIBRARY} - debug ${QT_QTCORE_LIBRARY_DEBUG} + SET(${STATIC_PYTHON_TARGETS} "${${STATIC_PYTHON_TARGETS}} mussa_py") + ADD_LIBRARY(mussa MODULE ${SOURCES}) + SET(${SHARED_PYTHON_TARGETS} "${${SHARED_PYTHON_TARGETS}} mussa") + TARGET_LINK_LIBRARIES(mussa + ${MUSSA_LIBRARIES} ) + ADD_LIBRARY(mussaqui_py STATIC ${QUI_SOURCES}) + SET(${STATIC_PYTHON_TARGETS} "${${STATIC_PYTHON_TARGETS}} mussaqui_py") + # ADD_LIBRARY(mussaqui MODULE ${QUI_SOURCES}) + # SET(${SHARED_PYTHON_TARGETS} "${${SHARED_PYTHON_TARGETS}} mussaqui") + #TARGET_LINK_LIBRARIES(mussaqui + # mussa_qui + # ${MUSSA_LIBRARIES} + # optimized ${QT_QTGUI_LIBRARY} + # debug ${QT_QTGUI_LIBRARY_DEBUG} + # optimized ${QT_QTOPENGL_LIBRARY} + # debug ${QT_QTOPENGL_LIBRARY_DEBUG} + # ) + + # don't put the "lib" prefix infront of our shared modules + SET_TARGET_PROPERTIES(${SHARED_PYTHON_TARGETS} + PROPERTIES + PREFIX "" + ) GET_MUSSA_COMPILE_FLAGS(PY_CFLAGS) GET_MUSSA_LINK_FLAGS(PY_LDFLAGS) SET_SOURCE_FILES_PROPERTIES( ${SOURCES} + ${QUI_SOURCES} PROPERTIES COMPILE_FLAGS "${PY_CFLAGS}" ) SET_TARGET_PROPERTIES( - mussa mussa_py mussa_qui_py PROPERTIES + ${STATIC_PYTHON_TARGETS} ${SHARED_PYTHON_TARGETS} + PROPERTIES COMPILE_FLAGS "${PY_CFLAGS}" LINK_FLAGS "${PY_LDFLAGS}" ) diff --git a/py/test/CMakeLists.txt b/py/test/CMakeLists.txt index f797b0b..9c5e00b 100644 --- a/py/test/CMakeLists.txt +++ b/py/test/CMakeLists.txt @@ -22,7 +22,7 @@ TARGET_LINK_LIBRARIES(mussa_python_test mussa_py mussa_core ${QT_QTCORE_LIBRARY} - mussa_qui_py + mussaqui_py ${OPENGL_gl_LIBRARY} ${BOOST_PROGRAM_OPTIONS_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY}