Added new CMake macro add_python_module() and some cleanup.

This commit is contained in:
Jean-Paul Chaput 2015-03-22 19:12:45 +01:00
parent 69c75b9ea9
commit 1e73466199
15 changed files with 753 additions and 711 deletions

View File

@ -316,3 +316,53 @@
set(${project}_FOUND FALSE)
endif(${project}_INCLUDE_DIR AND ${project}_LIBRARY)
endmacro(set_found project)
#
# Build a Python extention module.
# Usage:
# * clibSpec: The C/C++ shared part of the Python module.
# A four three list CLIB_NAME;version;soversion;
# - CLIB_NAME: the name of the C/C++ shared library
# - version: the full version number (ex: 1.0).
# - soversion: the shared version major (ex: 1).
# If the C library must not be generated because it is
# already included in another one, set to IGNORE.
# * pymodule: The name of the Python module (for "import PYMODULE").
# * deplibs: The list of dependencies.
#
macro( add_python_module pyCpps pyIncludes argClibSpec pymodule deplibs inc_install_dir )
set( pyDeplibs ${deplibs} )
# Force the argument <argClibSpec> to be parsed as a list.
set( clibSpec ${argClibSpec} )
list( GET clibSpec 0 clib )
message( STATUS ${clib} )
if( NOT (${clib} STREQUAL "Do_not_generate_C_library") )
list( LENGTH clibSpec clibLen )
if( NOT (clibLen EQUAL 3) )
message( FATAL_ERROR "python_module(): clibSpec doesnt't have exactly 3 elements (${clibSpec})." )
endif()
list( GET clibSpec 1 version )
list( GET clibSpec 2 soversion )
set( pyDeplibs ${clib} ${deplibs} )
add_library( ${clib} ${pyCpps} )
set_target_properties( ${clib} PROPERTIES VERSION ${version} SOVERSION ${soversion} )
target_link_libraries( ${clib} ${deplibs} )
install( TARGETS ${clib} DESTINATION lib${LIB_SUFFIX} )
endif()
set( pytarget "${pymodule}_target" )
add_library( ${pytarget} MODULE ${pyCpps} )
set_target_properties( ${pytarget} PROPERTIES
COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
PREFIX ""
OUTPUT_NAME ${pymodule}
)
target_link_libraries( ${pytarget} ${pyDeplibs} )
install( TARGETS ${pytarget} DESTINATION ${PYTHON_SITE_PACKAGES} )
install( FILES ${pyIncludes} DESTINATION ${inc_install_dir} )
endmacro( add_python_module )

View File

@ -26,7 +26,7 @@
-DPYTHON_SITE_PACKAGES="${PYTHON_SITE_PACKAGES}"
)
set ( sources PyCRL.cpp
set( pyCpps PyCRL.cpp
PyBanner.cpp
PyCatalog.cpp
PyCatalogState.cpp
@ -42,7 +42,7 @@
PyAcmSigda.cpp
PyIspd05.cpp
)
set ( includes crlcore/PyBanner.h
set( pyIncludes crlcore/PyBanner.h
crlcore/PyCatalog.h
crlcore/PyCatalogState.h
crlcore/PyEnvironment.h
@ -57,20 +57,16 @@
crlcore/PyAcmSigda.h
crlcore/PyIspd05.h
)
add_library ( pycrlcore ${sources} )
set_target_properties ( pycrlcore PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries ( pycrlcore crlcore
set( depLibs crlcore
${HURRICANE_PYTHON_LIBRARIES}
${PYTHON_LIBRARIES} -lutil
)
add_library ( CRL MODULE ${sources} )
target_link_libraries ( CRL pycrlcore )
set_target_properties ( CRL PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
PREFIX ""
${PYTHON_LIBRARIES}
-lutil
)
install ( FILES ${includes} DESTINATION include/coriolis2/crlcore )
install ( TARGETS pycrlcore DESTINATION lib${LIB_SUFFIX} )
install ( TARGETS CRL DESTINATION ${PYTHON_SITE_PACKAGES} )
add_python_module( "${pyCpps}"
"${pyIncludes}"
"pycrlcore;1.0;1"
CRL
"${depLibs}"
include/coriolis2/crlcore
)

View File

@ -1,7 +1,6 @@
# -*- explicit-buffer-name: "CMakeLists.txt<etesian/src>" -*-
# include( ${QT_USE_FILE} )
include_directories( ${ETESIAN_SOURCE_DIR}/src
${COLOQUINTE_INCLUDE_DIR}
${CORIOLIS_INCLUDE_DIR}
@ -31,10 +30,8 @@
PyGraphicEtesianEngine.cpp
)
qtX_wrap_cpp( mocCpps ${mocIncludes} )
add_library ( etesian ${cpps} ${mocCpps} ${pyCpps} )
set_target_properties ( etesian PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries ( etesian ${CORIOLIS_LIBRARIES}
set( depLibs ${CORIOLIS_PYTHON_LIBRARIES}
${CORIOLIS_LIBRARIES}
${HURRICANE_PYTHON_LIBRARIES}
${HURRICANE_GRAPHICAL_LIBRARIES}
${HURRICANE_LIBRARIES}
@ -53,22 +50,19 @@
${LIBEXECINFO_LIBRARIES}
)
add_library ( pyEtesian MODULE ${pyCpps} )
set_target_properties ( pyEtesian PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
PREFIX ""
OUTPUT_NAME "Etesian"
)
target_link_libraries ( pyEtesian etesian
${CORIOLIS_PYTHON_LIBRARIES}
add_library( etesian ${cpps} ${mocCpps} ${pyCpps} )
set_target_properties( etesian PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries( etesian ${depLibs} )
# add_executable ( etesian.bin ${etesiancpps} )
#target_link_libraries ( etesian.bin etesian )
add_python_module( "${pyCpps}"
"${pyIncludes}"
"Do_not_generate_C_library"
Etesian
"etesian;${depLibs}"
include/coriolis2/etesian
)
install( TARGETS etesian DESTINATION lib${LIB_SUFFIX} )
# install ( TARGETS etesian.bin DESTINATION bin )
install ( TARGETS pyEtesian DESTINATION ${PYTHON_SITE_PACKAGES} )
install( FILES ${includes}
${mocIncludes}
${pyIncludes} DESTINATION include/coriolis2/etesian )
${mocIncludes} DESTINATION include/coriolis2/etesian )

View File

@ -1,13 +1,12 @@
# -*- mode: CMAKE explicit-buffer-name: "CMakeLists.txt<hurricane/src/isobar>" -*-
# include( ${QT_USE_FILE} )
include_directories( ${HURRICANE_SOURCE_DIR}/src/hurricane
${HURRICANE_SOURCE_DIR}/src/viewer
${HURRICANE_SOURCE_DIR}/src/isobar
${PYTHON_INCLUDE_PATH}
)
set ( sources ProxyProperty.cpp
set( pyCpps ProxyProperty.cpp
PyBreakpoint.cpp
PyInterval.cpp
PyBox.cpp
@ -71,7 +70,7 @@
PyQueryMask.cpp
PyQuery.cpp
)
set ( includes hurricane/isobar/ProxyProperty.h
set( pyIncludes hurricane/isobar/ProxyProperty.h
hurricane/isobar/PyBreakpoint.h
hurricane/isobar/PyInterval.h
hurricane/isobar/PyBox.h
@ -136,16 +135,15 @@
hurricane/isobar/PyQuery.h
)
add_library ( isobar ${sources} )
set_target_properties ( isobar PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries ( isobar hurricane ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
add_library ( Hurricane MODULE ${sources} )
set_target_properties ( Hurricane PROPERTIES
COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
PREFIX ""
set( depLibs hurricane
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)
add_python_module( "${pyCpps}"
"${pyIncludes}"
"isobar;1.0;1"
Hurricane
"${depLibs}"
include/coriolis2/hurricane/isobar
)
target_link_libraries ( Hurricane isobar )
install ( TARGETS isobar DESTINATION lib${LIB_SUFFIX} )
install ( TARGETS Hurricane DESTINATION ${PYTHON_SITE_PACKAGES} )
install ( FILES ${includes} DESTINATION include/coriolis2/hurricane/isobar )

View File

@ -11,7 +11,7 @@
${PYTHON_INCLUDE_PATH}
)
set ( mocincludes hurricane/viewer/HApplication.h
set( mocIncludes hurricane/viewer/HApplication.h
hurricane/viewer/PaletteItem.h
hurricane/viewer/PaletteNamedItem.h
hurricane/viewer/PaletteLayerItem.h
@ -56,13 +56,14 @@
hurricane/viewer/SelectorCriterion.h
hurricane/viewer/CellWidgets.h
)
set ( pyincludes hurricane/viewer/PyHSVr.h
set( pyIncludes hurricane/viewer/PyHSVr.h
hurricane/viewer/PyDrawingStyle.h
hurricane/viewer/PyDrawingGroup.h
hurricane/viewer/PyDisplayStyle.h
hurricane/viewer/PyHApplication.h
hurricane/viewer/PyGraphics.h
hurricane/viewer/PyCellViewer.h
hurricane/viewer/Script.h
)
set( cpps HApplication.cpp
ScreenUtilities.cpp
@ -107,7 +108,7 @@
ControllerWidget.cpp
ScriptWidget.cpp
)
set ( pycpps PyHSVr.cpp
set( pyCpps PyHSVr.cpp
PyDrawingStyle.cpp
PyDrawingGroup.cpp
PyDisplayStyle.cpp
@ -115,18 +116,13 @@
PyGraphics.cpp
PyViewer.cpp
PyCellViewer.cpp
Script.cpp
)
# source2 & include2 for module that are *not* Python wrappers but true
# Hurricane modules.
set ( sources2 Script.cpp )
set ( includes2 hurricane/viewer/Script.h )
qtX_wrap_cpp ( MOC_SRCS ${mocincludes} )
qtX_wrap_cpp( MOC_SRCS ${mocIncludes} )
qtX_add_resources( RCC_SRCS CellViewer.qrc )
add_library ( viewer ${cpps} ${MOC_SRCS} ${RCC_SRCS} ${sources2} ${pycpps} )
set_target_properties ( viewer PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries ( viewer hurricane
set( depLibs hurricane
isobar
${UTILITIES_LIBRARY}
${CONFIGURATION_LIBRARY}
@ -134,18 +130,19 @@
${Boost_LIBRARIES}
${QtX_LIBRARIES}
)
add_library ( pyViewer MODULE ${pycpps} )
target_link_libraries ( pyViewer viewer )
set_target_properties ( pyViewer PROPERTIES
COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
OUTPUT_NAME "Viewer"
PREFIX ""
add_library( viewer ${cpps} ${MOC_SRCS} ${RCC_SRCS} ${pyCpps} )
set_target_properties( viewer PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries( viewer ${depLibs} )
add_python_module( "${pyCpps}"
"${pyIncludes}"
"Do_not_generate_C_library"
Viewer
"viewer;${depLibs}"
include/coriolis2/hurricane/viewer
)
install( FILES ${includes}
${includes2}
${mocincludes}
${pyincludes} DESTINATION include/coriolis2/hurricane/viewer )
${mocIncludes} DESTINATION include/coriolis2/hurricane/viewer )
install( TARGETS viewer DESTINATION lib${LIB_SUFFIX} )
install ( TARGETS pyViewer DESTINATION ${PYTHON_SITE_PACKAGES} )

View File

@ -14,6 +14,8 @@
// +-----------------------------------------------------------------+
#if !defined(__PYTHON_MODULE__)
#include <Python.h>
#include <sstream>
#include "hurricane/Error.h"
@ -303,3 +305,5 @@ namespace Isobar {
} // End of Isobar namespace.
#endif

View File

@ -14,6 +14,8 @@
// +-----------------------------------------------------------------+
#if !defined(__PYTHON_MODULE__)
#ifndef ISOBAR_SCRIPT_H
#define ISOBAR_SCRIPT_H
@ -97,7 +99,8 @@ namespace Isobar {
{ return _userModule = _importModule(_moduleName,flags); }
} // End of Isobar namespace.
} // Isobar namespace.
#endif // ISOBAR_SCRIPT_H
#endif

View File

@ -5,7 +5,6 @@ if ( CHECK_DETERMINISM )
endif ( CHECK_DETERMINISM )
# include( ${QT_USE_FILE} )
include_directories( ${KATABATIC_SOURCE_DIR}/src
${CORIOLIS_INCLUDE_DIR}
${HURRICANE_INCLUDE_DIR}
@ -32,7 +31,6 @@ endif ( CHECK_DETERMINISM )
katabatic/GCellGrid.h
katabatic/Session.h
katabatic/KatabaticEngine.h
#katabatic/GraphicKatabaticEngine.h
)
set( mocIncludes katabatic/GraphicKatabaticEngine.h )
set( cpps Configuration.cpp
@ -57,15 +55,11 @@ endif ( CHECK_DETERMINISM )
NetConstraints.cpp
NetOptimals.cpp
KatabaticEngine.cpp
#GraphicKatabaticEngine.cpp
)
set( pyCpps PyKatabatic.cpp )
qtX_wrap_cpp( mocCpps ${mocIncludes} )
add_library ( katabatic ${cpps} )
set_target_properties ( katabatic PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries ( katabatic ${KNIK_LIBRARIES}
set( depLibs ${KNIK_LIBRARIES}
${CORIOLIS_LIBRARIES}
${HURRICANE_PYTHON_LIBRARIES}
${HURRICANE_GRAPHICAL_LIBRARIES}
@ -80,17 +74,20 @@ endif ( CHECK_DETERMINISM )
${LIBXML2_LIBRARIES}
${PYTHON_LIBRARIES} -lutil
)
add_library ( pyKatabatic MODULE ${pyCpps} )
set_target_properties ( pyKatabatic PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
PREFIX ""
OUTPUT_NAME "Katabatic"
)
target_link_libraries ( pyKatabatic katabatic
${CORIOLIS_PYTHON_LIBRARIES}
add_library( katabatic ${cpps} )
set_target_properties( katabatic PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries( katabatic ${depLibs} )
add_python_module( "${pyCpps}"
"${pyIncludes}"
"Do_not_generate_C_library"
Katabatic
"katabatic;${depLibs}"
include/coriolis2/katabatic
)
install( TARGETS katabatic DESTINATION lib${LIB_SUFFIX} )
install ( TARGETS pyKatabatic DESTINATION ${PYTHON_SITE_PACKAGES} )
install( FILES ${includes}
${mocIncludes} DESTINATION include/coriolis2/katabatic )

View File

@ -1,7 +1,6 @@
# -*- explicit-buffer-name: "CMakeLists.txt<kite/src>" -*-
# include( ${QT_USE_FILE} )
include_directories( ${KITE_SOURCE_DIR}/src
${CORIOLIS_INCLUDE_DIR}
${HURRICANE_INCLUDE_DIR}
@ -70,15 +69,13 @@
PyKiteEngine.cpp
PyGraphicKiteEngine.cpp
)
set ( kitecpps KiteMain.cpp )
set( kiteCpps KiteMain.cpp )
qtX_wrap_cpp( mocCpps ${mocIncludes} )
add_library ( kite ${cpps} ${mocCpps} ${pyCpps} )
set_target_properties ( kite PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries ( kite ${KATABATIC_LIBRARIES}
set( depLibs ${KATABATIC_LIBRARIES}
${KNIK_LIBRARIES}
${NIMBUS_LIBRARIES}
${CORIOLIS_PYTHON_LIBRARIES}
${CORIOLIS_LIBRARIES}
${HURRICANE_PYTHON_LIBRARIES}
${HURRICANE_GRAPHICAL_LIBRARIES}
@ -97,23 +94,24 @@
${LIBEXECINFO_LIBRARIES}
)
add_library ( pyKite MODULE ${pyCpps} )
set_target_properties ( pyKite PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
PREFIX ""
OUTPUT_NAME "Kite"
add_library( kite ${cpps} ${mocCpps} ${pyCpps} )
set_target_properties( kite PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries( kite ${depLibs} )
add_python_module( "${pyCpps}"
"${pyIncludes}"
"Do_not_generate_C_library"
Kite
"kite;${depLibs}"
include/coriolis2/kite
)
# add_executable ( kite.bin ${kitecpps} )
#target_link_libraries ( kite.bin kite )
target_link_libraries ( pyKite kite
${CORIOLIS_PYTHON_LIBRARIES}
)
# add_executable( kite.bin ${kiteCpps} )
#target_link_libraries( kite.bin kite ${depLibs} )
install( TARGETS kite DESTINATION lib${LIB_SUFFIX} )
# install( TARGETS kite.bin DESTINATION bin )
install ( TARGETS pyKite DESTINATION ${PYTHON_SITE_PACKAGES} )
install( FILES ${includes}
${mocIncludes}
${pyIncludes} DESTINATION include/coriolis2/kite )
${mocIncludes} DESTINATION include/coriolis2/kite )

View File

@ -1,6 +1,6 @@
# -*- explicit-buffer-name: "CMakeLists.txt<knik/src>" -*-
# include ( ${QT_USE_FILE} )
include_directories ( ${KNIK_SOURCE_DIR}/src
${KNIK_SOURCE_DIR}/src/flute-2.4/src
${HURRICANE_INCLUDE_DIR}

View File

@ -35,6 +35,7 @@
#find_package(SOLSTICE REQUIRED)
add_subdirectory(src)
add_subdirectory(python)
add_subdirectory(cmake_modules)
if(BUILD_DOC)

View File

@ -18,7 +18,7 @@ IF(UNIX)
FIND_PATH(UNICORN_INCLUDE_PATH NAMES unicorn/UnicornGui.h PATHS
# Look in other places.
${CORIOLIS_DIR_SEARCH}
PATH_SUFFIXES include/coriolis
PATH_SUFFIXES include/coriolis2 include
# Help the user find it if we cannot.
DOC "The ${UNICORN_INCLUDE_PATH_DESCRIPTION}"
)

View File

@ -0,0 +1,4 @@
# -*- explicit-buffer-name: "CMakeLists.txt<unicorn/python>" -*-
install( FILES unicornInit.py DESTINATION ${PYTHON_SITE_PACKAGES}/unicorn )

View File

@ -37,9 +37,7 @@
qtX_wrap_cpp( mocCpps ${mocincludes} )
qtX_add_resources( RCC_SRCS Unicorn.qrc )
add_library ( unicorn ${cpps} ${mocCpps} ${pyCpps} )
set_target_properties ( unicorn PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries ( unicorn ${SOLSTICE_GRAPHICAL_LIBRARIES}
set( depLibs ${SOLSTICE_GRAPHICAL_LIBRARIES}
${SOLSTICE_LIBRARIES}
${EQUINOX_GRAPHICAL_LIBRARIES}
${EQUINOX_LIBRARIES}
@ -76,23 +74,25 @@
-lutil
${LIBXML2_LIBRARIES}
)
add_library ( pyUnicorn MODULE ${pyCpps} )
target_link_libraries ( pyUnicorn unicorn )
set_target_properties ( pyUnicorn PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
PREFIX ""
OUTPUT_NAME "Unicorn"
add_library( unicorn ${cpps} ${mocCpps} ${pyCpps} )
set_target_properties( unicorn PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries( unicorn ${depLibs} )
add_python_module( "${pyCpps}"
"${pyIncludes}"
"Do_not_generate_C_library"
Unicorn
"unicorn;${depLibs}"
include/coriolis2/unicorn
)
add_executable( cgt.bin ${cgtcpp} )
target_link_libraries ( cgt.bin unicorn )
target_link_libraries( cgt.bin unicorn ${depLibs} )
install( TARGETS unicorn DESTINATION lib${LIB_SUFFIX} )
install ( TARGETS pyUnicorn DESTINATION ${PYTHON_SITE_PACKAGES} )
install( TARGETS cgt.bin DESTINATION bin )
install( PROGRAMS cgt.py DESTINATION bin RENAME cgt )
install( FILES ${includes}
${mocincludes}
${pyIncludes} DESTINATION include/coriolis2/unicorn )
install ( FILES init/unicornInit.py
DESTINATION ${PYTHON_SITE_PACKAGES}/unicorn )
${mocincludes} DESTINATION include/coriolis2/unicorn )