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,7 +58,7 @@ 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)
......
# 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,13 +136,9 @@ 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
......@@ -150,7 +146,6 @@ endmacro()
#! 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
# define where to install files
set(EXPORT_HEADER_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
set(EXPORT_HEADER_INSTALL_ROOT ${CMAKE_INSTALL_PREFIX})
endif()
# Check group
if(EXPORT_HEADER_GROUP)
......@@ -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
......@@ -612,11 +600,11 @@ macro(camitk_extension)
# 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
......@@ -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()
......@@ -959,7 +947,7 @@ macro(application_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(${APPLICATION_TARGET_NAME} ${COMPONENT_EXTENSION_LIBRARIES} ${CAMITK_CORE_LIB} ${TOOL_LIBRARIES})
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}
......@@ -1030,35 +1018,66 @@ endmacro()
# MACRO initXmlSubProject
# MACRO camitk_sub_project_init
#
# Initialize the xml_subprojects variable to gather CamiTK subprojects
#
# usage:
# initXmlSubProject()
macro(initXmlSubProject)
# camitk_sub_project_init()
macro(camitk_sub_project_init)
set(CAMITK_XML_PROJECT_DESCRIPTION "<Project name=\"CamiTK\">" CACHE INTERNAL "")
set(CAMITK_SUBPROJECTS "" CACHE INTERNAL "")
set(CAMITK_ACTION_TARGETS "" CACHE STRING "List of CamiTK action targets" FORCE)
set(CAMITK_COMPONENT_TARGETS "" CACHE STRING "List of CamiTK component targets" FORCE)
set(CAMITK_TOOL_TARGETS "" CACHE STRING "List of CamiTK tool targets" FORCE)
set(CAMITK_APPLICATION_TARGETS "" CACHE STRING "List of CamiTK application targets" FORCE)
endmacro()
# MACRO addSubProject
# MACRO camitk_sub_project_add
#
# Add a subproject definition from targets and its dependencies (if any) to the variable
# Typically recursively call this function accross all targets to generate Project.xml file.
#
# usage:
# addSubProject(TARGET
# DEPENDENCIES)
# TARGET : the library / exe program targeted for CMake compilation
# camitk_sub_project_add(ACTION|COMPONENT|TOOL|APPLICATION target name
# [DEPENDENCIES dep1 dep2 dep3]
#
# )
# TARGET_TYPE name : the library / exe program targeted for CMake compilation
# DEPENDENCIES : (optional) the library dependencies to build the target
macro(addSubProject target)
#
macro(camitk_sub_project_add)
parse_arguments(ADD_SUB_PROJECT
"ACTION;COMPONENT;TOOL;APPLICATION;CORELIB;DEPENDENCIES" # possible lists
"" #possible options
${ARGN}
)
# check types
if(ADD_SUB_PROJECT_ACTION)
set(SUB_PROJECT_NAME ${ADD_SUB_PROJECT_ACTION})
set(CAMITK_ACTION_TARGETS ${CAMITK_ACTION_TARGETS} ${SUB_PROJECT_NAME} CACHE STRING "List of CamiTK action targets" FORCE)
endif()
if(ADD_SUB_PROJECT_COMPONENT)
set(SUB_PROJECT_NAME ${ADD_SUB_PROJECT_COMPONENT})
set(CAMITK_COMPONENT_TARGETS ${CAMITK_COMPONENT_TARGETS} ${SUB_PROJECT_NAME} CACHE STRING "List of CamiTK component targets" FORCE)
endif()
if(ADD_SUB_PROJECT_TOOL)
set(SUB_PROJECT_NAME ${ADD_SUB_PROJECT_TOOL})
set(CAMITK_TOOL_TARGETS ${CAMITK_TOOL_TARGETS} ${SUB_PROJECT_NAME} CACHE STRING "List of CamiTK tool targets" FORCE)
endif()
if(ADD_SUB_PROJECT_APPLICATION)
set(SUB_PROJECT_NAME ${ADD_SUB_PROJECT_APPLICATION})
set(CAMITK_APPLICATION_TARGETS ${CAMITK_APPLICATION_TARGETS} ${SUB_PROJECT_NAME} CACHE STRING "List of CamiTK applications targets" FORCE)
endif()
if(ADD_SUB_PROJECT_CORELIB)
set(SUB_PROJECT_NAME ${ADD_SUB_PROJECT_CORELIB})
endif()
# Create the xml node for this current subproject
set(xml_subproject "\n <SubProject name=\"${target}\">")
foreach(dependency ${ARGN})
set(xml_subproject ${xml_subproject} "\n <Dependency name=\"${dependency}\"/>")
set(xml_subproject "\n <SubProject name=\"${SUB_PROJECT_NAME}\">")
foreach(DEPENDENCY ${ADD_SUB_PROJECT_DEPENDENCIES})
set(xml_subproject ${xml_subproject} "\n <Dependency name=\"${DEPENDENCY}\"/>")
endforeach()
set(xml_subproject ${xml_subproject} " </SubProject>")
# Please note that no "\n" character is used, avoiding cmake cache to throw an "Offending entry"
......@@ -1066,11 +1085,11 @@ macro(addSubProject target)
# Add it to the list of different nodes
set(CAMITK_XML_PROJECT_DESCRIPTION ${CAMITK_XML_PROJECT_DESCRIPTION} ${xml_subproject} CACHE INTERNAL "")
set(CAMITK_SUBPROJECTS ${CAMITK_SUBPROJECTS} ${target} CACHE INTERNAL "")
set(CAMITK_SUBPROJECTS ${CAMITK_SUBPROJECTS} ${SUB_PROJECT_NAME} CACHE INTERNAL "")
endmacro()
# MACRO validateXmlSubProjects
# MACRO camitk_sub_project_validate
#
# Validate the xml_subprojects variable by ending its xml tag
# i.e. By adding the closing </Project> xml node, this will close the xml data
......@@ -1078,9 +1097,9 @@ endmacro()
# Use this file to send to the DashBoard to get the CamiTK project and subprojects definition
#
# usage:
# validateXmlSubProjects(DIR)
# camitk_sub_project_validate(DIR)
# DIR: The path to the directory where to store the xml data file
macro(validateXmlSubProjects dir)
macro(camitk_sub_project_validate dir)
# Add apidoc subproject at the end
set(CAMITK_XML_PROJECT_DESCRIPTION ${CAMITK_XML_PROJECT_DESCRIPTION} "\n <SubProject name=\"apidoc\">\n </SubProject>")
......
......@@ -2,7 +2,7 @@
# CamiTK packaging
#------------------
# Do not forget to change the version variables in CamiTKBuild.cmake
# Do not forget to change the version variables in CamiTKInternalBuild.cmake
#
# To make a source tar ball, just use the custom target camitk_package_source, e.g. "make camitk_package_source"
#
......
......@@ -34,7 +34,7 @@ set(CAMITKCORE_LIBRARY_PROPERTIES ${CAMITKCORE_LIBRARY_PROPERTIES}
add_library(${CAMITK_CORE_LIB} SHARED ${${CAMITK_CORE_LIB}_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(${CAMITK_CORE_LIB})
camitk_sub_project_add(CORELIB ${CAMITK_CORE_LIB})
# set the library specific info (SONAME...)
set_target_properties(${CAMITK_CORE_LIB} PROPERTIES ${CAMITKCORE_LIBRARY_PROPERTIES} LINK_INTERFACE_LIBRARIES "")
......
......@@ -15,7 +15,7 @@ foreach(TOOL_NAME ${TOOLS_LIST})
message(STATUS "Checking ${TOOL_NAME}")
# add option to enable/disable this tool
set(TOOL_${TOOL_NAME_CMAKE} FALSE CACHE BOOL "Build tool ${TOOL_NAME}")
set(CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL TRUE CACHE BOOL "Is variable CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL already created?")
set(CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL TRUE CACHE INTERNAL "Is variable CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL already created?")
mark_as_advanced(CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL)
endif()
endforeach()
......
......@@ -43,7 +43,7 @@ if(NOT PML_TOOLS_INTERNAL)
message(STATUS "Checking for pml tools")
# add option to enable/disable this pml tools
set(PML_TOOLS FALSE CACHE BOOL "Build all pml tools")
set(PML_TOOLS_INTERNAL TRUE CACHE BOOL "Is PML_TOOLS already created?")
set(PML_TOOLS_INTERNAL TRUE CACHE INTERNAL "Is PML_TOOLS already created?")
mark_as_advanced(PML_TOOLS_INTERNAL)
endif()
......
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