Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 742eb858 authored by promayon's avatar promayon
Browse files

FIXED macro spring cleaning (including .cmake renaming), using INTERNAL wherever possible

FIXED macro compatibility for CEP build (automatically detect core build vs CEP in multi CEP build vs CEP independant build, no more CEP options needed )

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@702 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 5ba77c6c
......@@ -26,7 +26,7 @@ include(${VTK_USE_FILE})
# update module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CAMITK_SOURCE_DIR}/cmake/modules)
# include CamiTK Internal Build environment
include(CamiTKInternalBuild)
include(CamiTKCoreBuild)
# include CamiTK variables
include(CamiTKVariables)
# include CamiTK generic macros from CMAKE_MODULE_PATH directory
......@@ -43,7 +43,7 @@ include(CamiTKPackaging)
include(CreateLaunchers)
# Create the Xml data for Project.xml description, fyi store in the global variable CAMITK_XML_PROJECT_DESCRIPTION
initXmlSubProject()
camitk_sub_project_init()
# add all subprojects
add_subdirectory(cmake) # rules for cmake install
......@@ -58,15 +58,15 @@ add_subdirectory(tools)
# This file is needed for CDash to correctly update the Dashboard accordingly to the project
# Thus, CDash continuous integration dashboard is automatically updated when adding a new extension
# to CamiTK, using the corresponding macro
validateXmlSubProjects(${CAMITK_BUILD_DIR})
camitk_sub_project_validate(${CMAKE_BINARY_DIR})
# For Microsoft Visual C++, sets the default application to imp for the "ALL_BUILD" project
# (i.e. launches imp when we you click on "Debug" or "Start Without Debugging" button on Visual)
# In addition, but not the least, sets the environment to the debug dll directory for VTK (and ITK)
# to solve the dll incompatibility between debug and relase version of QVTK.dll and ITKCommon.dll
if ( MSVC )
create_default_target_launcher(
application-imp
RUNTIME_LIBRARY_DIRS "%VTK_DIR%/bin/$(OutDir)" "%ITK_DIR%/bin/$(OutDir)"
)
create_default_target_launcher(
application-imp
RUNTIME_LIBRARY_DIRS "%VTK_DIR%/bin/$(OutDir)" "%ITK_DIR%/bin/$(OutDir)"
)
endif( MSVC )
# This module is defining build variables
# Set the installation directory, i.e where "make install" puts everything
# you can set the CAMITK_INSTALL_ROOT environment variable, set the cmake variable directly by
# adding -DCAMITK_INSTALL_ROOT:PATH=your-path-here to the cmake command
# or you can set CAMITK_INSTALL_ROOT by hand when running cmake (it is in the cache)
#
# If nothing is specified (or CAMITK_INSTALL_ROOT is blank), the default behaviour is to
# install everything in the directory on top of the source directory
set(CAMITK_INSTALL_ROOT_TEST "$ENV{CAMITK_INSTALL_ROOT}")
if (NOT CAMITK_INSTALL_ROOT_TEST)
set(CAMITK_INSTALL_ROOT_TEST ${CAMITK_INSTALL_ROOT})
if (NOT CAMITK_INSTALL_ROOT_TEST)
if (CAMITK_SOURCE_DIR)
set(CAMITK_INSTALL_ROOT ${CAMITK_SOURCE_DIR}/.. CACHE PATH "CamiTK installation root dir" FORCE)
# else()
# set(CAMITK_INSTALL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. CACHE PATH "CamiTK installation root dir" FORCE)
endif()
endif()
set (CMAKE_INSTALL_PREFIX ${CAMITK_INSTALL_ROOT} CACHE PATH "CamiTK installation root dir" FORCE)
else()
set (CMAKE_INSTALL_PREFIX $ENV{CAMITK_INSTALL_ROOT} CACHE PATH "CamiTK installation root dir" FORCE)
endif()
message(STATUS "CamiTK Installation Directory: ${CMAKE_INSTALL_PREFIX}")
# during compilation, set where everything (lib, exe, shared) goes
set (CAMITK_BUILD_DIR ${CMAKE_BINARY_DIR})
set (CAMITK_BIN_DIR ${CAMITK_BUILD_DIR}/bin CACHE PATH "CamiTK bin dir." FORCE)
set (CAMITK_LIB_DIR ${CAMITK_BUILD_DIR}/lib CACHE PATH "CamiTK lib dir." FORCE)
set (CAMITK_INCLUDE_DIR ${CAMITK_BUILD_DIR}/include CACHE PATH "CamiTK include dir." FORCE)
set (CAMITK_TESTDATA_DIR ${CAMITK_BUILD_DIR}/share/testdata CACHE PATH "CamiTK share dir. for test data" FORCE)
# the "normal" user does not need to see this
mark_as_advanced(CAMITK_BIN_DIR CAMITK_LIB_DIR CAMITK_INCLUDE_DIR CAMITK_TESTDATA_DIR)
# Setup output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BIN_DIR} CACHE PATH "Single directory for all runtimes." FORCE)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CAMITK_BIN_DIR} CACHE PATH "Single directory for all dynamic/shared libs." FORCE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CAMITK_LIB_DIR} CACHE PATH "Single directory for all archives." FORCE)
# no need to see this
mark_as_advanced ( CMAKE_RUNTIME_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
# This module is only to be included when building CamiTK from source!
#
# It is to be included just BEFORE CamiTKVariables
#
# --------------------------
# Project Name and Version
# --------------------------
set(CAMITK_PROJECT_NAME "CamiTK")
# Version (major, minor, patch)
......@@ -41,5 +46,45 @@ endif()
message(STATUS "Welcome to ${CAMITK_VERSION_STRING}, enjoy your compilation!")
include(CamiTKBuild)
# --------------------------
# build variables
# --------------------------
# Set the installation directory, i.e where "make install" puts everything
# you can set the CAMITK_INSTALL_ROOT environment variable, set the cmake variable directly by
# adding -DCAMITK_INSTALL_ROOT:PATH=your-path-here to the cmake command
# or you can set CAMITK_INSTALL_ROOT by hand when running cmake (it is in the cache)
#
# If nothing is specified (or CAMITK_INSTALL_ROOT is blank), the default behaviour is to
# install everything in the directory on top of the source directory
set(CAMITK_INSTALL_ROOT_TEST "$ENV{CAMITK_INSTALL_ROOT}")
if (NOT CAMITK_INSTALL_ROOT_TEST)
set(CAMITK_INSTALL_ROOT_TEST ${CAMITK_INSTALL_ROOT})
if (NOT CAMITK_INSTALL_ROOT_TEST)
if (CAMITK_SOURCE_DIR)
set(CAMITK_INSTALL_ROOT ${CAMITK_SOURCE_DIR}/../install CACHE PATH "CamiTK installation root dir" FORCE)
endif()
endif()
set (CMAKE_INSTALL_PREFIX ${CAMITK_INSTALL_ROOT} CACHE PATH "CamiTK installation root dir" FORCE)
else()
set (CMAKE_INSTALL_PREFIX $ENV{CAMITK_INSTALL_ROOT} CACHE PATH "CamiTK installation root dir" FORCE)
endif()
message(STATUS "CamiTK Installation Directory: ${CMAKE_INSTALL_PREFIX}")
# during compilation, set where everything (lib, exe, shared) goes
set (CAMITK_BIN_DIR ${CMAKE_BINARY_DIR}/bin CACHE PATH "CamiTK build bin dir." FORCE)
set (CAMITK_LIB_DIR ${CMAKE_BINARY_DIR}/lib CACHE PATH "CamiTK build lib dir." FORCE)
set (CAMITK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include CACHE PATH "CamiTK build include dir." FORCE)
set (CAMITK_TESTDATA_DIR ${CMAKE_BINARY_DIR}/share/testdata CACHE PATH "CamiTK build share dir. for test data" FORCE)
# the "normal" user does not need to see this
mark_as_advanced(CAMITK_BIN_DIR CAMITK_LIB_DIR CAMITK_INCLUDE_DIR CAMITK_TESTDATA_DIR)
# Setup output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BIN_DIR} CACHE PATH "Single directory for all runtimes." FORCE)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CAMITK_BIN_DIR} CACHE PATH "Single directory for all dynamic/shared libs." FORCE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CAMITK_LIB_DIR} CACHE PATH "Single directory for all archives." FORCE)
# no need to see this
mark_as_advanced ( CMAKE_RUNTIME_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
......@@ -11,7 +11,6 @@
#! [NAME packageName]
#! [VENDOR vendorName]
#! [CONTACT contactName]
#! [APPLICATIONS appName1 appName2...]
#! )
#! \endcode
#!
......@@ -20,7 +19,12 @@
#! \param VENDOR (optional) Specify the vendor name (default is TIMC-IMAG)
#! \param CONTACT (optional) Specify the contact name (default is link to CamiTK website)
#! \param APPLICATIONS (optional) If you want to package some applications
#!
#! When configuring CMake, do not forget to set the CMAKE_INSTALL_PREFIX correctly (e.g., /usr on Linux)
#! It will always use the CamiTK install directory as install prefix (install where the core is already)
#!
#! To generate deb package add this to the cmake configuration line: -DCPACK_BINARY_DEB:BOOL=TRUE
#! To generate rpm package add this to the cmake configuration line: -DCPACK_BINARY_RPM:BOOL=TRUE
macro(camitk_cep_packaging)
# CEP Packaging only works for stand-alone CEP
......@@ -41,9 +45,9 @@ else()
endif()
string(TOLOWER ${PACKAGING_NAME} CPACK_PACKAGE_NAME)
set(CPACK_PACKAGE_VERSION_MAJOR ${CAMITK_VER_MAJ})
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH ${CAMITK_VER_PACKAGE_PAT})
string(TOLOWER "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CAMITK_VER_NICKNAME}-${LSB_DISTRIB}_${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_FILE_NAME)
set(CPACK_PACKAGE_VERSION_MINOR ${CAMITK_VER_MIN})
set(CPACK_PACKAGE_VERSION_PATCH "0")
string(TOLOWER "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${LSB_DISTRIB}_${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_FILE_NAME)
# contact information
if (CAMITK_CEP_PACKAGING_VENDOR)
......@@ -61,19 +65,17 @@ endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README")
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/COPYRIGHT")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYRIGHT")
endif()
# applications / executable
if(CAMITK_CEP_PACKAGING_APPLICATIONS)
set(EXECUTABLES_TO_PACKAGE)
foreach(APP_TO_PACKAGE ${CAMITK_CEP_PACKAGING_APPLICATIONS})
set(EXECUTABLES_TO_PACKAGE)
foreach(APPLICATION_TARGET_NAME ${CAMITK_APPLICATION_TARGETS})
# name and label are the same
set(EXECUTABLES_TO_PACKAGE ${EXECUTABLES_TO_PACKAGE} ${APP_TO_PACKAGE} ${APP_TO_PACKAGE})
endforeach()
set(CPACK_PACKAGE_EXECUTABLES ${EXECUTABLES_TO_PACKAGE})
endif()
set(EXECUTABLES_TO_PACKAGE ${EXECUTABLES_TO_PACKAGE} ${APPLICATION_TARGET_NAME} ${APPLICATION_TARGET_NAME})
endforeach()
set(CPACK_PACKAGE_EXECUTABLES ${EXECUTABLES_TO_PACKAGE})
# package description
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CAMITK_CEP_PACKAGING_DESCRIPTION})
......@@ -171,7 +173,7 @@ if (UNIX AND NOT WIN32)
# TODO Debian dependencies (see CamiTKPackaging.cmake)
if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
message("Packaging for ${LSB_DISTRIB} not supported yet.\nPlease set deps in cmake/darktable-packaging.cmake before packaging.")
message(STATUS "Packaging for ${LSB_DISTRIB} not supported yet.\nPlease set deps in cmake/darktable-packaging.cmake before packaging.")
endif()
endif()
......@@ -205,8 +207,8 @@ if(WIN32 AND NOT UNIX)
# MinGW compiler
if ("${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles")
# NSIS Windows installer
message(STATUS "Packaging nsis using ${MAKENSIS}")
message(STATUS "Packaging nsis using ${MAKENSIS} with MinGW compiler")
# Qt dependencies
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
##TODO use GetPrerequisites.cmake (i.e. find a better way to list dependencies)
##get_prerequisites() is not well enough documented to justify the time investement - EP May 2011
......@@ -386,15 +388,92 @@ if(APPLE)
set(MACOSX_BUNDLE_LONG_VERSION_STRING "Version ${PROJECT_VERSION}")
endif()
# -------------------------------------
# System and dependencies requirements
# -------------------------------------
include(InstallRequiredSystemLibraries)
# and here we go...
include(CPack)
# ----------------------------
# CamiTK's own package (.cep)
# ----------------------------
# TODO install a CEP in CamiTK
# TODO CamiTK Market Place
set(CEP_PACKAGING_DIR "${CMAKE_BINARY_DIR}/CamiTKExtensionPackage")
set(CEP_PACKAGE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.cep")
add_custom_target(camitk_extension_package
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/include" "${CEP_PACKAGING_DIR}/include/${CAMITK_SHORT_VERSION_STRING}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/lib" "${CEP_PACKAGING_DIR}/lib/${CAMITK_SHORT_VERSION_STRING}"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/share" "${CEP_PACKAGING_DIR}/share/${CAMITK_SHORT_VERSION_STRING}"
COMMAND ${CMAKE_COMMAND} -E tar cvz "${CMAKE_BINARY_DIR}/${CEP_PACKAGE_NAME}" "${CEP_PACKAGING_DIR}/"
COMMENT "Building ${CEP_PACKAGE_NAME}"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
# Init CEP package directory structure
add_custom_target(camitk_extension_package_init
# build first
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}
# clean CEP package structure
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CEP_PACKAGING_DIR}"
COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/${CEP_PACKAGE_NAME}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CEP_PACKAGING_DIR}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CEP_PACKAGING_DIR}/bin"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CEP_PACKAGING_DIR}/lib/${CAMITK_SHORT_VERSION_STRING}/actions"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CEP_PACKAGING_DIR}/lib/${CAMITK_SHORT_VERSION_STRING}/components"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CEP_PACKAGING_DIR}/share/${CAMITK_SHORT_VERSION_STRING}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CEP_PACKAGING_DIR}/include/${CAMITK_SHORT_VERSION_STRING}"
# We have no way to determine which files were
# produce by libs, therefore, we just remove everything we don't need
# 1. copy all bin to lib
# 2. move all actions to lib/${CAMITK_SHORT_VERSION_STRING} (see cep_packaging_actions)
# 3. move all components to lib/${CAMITK_SHORT_VERSION_STRING} (see cep_packaging_components)
# 4. remove all applications (see cep_packaging_${APPLICATION_TARGET_NAME} custom target)
# Step 1.
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/bin" "${CEP_PACKAGING_DIR}/lib"
COMMENT "Building CEP and packaging tools"
)
add_dependencies(camitk_extension_package camitk_extension_package_init)
# move all actions extension to lib/${CAMITK_SHORT_VERSION_STRING} subdir (see step 2. in camitk_extension_package_init)
if(CAMITK_ACTION_TARGETS)
add_custom_target(cep_packaging_actions
COMMAND ${CMAKE_COMMAND} -E rename "${CEP_PACKAGING_DIR}/lib/actions" "${CEP_PACKAGING_DIR}/lib/${CAMITK_SHORT_VERSION_STRING}/actions"
COMMENT "Packaging action extensions"
)
# cep_packaging_actions depends on camitk_extension_package_init...
add_dependencies(cep_packaging_actions camitk_extension_package_init)
# ...and we also need cep_packaging_actions to be done before camitk_extension_package
add_dependencies(camitk_extension_package cep_packaging_actions)
endif()
# move all components extension to lib/${CAMITK_SHORT_VERSION_STRING} subdir (see step 3. in camitk_extension_package_init)
if(CAMITK_COMPONENT_TARGETS)
add_custom_target(cep_packaging_components
COMMAND ${CMAKE_COMMAND} -E rename "${CEP_PACKAGING_DIR}/lib/components" "${CEP_PACKAGING_DIR}/lib/${CAMITK_SHORT_VERSION_STRING}/components"
COMMENT "Packaging component extensions"
)
add_dependencies(cep_packaging_components camitk_extension_package_init)
add_dependencies(camitk_extension_package cep_packaging_components)
endif()
# remove applications from libs (see step 4. in camitk_extension_package_init)
foreach(APPLICATION_TARGET_NAME ${CAMITK_APPLICATION_TARGETS})
string(REPLACE "application-" "" APPNAME ${APPLICATION_TARGET_NAME})
add_custom_target(cep_packaging_${APPLICATION_TARGET_NAME}
# remove the executable from lib
COMMAND ${CMAKE_COMMAND} -E copy ${CEP_PACKAGING_DIR}/lib/camitk-${APPNAME} ${CEP_PACKAGING_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E remove -f ${CEP_PACKAGING_DIR}/lib/camitk-${APPNAME}
COMMENT "Packaging ${APPLICATION_TARGET_NAME}"
)
add_dependencies(cep_packaging_${APPLICATION_TARGET_NAME} camitk_extension_package_init)
add_dependencies(camitk_extension_package cep_packaging_${APPLICATION_TARGET_NAME})
endforeach()
endif() # Standalone CEP
endmacro()
\ No newline at end of file
......@@ -136,21 +136,16 @@ endmacro()
#!
#! Duplicate headers installation:
#! - one is used at compiled time and puts everything in
#! ${CAMITK_BUILD_DIR}/include/${GroupName}/${ComponentName}/${SubdirName}
#! ${CMAKE_BINARY_DIR}/include/${GroupName}/${ComponentName}/${SubdirName}
#! - the other one is used at installation time and puts everything in
#! ${CAMITK_INSTALL_ROOT}/include/${GroupName}/${ComponentName}/${SubdirName}
#!
#! \note
#! if you use the CEP option, CMAKE_BINARY_DIR is used instead of CAMITK_BUILD_DIR
#! and CMAKE_INSTALL_PREFIX is used instead of CAMITK_INSTALL_ROOT
#!
#! ${CMAKE_INSTALL_PREFIX}/include/${GroupName}/${ComponentName}/${SubdirName}
#!
#! Usage:
#! \code
#! export_headers(HeaderFile1.h HeaderFile2.h ...
#! COMPONENT ComponentName
#! [GROUP GroupName]
#! [SUBDIRECTORY SubdirName]
#! [CEP]
#! )
#! \endcode
#!
......@@ -160,7 +155,6 @@ endmacro()
#! \param GROUP (optional) the name of the group this install should be using group will be
#! prepend to the component name.
#! \param SUBDIRECTORY (optional) subdirectory to use in ${CAMITK_INCLUDE_DIR}/include/${ComponentName}
#! \param CEP (optional) states that the files should installed CEP wise
#!
#! Example invocation:
#!
......@@ -178,22 +172,16 @@ macro(export_headers)
parse_arguments(EXPORT_HEADER
"COMPONENT;SUBDIRECTORY;GROUP;" # possible lists
"CEP" # possible options
"" # no possible options
${ARGN}
)
# special case for components: remove prefix for the destination directory
string(REGEX REPLACE "^component-|^action-" "" EXPORT_HEADER_DESTINATION ${EXPORT_HEADER_COMPONENT})
# Do things CEP wise
if(NOT EXPORT_HEADER_CEP)
set(EXPORT_HEADER_INCLUDE_DIR ${CAMITK_INCLUDE_DIR})
set(EXPORT_HEADER_INSTALL_ROOT ${CAMITK_INSTALL_ROOT})
else()
# this is a CEP
set(EXPORT_HEADER_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
set(EXPORT_HEADER_INSTALL_ROOT ${CMAKE_INSTALL_PREFIX})
endif()
# define where to install files
set(EXPORT_HEADER_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
set(EXPORT_HEADER_INSTALL_ROOT ${CMAKE_INSTALL_PREFIX})
# Check group
if(EXPORT_HEADER_GROUP)
......@@ -239,7 +227,7 @@ macro(export_headers)
# check if file name is relative or not
set(FILE_TO_COPY ${HEADER})
# copy after build, only if there was a change
# copy after build, only if there was a change
add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE_TO_COPY} ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_DESTINATION}/
......@@ -252,7 +240,7 @@ macro(export_headers)
# during installation, copy the files to install directory
install(FILES ${EXPORT_HEADER_DEFAULT_ARGS}
DESTINATION ${EXPORT_HEADER_INSTALL_ROOT}/include/${CAMITK_SHORT_VERSION_STRING}/${EXPORT_HEADER_DESTINATION}/
COMPONENT ${EXPORT_HEADER_COMPONENT}
COMPONENT ${EXPORT_HEADER_COMPONENT}
)
endmacro()
......@@ -346,7 +334,7 @@ macro(camitk_extension)
set(${EXTENSION_NAME_CMAKE}_DEFAULT_IS_SET ${${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}})
endif()
set(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE} ${${EXTENSION_NAME_CMAKE}_DEFAULT} CACHE BOOL "Build extension ${EXTENSION_NAME}")
set(CAMITK_${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_INTERNAL TRUE CACHE BOOL "Is variable ${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME} already created?")
set(CAMITK_${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_INTERNAL TRUE CACHE INTERNAL "Is variable ${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME} already created?")
mark_as_advanced(CAMITK_${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}_INTERNAL)
endif()
......@@ -530,7 +518,7 @@ macro(camitk_extension)
# Update XML Project description adding this target as a subproject of the main CamiTK project with
# its dependencies (in the CMake target point of view)
addSubProject(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_CORE_LIB} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${TOOL_LIBRARIES})
camitk_sub_project_add(${TYPE_EXTENSION_CMAKE} ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} DEPENDENCIES ${CAMITK_CORE_LIB} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${TOOL_LIBRARIES})
# Set the libraries required to link the target
# An component or action has to be linked with ${CAMITK_CORE_LIB} and with all its dependencies
......@@ -609,14 +597,14 @@ macro(camitk_extension)
COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
)
# testdata files installation
# testdata files installation
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/testdata)
# Check test data dir directory
if (NOT EXISTS ${CAMITK_TESTDATA_DIR})
if (NOT EXISTS ${CMAKE_BINARY_DIR}/share/testdata)
add_custom_command(TARGET ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_TESTDATA_DIR}
COMMENT "Creating build-time share directory for test data ${CAMITK_TESTDATA_DIR}"
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/share/testdata
COMMENT "Creating build-time share directory for test data ${CMAKE_BINARY_DIR}/share/testdata"
VERBATIM
)
endif()
......@@ -624,7 +612,7 @@ macro(camitk_extension)
# 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_TESTDATA_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory testdata ${CMAKE_BINARY_DIR}/share/testdata
COMMENT "Installing build-time test data for ${EXTENSION_NAME}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
......@@ -632,17 +620,17 @@ macro(camitk_extension)
# during installation, copy the files to install directory
set (TESTDATA_DEST_DIR)
if ( MSVC )
# Do NOT add ${CAMITK_SHORT_VERSION_STRING} to the testdata path for Win32 MSVC !
set (TESTDATA_DEST_DIR share/testdata)
else ()
set (TESTDATA_DEST_DIR share/${CAMITK_SHORT_VERSION_STRING}/testdata)
endif ()
set (TESTDATA_DEST_DIR)
if ( MSVC )
# Do NOT add ${CAMITK_SHORT_VERSION_STRING} to the testdata path for Win32 MSVC !
set (TESTDATA_DEST_DIR share/testdata)
else ()
set (TESTDATA_DEST_DIR share/${CAMITK_SHORT_VERSION_STRING}/testdata)
endif ()
install(DIRECTORY testdata/
#DESTINATION share/testdata
#DESTINATION share/testdata
#DESTINATION share/${CAMITK_SHORT_VERSION_STRING}/testdata
DESTINATION ${TESTDATA_DEST_DIR}
DESTINATION ${TESTDATA_DEST_DIR}
COMPONENT ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
PATTERN ".svn" EXCLUDE
PATTERN "*~" EXCLUDE
......@@ -794,7 +782,7 @@ macro(camitk_tool)
# Update XML Project description adding this target as a subproject of the main CamiTK project with
# its dependencies (in the CMake target point of view)
addSubProject(${LIBRARY_NAME})
camitk_sub_project_add(TOOL ${LIBRARY_NAME})
# 64bits and other platform with relocation needs -fPIC
include(TestCXXAcceptsFlag)
......@@ -858,7 +846,7 @@ macro(application_extension)
set(APPLICATION_${APPLICATION_NAME_CMAKE}_IS_SET ${APPLICATION_${APPLICATION_NAME_CMAKE}})
endif()
set(APPLICATION_${APPLICATION_NAME_CMAKE} ${APPLICATION_${APPLICATION_NAME_CMAKE}_IS_SET} CACHE BOOL "Build application ${APPLICATION_NAME}")
set(CAMITK_APPLICATION_${APPLICATION_NAME_CMAKE}_INTERNAL TRUE CACHE BOOL "Is variable APPLICATION_${APPLICATION_NAME} already created?")
set(CAMITK_APPLICATION_${APPLICATION_NAME_CMAKE}_INTERNAL TRUE CACHE INTERNAL "Is variable APPLICATION_${APPLICATION_NAME} already created?")
mark_as_advanced(CAMITK_APPLICATION_${APPLICATION_NAME_CMAKE}_INTERNAL)
endif()
......@@ -927,17 +915,17 @@ macro(application_extension)
message(STATUS "${APPLICATION_NAME}: xerces-c required because of XSD cxx, please set XERCESC_INCLUDE_DIR")
endif()
endif()
# Looking for required component that this application needs
set(COMPONENT_EXTENSION_LIBRARIES)
# Looking for required component that this application needs
set(COMPONENT_EXTENSION_LIBRARIES)
# check for intra-component extension
if(${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION)
foreach(COMPONENT_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
string(TOUPPER ${COMPONENT_NEEDED} ${COMPONENT_NEEDED}_INTERNAL)
set(COMPONENT_${${COMPONENT_NEEDED}_INTERNAL} ON CACHE BOOL "Required by application ${APPLICATION_NAME}" FORCE )
if(${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION)
foreach(COMPONENT_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
string(TOUPPER ${COMPONENT_NEEDED} ${COMPONENT_NEEDED}_INTERNAL)
set(COMPONENT_${${COMPONENT_NEEDED}_INTERNAL} ON CACHE BOOL "Required by application ${APPLICATION_NAME}" FORCE )
set(COMPONENT_EXTENSION_LIBRARIES ${COMPONENT_EXTENSION_LIBRARIES} component-${COMPONENT_NEEDED})
include_directories(${CAMITK_INCLUDE_DIR}/components/${COMPONENT_NEEDED})
endforeach()
include_directories(${CAMITK_INCLUDE_DIR}/components/${COMPONENT_NEEDED})
endforeach()
endif()
# set the directories where to seek for .h files at compilation time.
......@@ -957,9 +945,9 @@ macro(application_extension)
# add the executable target
add_executable(${APPLICATION_TARGET_NAME} ${${APPLICATION_NAME}_SOURCES})
# Update XML Project description adding this target as a subproject of the main CamiTK project with
# its dependencies (in the CMake target point of view)
addSubProject(${APPLICATION_TARGET_NAME} ${COMPONENT_EXTENSION_LIBRARIES} ${CAMITK_CORE_LIB} ${TOOL_LIBRARIES})
# Update XML Project description adding this target as a subproject of the main CamiTK project with
# its dependencies (in the CMake target point of view)
camitk_sub_project_add(APPLICATION ${APPLICATION_TARGET_NAME} DEPENDENCIES ${COMPONENT_EXTENSION_LIBRARIES} ${CAMITK_CORE_LIB} ${TOOL_LIBRARIES})
# target properties
set_target_properties(${APPLICATION_TARGET_NAME}
......@@ -972,56 +960,56 @@ macro(application_extension)
add_dependencies(${APPLICATION_TARGET_NAME} ${TOOL_NEEDED})
endforeach()
endif()
# Set the Component(s) dependency
if(${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION)
foreach(COMPONENT_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
# Set the Component(s) dependency
if(${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION)
foreach(COMPONENT_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
string(TOUPPER ${COMPONENT_NEEDED} COMPONENT_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_COMPONENT_${COMPONENT_NEEDED_CMAKE}_INTERNAL)
add_dependencies(${APPLICATION_TARGET_NAME} component-${COMPONENT_NEEDED})
add_dependencies(${APPLICATION_TARGET_NAME} component-${COMPONENT_NEEDED})
endif()
endforeach()
endforeach()
endif()
# Set the Action(s) dependency
set(ACTION_EXTENSION_LIBRARIES)
if(${APPLICATION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION)
foreach(ACTION_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
string(TOUPPER ${ACTION_NEEDED} ${ACTION_NEEDED}_INTERNAL)
set(ACTION_${${ACTION_NEEDED}_INTERNAL} ON CACHE BOOL "Required by application ${APPLICATION_NAME}" FORCE )
# Set the Action(s) dependency
set(ACTION_EXTENSION_LIBRARIES)
if(${APPLICATION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION)
foreach(ACTION_NEEDED ${${APPLICATION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
string(TOUPPER ${ACTION_NEEDED} ${ACTION_NEEDED}_INTERNAL)
set(ACTION_${${ACTION_NEEDED}_INTERNAL} ON CACHE BOOL "Required by application ${APPLICATION_NAME}" FORCE )
set(ACTION_EXTENSION_LIBRARIES ${ACTION_EXTENSION_LIBRARIES} action-${ACTION_NEEDED})
include_directories(${CAMITK_INCLUDE_DIR}/actions/${ACTION_NEEDED})
# if this is not true, then the dependencies is from an external build, do not use add_dependencies
endforeach()
include_directories(${CAMITK_INCLUDE_DIR}/actions/${ACTION_NEEDED})
# if this is not true, then the dependencies is from an external build, do not use add_dependencies
endforeach()
endif()
# dependences to core (only set for internal build)
if (CAMITK_INTERNAL_BUILD)
add_dependencies(${APPLICATION_TARGET_NAME} ${CAMITK_CORE_LIB})
add_dependencies(${APPLICATION_TARGET_NAME} ${CAMITK_CORE_LIB})
endif()
# Set the libraries needed to build the application target
# 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_LIB} ${TOOL_LIBRARIES} ${XERCESC_LIBRARY} ${ITK_LIBRARIES})
# installation
install(TARGETS ${APPLICATION_TARGET_NAME}
RUNTIME DESTINATION bin
COMPONENT ${APPLICATION_TARGET_NAME}
)
# For Microsoft Visual C++, sets the default application to the corresponding project
# (i.e. launches this application when we you click on "Debug" or "Start Without Debugging" button on Visual)
# In addition, but not the least, sets the environment to the debug dll directory for VTK (and ITK)
# to solve the dll incompatibility between debug and relase version of QVTK.dll and ITKCommon.dll
# Edit, don't know why, but macro does not work correctly inside application_extension()
if ( MSVC )
include(CreateLaunchers)
create_target_launcher(
${APPLICATION_TARGET_NAME}
RUNTIME_LIBRARY_DIRS "%VTK_DIR%/bin/$(OutDir)" "%ITK_DIR%/bin/$(OutDir)"
)
endif( MSVC )
# For Microsoft Visual C++, sets the default application to the corresponding project
# (i.e. launches this application when we you click on "Debug" or "Start Without Debugging" button on Visual)
# In addition, but not the least, sets the environment to the debug dll directory for VTK (and ITK)
# to solve the dll incompatibility between debug and relase version of QVTK.dll and ITKCommon.dll
# Edit, don't know why, but macro does not work correctly inside application_extension()
if ( MSVC )
include(CreateLaunchers)
create_target_launcher(
${APPLICATION_TARGET_NAME}
RUNTIME_LIBRARY_DIRS "%VTK_DIR%/bin/$(OutDir)" "%ITK_DIR%/bin/$(OutDir)"
)
endif( MSVC )