Commit 072bf7a8 authored by saubatn's avatar saubatn
Browse files

FIXED bug on linking libraries with external lib dependencies

UPDATED clean camitk macro (step 1.)
FIXED add dependencies building order for camitk libraries dependending on other cep libraries.
FIXED some libraries CMakeLists.txt files updates.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@961 ec899d31-69d1-42ba-9299-647d76f65fb3
parent fdcda525
......@@ -376,7 +376,9 @@ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# add lib as a camitk library
camitk_library(SHARED
SOURCES ${monitoring_SRCS}
EXTERNAL_LIBRARIES ${monitoring_LIBRARIES}
NEEDS_QT_MODULES
NEEDS_CEP_LIBRARIES mml pml lml
EXTERNAL_LIBRARIES ${MML_SOFA_LIBS}
INCLUDE_DIRECTORIES ${monitoring_INCLUDE_DIR}
LINK_DIRECTORIES ${monitoring_link}
NEEDS_LIBXML2
......
# use the application extension macro
camitk_application(NEEDS_QTXML
camitk_application(NEEDS_QT_MODULES #we use QtXML
ADDITIONAL_SOURCES CommandLineOptions.cxx CommandLineOptions.hxx CommandLineOptions.ixx
CEP_NAME SDK
DESCRIPTION "Simple action state machine to pipeline actions from an XML file"
......
......@@ -24,8 +24,8 @@
#! \code
#! camitk_application(
#! [DISABLED]
#! [NEEDS_QT_MODULES]
#! [NEEDS_ITK]
#! [NEEDS_QTXML]
#! [NEEDS_PYTHON]
#! [NEEDS_CEP_LIBRARIES CEPLib1 CEPLib12 ...]
#! [NEEDS_COMPONENT_EXTENSION component1 component2 ...]
......@@ -37,9 +37,9 @@
#! \endcode
#!
#! \param DISABLED means this is a default application is NOT to be compiled automatically
#! \param NEEDS_QT_MODULES add this if your library depends on Qt modules, such as QtCore, QtGui, QtMultimedia, QtNetwork, QtOpenGL, QtScript, QtScriptTools, QtSql, QtSvg, QtWebkit, QtXml, QtXmlPatterns, QtDeclarative
#! \param NEEDS_ITK means this application requires ITK to be compiled / run.
#! \param NEEDS_CEP_LIBRARIES list of needed camitk CEP libraries
#! \param NEEDS_QTXML this application needs QtXML
#! \param NEEDS_COMPONENT_EXTENSION list of needed component extensions
#! \param NEEDS_ACTION_EXTENSION list of needed component extensions
#! \param ADDITIONAL_SOURCES list of additional sources (that cannot be automatically found by gather_headers_and_sources macro)
......@@ -54,7 +54,7 @@ macro(camitk_application)
parse_arguments(${APPLICATION_NAME_CMAKE}
"NEEDS_CEP_LIBRARIES;NEEDS_TOOL;NEEDS_COMPONENT_EXTENSION;NEEDS_ACTION_EXTENSION;ADDITIONAL_SOURCES;CEP_NAME;DESCRIPTION;EXTERNAL_LIBRARIES;INCLUDE_DIRECTORIES" # possible lists
"DISABLED;NEEDS_ITK;NEEDS_QTXML;NEEDS_XSD;NEEDS_XERCESC;NEEDS_PYTHON" # possible options
"DISABLED;NEEDS_QT_MODULES;NEEDS_ITK;NEEDS_QTXML;NEEDS_XSD;NEEDS_XERCESC;NEEDS_PYTHON" # possible options
${ARGN}
)
......@@ -91,7 +91,7 @@ macro(camitk_application)
set(CEP_LIBRARIES ${CEP_LIBRARIES} ${${APPLICATION_NAME_CMAKE}_NEEDS_TOOL})
endif()
# check the option
# consider additional CEP libraries
if(${APPLICATION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES)
foreach(CEP_LIBRARIES_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES})
message(STATUS "${CEP_LIBRARIES_NEEDED} required by application ${APPLICATION_NAME}")
......@@ -100,15 +100,9 @@ macro(camitk_application)
# Add the libraries to link against according to the dependencies
if (MSVC)
# if (PACKAGING_NSIS)
# set(CEP_LIBRARIES ${CEP_LIBRARIES} debug ${CEP_LIBRARIES_NEEDED}${CAMITK_DEBUG_POSTFIX}
# optimized ${CEP_LIBRARIES_NEEDED}
# )
# else()
set(CEP_LIBRARIES ${CEP_LIBRARIES} debug ${CEP_LIBRARIES_NEEDED}${CAMITK_DEBUG_POSTFIX}
optimized ${CEP_LIBRARIES_NEEDED}
)
# endif()
else()
if(PACKAGING_NSIS)
set(CEP_LIBRARIES ${CEP_LIBRARIES} library_${CEP_LIBRARIES_NEEDED})
......@@ -183,16 +177,11 @@ macro(camitk_application)
endif()
endif()
set(QT_LIBRARIES_WITH_QTXML)
if(${APPLICATION_NAME_CMAKE}_NEEDS_QTXML)
set (QT_USE_QTXML ON)
find_package(Qt4 REQUIRED)
if(QT_USE_FILE)
include(${QT_USE_FILE})
else(QT_USE_FILE)
set(QT_LIBRARIES ${QT_QT_LIBRARY})
endif(QT_USE_FILE)
set(QT_LIBRARIES_WITH_QTXML ${QT_LIBRARIES})
# Looking for additional Qt modules
set(QT_MODULES_LIBRARIES)
if(${DEFAULT_LIBRARY_NAME_CMAKE}_NEEDS_QT_MODULES)
# Qt additional modules are required for linking
set(QT_MODULES_LIBRARIES ${QT_LIBRARIES})
endif()
# Looking for codesynthesis XSD CXX
......@@ -323,22 +312,41 @@ macro(camitk_application)
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_BIN_DIR}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_BIN_DIR}
)
# Application requires at least camitkcore library
add_dependencies(${APPLICATION_TARGET_NAME} ${CAMITK_CORE_TARGET_LIB_NAME})
# CEP library dependencies
if(${APPLICATION_TARGET_NAME}_NEEDS_CEP_LIBRARIES)
foreach(CEP_LIBRARIES_NEEDED ${${APPLICATION_TARGET_NAME}_NEEDS_CEP_LIBRARIES})
if(PACKAGING_NSIS)
add_dependencies(${APPLICATION_TARGET_NAME} library_${CEP_LIBRARIES_NEEDED})
else()
add_dependencies(${APPLICATION_TARGET_NAME} library-${CEP_LIBRARIES_NEEDED})
endif()
endforeach()
endif()
# Set the libraries needed to build the application target
target_link_libraries(${APPLICATION_TARGET_NAME} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${CAMITK_LIBRARIES} ${QT_MODULES_LIBRARIES} ${CAMITK_CORE_LIBRARIES} ${CEP_LIBRARIES} ${XERCESC_LIBRARY} ${ITK_LIBRARIES} ${PYTHON_LIBRARIES} ${EXTERNAL_LIBRARIES})
#########################################################################
# #
# INSTALLATION #
# #
# * When installing the project, header files (.h) and test data are #
# copied into a installation folder to determine. #
# * Indicate in this section, where to install your project and which #
# files to copy into that folder (during local/global installation) #
# #
#########################################################################
# Set the Component(s) dependency
# FOLDER INSTALLATION
# Indicate where to install the application
install(TARGETS ${APPLICATION_TARGET_NAME}
RUNTIME DESTINATION bin
COMPONENT ${APPLICATION_TARGET_NAME}
)
#########################################################################
# #
# PROJECT DEPENDENCIES #
# #
# * Add in this section library dependencies to other camitk projects #
# to keep a correct build order. #
# #
#########################################################################
# CAMITKCORE LIBRARY DEPENDENCY
add_dependencies(${APPLICATION_TARGET_NAME} ${CAMITK_CORE_TARGET_LIB_NAME})
# COMPONENTS DEPENDENCIES
if(${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION)
foreach(COMPONENT_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
string(TOUPPER ${COMPONENT_NEEDED} COMPONENT_NEEDED_CMAKE)
......@@ -350,7 +358,7 @@ macro(camitk_application)
endforeach()
endif()
# Set the Action(s) dependency
# ACTIONS DEPENDENCIES
if(${APPLICATION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION)
foreach(ACTION_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
string(TOUPPER ${ACTION_NEEDED} ACTION_NEEDED_CMAKE)
......@@ -361,17 +369,33 @@ macro(camitk_application)
endif()
endforeach()
endif()
# CEP LIBRARIES DEPENDENCIES
if(${DEFAULT_LIBRARY_NAME_CMAKE}_NEEDS_CEP_LIBRARIES)
foreach(CEP_LIBRARY_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES})
if(PACKAGING_NSIS)
add_dependencies(${APPLICATION_TARGET_NAME} library_${CEP_LIBRARY_NEEDED})
else()
add_dependencies(${APPLICATION_TARGET_NAME} library-${CEP_LIBRARY_NEEDED})
endif()
endforeach()
endif()
#########################################################################
# #
# PACKAGING CATEGORIZATION #
# #
# * On Windows, when building a package (win32 installer), the #
# install shield wizard proposes you to select which component #
# to install. #
# * Each component to install has a short description following its #
# name to understand its role. #
# * This section deals with the categorization and the description #
# of the component in this installer. #
# #
#########################################################################
# Set the libraries needed to build the application target
target_link_libraries(${APPLICATION_TARGET_NAME} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${CAMITK_LIBRARIES} ${QT_LIBRARIES_WITH_QTXML} ${CAMITK_CORE_LIBRARIES} ${CEP_LIBRARIES} ${XERCESC_LIBRARY} ${ITK_LIBRARIES} ${PYTHON_LIBRARIES} ${EXTERNAL_LIBRARIES})
# installation
install(TARGETS ${APPLICATION_TARGET_NAME}
RUNTIME DESTINATION bin
COMPONENT ${APPLICATION_TARGET_NAME}
)
# Categorized the extension in the install shield wizard.
# WINDOWS INSTALLER CATEGORIZATION
if(${APPLICATION_NAME_CMAKE}_CEP_NAME)
if (${APPLICATION_NAME_CMAKE}_CEP_NAME MATCHES "SDK")
# The default SDK extensions are categorized as "required" and are not "unselectable" by the user at installation time
......
......@@ -10,12 +10,12 @@
#! \code
#! extension(<type>
#! [DISABLED]
#! [NEEDS_QT_MODULES]
#! [NEEDS_ITK]
#! [NEEDS_LIBXML2]
#! [NEEDS_OPENCV]
#! [NEEDS_IGSTK]
#! [NEEDS_XSD]
#! [NEEDS_QTXML]
#! [NEEDS_GDCM]
#! [NEEDS_CEP_LIBRARIES CEPLib1 CEPLib2 ...]
#! [NEEDS_COMPONENT_EXTENSION component1 component2 ...]
......@@ -32,6 +32,7 @@
#! \param <type> = The selected type of extension you wish to build.
# possible values : ACTION_EXTENSION or COMPONENT_EXTENSION.
#! \param DISABLED = means this is a not a default extension, it will not be compiled automatically
#! \param NEEDS_QT_MODULES = add this if your library depends on Qt modules, such as QtCore, QtGui, QtMultimedia, QtNetwork, QtOpenGL, QtScript, QtScriptTools, QtSql, QtSvg, QtWebkit, QtXml, QtXmlPatterns, QtDeclarative
#! \param NEEDS_ITK = add this if your component needs itk.
#! Do not forget to add the needed list of itk libraries in the LIBRARIES parameter
#! \param NEEDS_LIBXML2 = add this if your component needs libxml2
......@@ -39,7 +40,6 @@
#! \param NEEDS_OPENCV = add this if your component needs OpenCV
#! \param NEEDS_IGSTK = add this if your component needs IgsTK
#! \param NEEDS_XERCESC = add this if your action / component needs XercesC library
#! \param NEEDS_QTXML = this application needs QtXML
#! \param NEEDS_CEP_LIBRARIES = list of needed CEP libraries (not external dependencies)
#! \param NEEDS_COMPONENT_EXTENSION = list of needed component extensions
#! \param NEEDS_ACTION_EXTENSION = list of needed component extensions
......@@ -69,7 +69,7 @@ macro(camitk_extension)
parse_arguments(${EXTENSION_NAME_CMAKE} #prefix
"NEEDS_TOOL;NEEDS_CEP_LIBRARIES;NEEDS_COMPONENT_EXTENSION;NEEDS_ACTION_EXTENSION;INCLUDE_DIRECTORIES;EXTERNAL_LIBRARIES;HEADERS_TO_INSTALL;DEFINES;EXTERNAL_SOURCES;TARGET_NAME;CEP_NAME;DESCRIPTION" # possible lists
"ACTION_EXTENSION;COMPONENT_EXTENSION;DISABLED;NEEDS_XERCESC;NEEDS_ITK;NEEDS_LIBXML2;NEEDS_XSD;NEEDS_QTXML;NEEDS_OPENCV;NEEDS_IGSTK;INSTALL_ALL_HEADERS;NEEDS_GDCM" # possible options
"NEEDS_QT_MODULES;ACTION_EXTENSION;COMPONENT_EXTENSION;DISABLED;NEEDS_XERCESC;NEEDS_ITK;NEEDS_LIBXML2;NEEDS_XSD;NEEDS_QTXML;NEEDS_OPENCV;NEEDS_IGSTK;INSTALL_ALL_HEADERS;NEEDS_GDCM" # possible options
${ARGN}
)
......@@ -142,15 +142,9 @@ macro(camitk_extension)
string(TOUPPER ${CEP_LIBRARIES_NEEDED} ${CEP_LIBRARIES_NEEDED}_INTERNAL)
set(LIBRARY_${${CEP_LIBRARIES_NEEDED}_INTERNAL} ON CACHE BOOL "Required by action extension ${EXTENSION_NAME}" FORCE )
if (MSVC)
# if (PACKAGING_NSIS)
# set(CEP_LIBRARIES ${CEP_LIBRARIES} debug ${CEP_LIBRARIES_NEEDED}${CAMITK_DEBUG_POSTFIX}
# optimized ${CEP_LIBRARIES_NEEDED}
# )
# else()
set(CEP_LIBRARIES ${CEP_LIBRARIES} debug ${CEP_LIBRARIES_NEEDED}${CAMITK_DEBUG_POSTFIX}
optimized ${CEP_LIBRARIES_NEEDED}
)
# endif()
else()
if(PACKAGING_NSIS)
set(CEP_LIBRARIES ${CEP_LIBRARIES} library_${CEP_LIBRARIES_NEEDED})
......@@ -283,27 +277,24 @@ macro(camitk_extension)
endif()
if(GDCM_FOUND)
include(${GDCM_USE_FILE})
if (MSVC)
set(GDCM_LIBRARIES
debug ${GDCM_DIR}/../vtkgdcm${CAMITK_DEBUG_POSTFIX}
optimized vtkgdcm
)
else()
set(GDCM_LIBRARIES vtkgdcm)
endif()
if (MSVC)
set(GDCM_LIBRARIES
debug ${GDCM_DIR}/../vtkgdcm${CAMITK_DEBUG_POSTFIX}
optimized vtkgdcm
)
else()
set(GDCM_LIBRARIES vtkgdcm)
endif()
else()
message(ERROR "${EXTENSION_NAME}: GDCM 2.x library required. Please install GDCM.")
endif()
endif()
set(QT_LIBRARIES_WITH_QTXML)
if(${EXTENSION_NAME_CMAKE}_NEEDS_QTXML)
set (QT_USE_QTXML ON)
find_package(Qt4 REQUIRED)
if(QT_USE_FILE)
include(${QT_USE_FILE})
endif()
set(QT_LIBRARIES_WITH_QTXML ${QT_LIBRARIES})
# Looking for additional Qt modules
set(QT_MODULES_LIBRARIES)
if(${DEFAULT_LIBRARY_NAME_CMAKE}_NEEDS_QT_MODULES)
# Qt additional modules are required for linking
set(QT_MODULES_LIBRARIES ${QT_LIBRARIES})
endif()
set(COMPONENT_EXTENSION_LIBRARIES)
......@@ -392,11 +383,9 @@ macro(camitk_extension)
# Set the libraries required to link the target
# Any component or action has to be linked with ${CAMITK_CORE_LIBRARIES} and with all its dependencies
target_link_libraries(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_LIBRARIES} ${QT_LIBRARIES_WITH_QTXML} ${CAMITK_CORE_LIBRARIES} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${ITK_LIBRARIES} ${LIBXML2_LIBRARIES} ${OpenCV_LIBRARIES} ${IGSTK_LIBRARIES} ${XERCESC_LIBRARY} ${GDCM_LIBRARIES} ${CEP_LIBRARIES} ${EXTERNAL_LIBRARIES})
target_link_libraries(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_LIBRARIES} ${QT_MODULES_LIBRARIES} ${CAMITK_CORE_LIBRARIES} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${ITK_LIBRARIES} ${LIBXML2_LIBRARIES} ${OpenCV_LIBRARIES} ${IGSTK_LIBRARIES} ${XERCESC_LIBRARY} ${GDCM_LIBRARIES} ${CEP_LIBRARIES} ${EXTERNAL_LIBRARIES})
# dependencies to core (only set for internal build)
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_CORE_TARGET_LIB_NAME})
# change the output library name
set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
PROPERTIES OUTPUT_NAME ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}
......@@ -435,21 +424,88 @@ macro(camitk_extension)
SOVERSION "${CAMITK_VERSION_MAJOR}"
)
# set the library specific info (SONAME...)
set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTIES ${${TYPE_EXTENSION_CMAKE}_LIBRARY_PROPERTIES} LINK_INTERFACE_LIBRARIES "")
set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTIES ${${TYPE_EXTENSION_CMAKE}_LIBRARY_PROPERTIES} LINK_INTERFACE_LIBRARIES "")
#########################################################################
# #
# INSTALLATION #
# #
# * When installing the project, header files (.h) and test data are #
# copied into a installation folder to determine. #
# * Indicate in this section, where to install your project and which #
# files to copy into that folder (during local/global installation) #
# #
#########################################################################
# FOLDER INSTALLATION
# Indicate where to install the action/component
install(TARGETS ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
# TODO always use private lib, even for runtime
RUNTIME DESTINATION lib/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
LIBRARY DESTINATION lib/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
ARCHIVE DESTINATION lib/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
)
# CEP libraries dependencies
if(${EXTENSION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES)
foreach(CEP_LIBRARIES_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES})
# TODO add IMPORTED
if (PACKAGING_NSIS)
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} library_${CEP_LIBRARIES_NEEDED})
else()
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} library-${CEP_LIBRARIES_NEEDED})
endif()
endforeach()
# HEADERS INSTALLATION
# Build target to install provided headers to install (with HEADERS_TO_INSTALL option)
if(${EXTENSION_NAME_CMAKE}_HEADERS_TO_INSTALL)
export_headers(${${EXTENSION_NAME_CMAKE}_HEADERS_TO_INSTALL} COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} GROUP ${TYPE_EXTENSION}s)
endif()
# Build target to install all header files(with HEADERS_ALL_HEADERS option)
if(${EXTENSION_NAME_CMAKE}_INSTALL_ALL_HEADERS)
export_headers(${${EXTENSION_NAME_CMAKE}_HEADERS} COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} GROUP ${TYPE_EXTENSION}s)
endif()
# TESTDATA INSTALLATION
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/testdata)
# Check test data dir directory
if (NOT EXISTS ${CAMITK_BUILD_TESTDATA_DIR})
add_custom_command(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_BUILD_TESTDATA_DIR}
COMMENT "Creating build-time share directory for test data ${CAMITK_BUILD_TESTDATA_DIR}"
VERBATIM
)
endif()
# At build time, copy the files to test data directory
add_custom_command(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory testdata ${CAMITK_BUILD_TESTDATA_DIR}
COMMENT "Installing build-time test data for ${EXTENSION_NAME}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
# during installation, copy the files to install directory
set (TESTDATA_DEST_DIR share/${CAMITK_SHORT_VERSION_STRING}/testdata)
install(DIRECTORY testdata/
#DESTINATION share/testdata
#DESTINATION share/${CAMITK_SHORT_VERSION_STRING}/testdata
DESTINATION ${TESTDATA_DEST_DIR}
# COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
PATTERN ".svn" EXCLUDE
PATTERN "*~" EXCLUDE
)
endif()
# Set the Component(s) dependency
endif()
#########################################################################
# #
# PROJECT DEPENDENCIES #
# #
# * Add in this section library dependencies to other camitk projects #
# to keep a correct build order. #
# #
#########################################################################
# CAMITKCORE LIBRARY DEPENDENCY
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_CORE_TARGET_LIB_NAME})
# COMPONENTS DEPENDENCIES
if(${EXTENSION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION)
foreach(COMPONENT_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
string(TOUPPER ${COMPONENT_NEEDED} COMPONENT_NEEDED_CMAKE)
......@@ -460,8 +516,8 @@ macro(camitk_extension)
endif()
endforeach()
endif()
# Set the Action(s) dependency
# ACTIONS DEPENDENCIES
if(${EXTENSION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION)
foreach(ACTION_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
string(TOUPPER ${ACTION_NEEDED} ACTION_NEEDED_CMAKE)
......@@ -472,27 +528,34 @@ macro(camitk_extension)
endif()
endforeach()
endif()
# generate an install target for headers
if(${EXTENSION_NAME_CMAKE}_HEADERS_TO_INSTALL)
export_headers(${${EXTENSION_NAME_CMAKE}_HEADERS_TO_INSTALL} COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} GROUP ${TYPE_EXTENSION}s)
endif()
# lazy you!
if(${EXTENSION_NAME_CMAKE}_INSTALL_ALL_HEADERS)
export_headers(${${EXTENSION_NAME_CMAKE}_HEADERS} COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} GROUP ${TYPE_EXTENSION}s)
# CEP LIBRARIES DEPENDENCIES
if(${EXTENSION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES)
foreach(CEP_LIBRARY_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_CEP_LIBRARIES})
# TODO add IMPORTED
if (PACKAGING_NSIS)
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} library_${CEP_LIBRARY_NEEDED})
else()
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} library-${CEP_LIBRARY_NEEDED})
endif()
endforeach()
endif()
# lib installation
install(TARGETS ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
# TODO always use private lib, even for runtime
RUNTIME DESTINATION lib/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
LIBRARY DESTINATION lib/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
ARCHIVE DESTINATION lib/${CAMITK_SHORT_VERSION_STRING}/${TYPE_EXTENSION}s
COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
)
# Categorized the extension in the install shield wizard.
#########################################################################
# #
# PACKAGING CATEGORIZATION #
# #
# * On Windows, when building a package (win32 installer), the #
# install shield wizard proposes you to select which component #
# to install. #
# * Each component to install has a short description following its #
# name to understand its role. #
# * This section deals with the categorization and the description #
# of the component in this installer. #
# #
#########################################################################
# WINDOWS INSTALLER CATEGORIZATION
if(${EXTENSION_NAME_CMAKE}_CEP_NAME)
if (${EXTENSION_NAME_CMAKE}_CEP_NAME MATCHES "SDK")
# The default SDK extensions are categorized as "required" and are not "unselectable" by the user at installation time
......@@ -519,42 +582,8 @@ macro(camitk_extension)
)
endif()
# testdata files installation
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/testdata)
# Check test data dir directory
if (NOT EXISTS ${CAMITK_BUILD_TESTDATA_DIR})
add_custom_command(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_BUILD_TESTDATA_DIR}
COMMENT "Creating build-time share directory for test data ${CAMITK_BUILD_TESTDATA_DIR}"
VERBATIM
)
endif()
# At build time, copy the files to test data directory
add_custom_command(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory testdata ${CAMITK_BUILD_TESTDATA_DIR}
COMMENT "Installing build-time test data for ${EXTENSION_NAME}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
# during installation, copy the files to install directory
set (TESTDATA_DEST_DIR share/${CAMITK_SHORT_VERSION_STRING}/testdata)
install(DIRECTORY testdata/
#DESTINATION share/testdata
#DESTINATION share/${CAMITK_SHORT_VERSION_STRING}/testdata
DESTINATION ${TESTDATA_DEST_DIR}
# COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
PATTERN ".svn" EXCLUDE
PATTERN "*~" EXCLUDE
)
endif()
endif()
endmacro()
......
......@@ -14,15 +14,17 @@
#! \code
#! camitk_library(
#! SHARED|STATIC
#! [LIBNAME libname]
#! [PUBLIC]
#! SOURCES source1.cpp source1.h...
#! EXTERNAL_LIBRARIES lib1 lib2...
#! [INCLUDE_DIRECTORIES dir1 dir2...]
#! [NEEDS_CEP_LIBRARIES lib1 lib2...]
#! [NEEDS_LIBXML2]
#! [NEEDS_XERCESC]
#! [NEEDS_XSD]
#! [NEEDS_QT_MODULES]
#! [EXTERNAL_LIBRARIES lib1 lib2... ]
#! [INCLUDE_DIRECTORIES dir1 dir2...]
#! [LINK_DIRECTORIES dir1 dir2...]
#! [LIBNAME libname]
#! [PUBLIC]
#! [HEADERS_TO_INSTALL]
#! [CEP_NAME]
#! [DESCRIPTION]
......@@ -33,10 +35,12 @@
#! \param SHARED optional, if the library should be compiled as shared
#! \param SOURCES all sources to be included in the library
#! \param INCLUDE_DIRECTORIES all needed include directories (${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} are automatically added)
#! \param LIBRARIES all the libraries to be used during the link (shared or static)
#! \param EXTERNAL_LIBRARIES all the libraries to be used during the link (shared or static)
#! \param NEEDS_CEP_LIBRARIES all the libraries to be used during the link (shared or static)
#! \param NEEDS_LIBXML2 add this if the CEP library needs libxml2
#! \param NEEDS_XERCESC add this if your action / component needs XercesC library
#! \param NEEDS_XSD add this if your action needs Codesynthesis xsd cxx (xml schema compiler)
#! \param NEEDS_QT_MODULES add this if your library depends on Qt modules, such as QtCore, QtGui, QtMultimedia, QtNetwork, QtOpenGL, QtScript, QtScriptTools, QtSql, QtSvg, QtWebkit, QtXml, QtXmlPatterns, QtDeclarative
#! \param LIBNAME force the CEP library name to be different from the directory it is in
#! \param LINK_DIRECTORIES additional directories to use in link_directories(...)
#! \param PUBLIC The library is a public library that has to be loaded directly by the operating system.
......@@ -55,11 +59,11 @@ macro(camitk_library)
get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} DEFAULT_LIBRARY_NAME)
parse_arguments(${DEFAULT_LIBRARY_NAME_CMAKE}
"SOURCES;EXTERNAL_LIBRARIES;INCLUDE_DIRECTORIES;LIBNAME;LINK_DIRECTORIES;HEADERS_TO_INSTALL;CEP_NAME;DESCRIPTION" # possible lists
"SHARED;STATIC;NEEDS_LIBXML2;NEEDS_XERCESC;NEEDS_XSD;PUBLIC" # possible options
"SOURCES;NEEDS_CEP_LIBRARIES;EXTERNAL_LIBRARIES;INCLUDE_DIRECTORIES;LIBNAME;LINK_DIRECTORIES;HEADERS_TO_INSTALL;CEP_NAME;DESCRIPTION;" # possible lists
"SHARED;STATIC;NEEDS_LIBXML2;NEEDS_XERCESC;NEEDS_XSD;NEEDS_QT_MODULES;PUBLIC" # possible options
${ARGN}
)
# if the libname is forced to be different (for string comparison problem, and
# why there is a double quote here, see http://www.cmake.org/pipermail/cmake/2011-October/046939.html)
# NSIS requires that cpack component names do not feature space or "-" characters
......@@ -77,9 +81,6 @@ macro(camitk_library)
endif()
endif()
# when installing, remove the prefix 'library'
string(REGEX REPLACE "^library_|^library-" "" LIBRARY_NAME ${LIBRARY_TARGET_NAME})
# includes
include_directories ( ${${DEFAULT_LIBRARY_NAME_CMAKE}_INCLUDE_DIRECTORIES}
${CMAKE_CURRENT_SOURCE_DIR}
......@@ -127,17 +128,51 @@ macro(camitk_library)
endif()
endif()
# Looking for additional Qt modules
set(QT_MODULES_LIBRARIES)
if(${DEFAULT_LIBRARY_NAME_CMAKE}_NEEDS_QT_MODULES)
# Qt additional modules are required for linking
set(QT_MODULES_LIBRARIES ${QT_LIBRARIES})
endif()
# Add the link directories needed for linkage
link_directories(${CAMITK_LINK_DIRECTORIES})
# CEP Libraries dependencies
set(CEP_LIBRARIES)
if(${DEFAULT_LIBRARY_NAME_CMAKE}_NEEDS_CEP_LIBRARIES)
foreach(CEP_LIBRARY_NEEDED ${${DEFAULT_LIBRARY_NAME_CMAKE}_NEEDS_CEP_LIBRARIES})
string(TOUPPER ${CEP_LIBRARY_NEEDED} ${CEP_LIBRARY_NEEDED}_INTERNAL)
set(LIBRARY_${${CEP_LIBRARY_NEEDED}_INTERNAL} ON CACHE BOOL "Required by action extension ${EXTENSION_NAME}" FORCE )
if (MSVC)
set(CEP_LIBRARIES ${CEP_LIBRARIES} debug ${CEP_LIBRARY_NEEDED}${CAMITK_DEBUG_POSTFIX}
optimized ${CEP_LIBRARY_NEEDED}
)
else()
if(PACKAGING_NSIS)
set(CEP_LIBRARIES ${CEP_LIBRARIES} library_${CEP_LIBRARY_NEEDED})
else()
set(CEP_LIBRARIES ${CEP_LIBRARIES} library-${CEP_LIBRARY_N