Commit af5693b3 authored by promayon's avatar promayon
Browse files

FIXED CEP problem with specific TARGET_NAME , output name and SONAME

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@718 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 0f093d33
......@@ -146,7 +146,11 @@ endmacro()
#! \param subdir (required) the name of the source subdirectory to include
macro(camitk_add_subdirectory DirectoryName)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${DirectoryName} AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${DirectoryName}/CMakeLists.txt)
message(STATUS "${CMAKE_PROJECT_NAME} ${CEP_NAME} provides ${DirectoryName}:")
set(SUBDIRECTORY_MESSAGE ${CMAKE_PROJECT_NAME})
if(CEP_NAME AND NOT ${CEP_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
set(SUBDIRECTORY_MESSAGE "${SUBDIRECTORY_MESSAGE} ${CEP_NAME}")
endif()
message(STATUS "${SUBDIRECTORY_MESSAGE} provides ${DirectoryName}:")
add_subdirectory(${DirectoryName})
endif()
endmacro()
......@@ -267,64 +271,66 @@ macro(export_headers)
endmacro()
# MACRO camitk_extension
#
# Simplify writing a camitk extension (component, action)
#
# usage:
# extension(<type>
# [DEFAULT]
# [NEEDS_ITK]
# [NEEDS_LIBXML2]
# [NEEDS_OPENCV]
# [NEEDS_IGSTK]
# [NEEDS_XSD]
# [NEEDS_QTXML]
# [NEEDS_TOOL tool1 tool2 ...]
# [NEEDS_COMPONENT_EXTENSION component1 component2 ...]
# [INCLUDE_DIRECTORIES dir1 dir2 ...]
# [DEFINES flag1 flag2 ...]
# [EXTERNAL_SOURCES file1 file2 ...]
# [LIBRARIES lib1 lib2 ...]
# [HEADERS_TO_INSTALL header1.h header2.h ...]
# [INSTALL_ALL_HEADERS]
# [TARGET_NAME non-default-targetname]
# )
#
# The name of the extension is automatically the name of the directory from where this macro
# is called.
#
# <type> = The selected type of extension you wish to build.
# possible values : ACTION_EXTENSION or COMPONENT_EXTENSION.
# DEFAULT = means this is a default component to be compiled automatically
# NEEDS_ITK = add this if your component needs itk.
# Do not forget to add the needed list of itk libraries in the LIBRARIES parameter
# NEEDS_LIBXML2 = add this if your component needs libxml2
# NEEDS_XSD = add this if your action needs Codesynthesis xsd cxx (xml schema compiler)
# NEEDS_OPENCV = add this if your component needs OpenCV
# NEEDS_IGSTK = add this if your component needs IgsTK
# NEEDS_XERCESC = add this if your action / component needs XercesC library
# NEEDS_QTXML = this application needs QtXML
# NEEDS_TOOL = list of needed camitk tools
# NEEDS_COMPONENT_EXTENSION = list of needed component extensions
# NEEDS_ACTION_EXTENSION = list of needed component extensions
# INCLUDE_DIRECTORIES = additional include directories
# DEFINES = list of define flags to add at compilation time
# EXTERNAL_SOURCES = list of extra source/headers files (external to the current directory)
# that needed to be added to the SOURCES variable.
# Note: EXTERNAL_SOURCES are not installed
# LIBRARIES = libraries to add to the link command
# HEADERS_TO_INSTALL = list of headers to install, if present this will automatically
# create an "install-COMPONENT_NAMEcomponent" target, that can be used
# anywhere else to manage dependencies to this component.
# The headers are installed ${CAMITK_INCLUDE_DIR}
# when the target "install-COMPONENT_NAMEcomponent" is called.
# INSTALL_ALL_HEADERS = install all of the headers (this is the lazy solution, please consider
# making a list and using HEADERS_TO_INSTALL parameter instead!
# TARGET_NAME = specify a target name different than the default (default is the action/component directory name)
# this can be very useful for example when you have action/component directory in your CEP that has
# the same name as one in the camitk opensource
#!
#! \addtogroup CamiTKMacros
#!
#! Macro camitk_extension simplifies writing a camitk extension (component, action)
#!
#! usage:
#! \code
#! extension(<type>
#! [DEFAULT]
#! [NEEDS_ITK]
#! [NEEDS_LIBXML2]
#! [NEEDS_OPENCV]
#! [NEEDS_IGSTK]
#! [NEEDS_XSD]
#! [NEEDS_QTXML]
#! [NEEDS_TOOL tool1 tool2 ...]
#! [NEEDS_COMPONENT_EXTENSION component1 component2 ...]
#! [INCLUDE_DIRECTORIES dir1 dir2 ...]
#! [DEFINES flag1 flag2 ...]
#! [EXTERNAL_SOURCES file1 file2 ...]
#! [LIBRARIES lib1 lib2 ...]
#! [HEADERS_TO_INSTALL header1.h header2.h ...]
#! [INSTALL_ALL_HEADERS]
#! [TARGET_NAME non-default-targetname]
#! )
#! \endcode
#!
#! The name of the extension is automatically the name of the directory from where this macro
#! is called, unless it is overriden by the TARGET_NAME parameter.
#!
#! \param <type> = The selected type of extension you wish to build.
# possible values : ACTION_EXTENSION or COMPONENT_EXTENSION.
#! \param DEFAULT = means this is a default component to be compiled automatically
#! \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
#! \param NEEDS_XSD = add this if your action needs Codesynthesis xsd cxx (xml schema compiler)
#! \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_TOOL = list of needed camitk tools
#! \param NEEDS_COMPONENT_EXTENSION = list of needed component extensions
#! \param NEEDS_ACTION_EXTENSION = list of needed component extensions
#! \param INCLUDE_DIRECTORIES = additional include directories
#! \param DEFINES = list of define flags to add at compilation time
#! \param EXTERNAL_SOURCES = list of extra source/headers files (external to the current directory)
#! that needed to be added to the SOURCES variable.
#! Note: EXTERNAL_SOURCES are not installed
#! \param LIBRARIES = libraries to add to the link command
#! \param HEADERS_TO_INSTALL = list of headers to install, if present this will automatically
#! create an "install-COMPONENT_NAMEcomponent" target, that can be used
#! anywhere else to manage dependencies to this component.
#! The headers are installed ${CAMITK_INCLUDE_DIR}
#! when the target "install-COMPONENT_NAMEcomponent" is called.
#! \param INSTALL_ALL_HEADERS = install all of the headers (this is the lazy solution, please consider
#! making a list and using HEADERS_TO_INSTALL parameter instead!
#! \param TARGET_NAME = specify a target name different than the default (default is the action/component directory name)
#! this can be very useful for example when you have action/component directory in your CEP that has
#! the same name as one in the camitk opensource.
macro(camitk_extension)
get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} EXTENSION_NAME)
......@@ -337,11 +343,11 @@ macro(camitk_extension)
# Get the type of extension
if (${EXTENSION_NAME_CMAKE}_ACTION_EXTENSION)
set(TYPE_EXTENSION "action")
string(TOUPPER ${TYPE_EXTENSION} TYPE_EXTENSION_CMAKE)
set(TYPE_EXTENSION "action")
string(TOUPPER ${TYPE_EXTENSION} TYPE_EXTENSION_CMAKE)
elseif(${EXTENSION_NAME_CMAKE}_COMPONENT_EXTENSION)
set(TYPE_EXTENSION "component")
string(TOUPPER ${TYPE_EXTENSION} TYPE_EXTENSION_CMAKE)
set(TYPE_EXTENSION "component")
string(TOUPPER ${TYPE_EXTENSION} TYPE_EXTENSION_CMAKE)
endif()
# if it is the first cmake run, create the extension variable with a correct initial value
......@@ -366,10 +372,11 @@ macro(camitk_extension)
# check for target name
if (${EXTENSION_NAME_CMAKE}_TARGET_NAME)
set(${TYPE_EXTENSION_CMAKE}_TARGET_NAME ${${EXTENSION_NAME_CMAKE}_TARGET_NAME})
set(${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME ${${EXTENSION_NAME_CMAKE}_TARGET_NAME})
else()
set(${TYPE_EXTENSION_CMAKE}_TARGET_NAME ${TYPE_EXTENSION}-${EXTENSION_NAME})
set(${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME ${EXTENSION_NAME})
endif()
set(${TYPE_EXTENSION_CMAKE}_TARGET_NAME ${TYPE_EXTENSION}-${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME})
message(STATUS "Building extension ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}")
# actions are compiled as shared object
......@@ -399,11 +406,11 @@ macro(camitk_extension)
set(TOOL_${${TOOL_NEEDED}_INTERNAL} ON CACHE BOOL "Required by action extension ${EXTENSION_NAME}" FORCE )
set(TOOL_LIBRARIES ${TOOL_LIBRARIES} ${TOOL_NEEDED})
include_directories(${CAMITK_INCLUDE_DIR}/${TOOL_NEEDED}) # TODO remove this
include_directories(${CMAKE_BINARY_DIR}/include/${TOOL_NEEDED})
include_directories(${CMAKE_BINARY_DIR}/include/${TOOL_NEEDED})
endforeach()
endif()
# Looking for ITK
# Looking for ITK
set(ITK_LIBRARIES "")
if(${EXTENSION_NAME_CMAKE}_NEEDS_ITK)
# ITK is required
......@@ -414,7 +421,7 @@ macro(camitk_extension)
set(ITK_LIBRARIES "")
endif()
# Looking for LibXML2.0
# Looking for LibXML2.0
set(LIBXML2_LIBRARIES)
if(${EXTENSION_NAME_CMAKE}_NEEDS_LIBXML2)
# LibXml2 is required
......@@ -427,24 +434,24 @@ macro(camitk_extension)
message(STATUS "${EXTENSION_NAME}: libxml2 required")
endif()
endif()
# looking for OpenCV
set(OpenCV_LIBRARIES "")
if(${EXTENSION_NAME_CMAKE}_NEEDS_OPENCV)
# OpenCV is required
find_package( OpenCV REQUIRED )
else ( )
set(OpenCV_LIBRARIES "")
endif()
# OpenCV is required
find_package( OpenCV REQUIRED )
else ( )
set(OpenCV_LIBRARIES "")
endif()
#looking for IGSTK libraries ?
set(IGSTK_LIBRARIES "")
if(${EXTENSION_NAME_CMAKE}_NEEDS_IGSTK)
find_package(IGSTK REQUIRED)
include(${IGSTK_USE_FILE})
else()
set(IGSTK_LIBRARIES "")
endif()
find_package(IGSTK REQUIRED)
include(${IGSTK_USE_FILE})
else()
set(IGSTK_LIBRARIES "")
endif()
# Looking for XercesC
set(XERCESC_LIBRARIES)
......@@ -518,18 +525,18 @@ macro(camitk_extension)
${CAMITK_INSTALL_ROOT}/bin/actions
${CMAKE_CURRENT_BINARY_DIR}/../../bin/components
${CMAKE_CURRENT_BINARY_DIR}/../../bin/actions
# For CEP
${CMAKE_BINARY_DIR}/bin/components
${CMAKE_BINARY_DIR}/bin/actions
${CMAKE_BINARY_DIR}/bin
${CMAKE_BINARY_DIR}/lib
# For CEP
${CMAKE_BINARY_DIR}/bin/components
${CMAKE_BINARY_DIR}/bin/actions
${CMAKE_BINARY_DIR}/bin
${CMAKE_BINARY_DIR}/lib
)
# get all headers, sources and do what is needed for Qt
# one need to do this just before the add_library so that all defines, include directories and link directories
# are set properly (gather_headers_and_sources include the call to Qt moc and uic)
gather_headers_and_sources(${EXTENSION_NAME_CMAKE})
# check for external sources
if(${EXTENSION_NAME_CMAKE}_EXTERNAL_SOURCES)
set(${EXTENSION_NAME_CMAKE}_SOURCES ${${EXTENSION_NAME_CMAKE}_SOURCES} ${${EXTENSION_NAME_CMAKE}_EXTERNAL_SOURCES})
......@@ -551,12 +558,19 @@ macro(camitk_extension)
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_CORE_LIB})
endif()
# change the output library name
set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
PROPERTIES OUTPUT_NAME ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}
)
# see http://www.cmake.org/pipermail/cmake/2012-April/049889.html
# target properties (outputname and remove soname)
# set_property(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} PROPERTY NO_SONAME 1)
set_target_properties(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
PROPERTIES OUTPUT_NAME ${EXTENSION_NAME}
)
# in CEP the version patch might not have been set
if (NOT CAMITK_VER_PAT)
set(CAMITK_VER_PAT 0)
endif()
# set so name
set(${TYPE_EXTENSION_CMAKE}_LIBRARY_PROPERTIES ${${TYPE_EXTENSION_CMAKE}_LIBRARY_PROPERTIES}
VERSION "${CAMITK_VER_MAJ}.${CAMITK_VER_MIN}.${CAMITK_VER_PAT}"
SOVERSION "${CAMITK_VER_MAJ}"
......@@ -578,37 +592,29 @@ macro(camitk_extension)
# if this is not true, then the dependencies is from an external build, do not use add_dependencies
if (CAMITK_COMPONENT_${COMPONENT_NEEDED_CMAKE}_INTERNAL)
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} component-${COMPONENT_NEEDED})
# message(STATUS "............................................................ ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} depends on component-${COMPONENT_NEEDED}")
# if(NOT TARGET "component-${COMPONENT_NEEDED}")
# message(STATUS "............................................................ component-${COMPONENT_NEEDED} not existing (yet)")
# endif()
endif()
endforeach()
endif()
# Set the Action(s) dependency
# Set the Action(s) dependency
if(${EXTENSION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION)
foreach(ACTION_NEEDED ${${EXTENSION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
string(TOUPPER ${ACTION_NEEDED} ACTION_NEEDED_CMAKE)
# if this is not true, then the dependencies is from an external build, do not use add_dependencies
# if this is not true, then the dependencies is from an external build, do not use add_dependencies
if (CAMITK_ACTION_${ACTION_NEEDED_CMAKE}_INTERNAL)
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} action-${ACTION_NEEDED})
# message(STATUS "............................................................ ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} depends on action-${ACTION_NEEDED}")
# if(NOT TARGET "action-${ACTION_NEEDED}")
# message(STATUS "............................................................ action-${ACTION_NEEDED} not existing")
# endif()
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} action-${ACTION_NEEDED})
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)
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)
export_headers(${${EXTENSION_NAME_CMAKE}_HEADERS} COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} GROUP ${TYPE_EXTENSION}s)
endif()
# lib installation
......
......@@ -135,7 +135,7 @@ if(NOT ${CAMITK_INSTALL_ROOT} EQUAL "")
mark_as_advanced(CAMITK_BIN_DIR CAMITK_LIB_DIR CAMITK_INCLUDE_DIR CAMITK_TESTDATA_DIR)
# Needed due to installation reason
link_directories(${CAMITK_INSTALL_ROOT}/lib)
link_directories(${CAMITK_INSTALL_ROOT}/lib ${CEP_INSTALL_ROOT}/lib)
# update module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CAMITK_LIB_DIR}/cmake ${CAMITK_INSTALL_ROOT}/share/cmake ${CAMITK_INSTALL_ROOT}/share/${CAMITK_SHORT_VERSION_STRING}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/../camitk/cmake/modules)
......@@ -149,7 +149,7 @@ if(NOT ${CAMITK_INSTALL_ROOT} EQUAL "")
include(CamiTKExtensionPackaging)
# set install path
set (CMAKE_INSTALL_PREFIX ${CAMITK_INSTALL_ROOT} CACHE PATH "Path to install dir (deduced from CAMITK_INSTALL_ROOT)" FORCE)
set (CMAKE_INSTALL_PREFIX ${CEP_INSTALL_ROOT} CACHE PATH "Path to install dir (deduced from CEP_INSTALL_ROOT)" FORCE)
# check the following to define the proper output variables for an external extension
# during compilation, set where everything (lib, exe, shared) goes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment