Commit ddbad714 authored by saubatn's avatar saubatn
Browse files

ADD : prepare CMake structure for continuous integration.

ADD : macro to automatically compute Project.xml file when CMake look accross CamiTK projects.
           Project.xml file describes the Project CamiTK with its subprojects : CMake targets (libraries, exec) and their dependencies.
           This file is used by CDash to correctly handle the Project structure on the dashboard.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@203 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 85187429
......@@ -40,6 +40,9 @@ include(CamiTKPackaging)
# enables to specify which target to launch to MSVC
include(CreateLaunchers)
# Create the Xml data for Project.xml description, fyi store in the global variable CAMITK_XML_PROJECT_DESCRIPTION
initXmlSubProject()
add_subdirectory(tools)
add_subdirectory(core)
add_subdirectory(components)
......@@ -47,6 +50,13 @@ add_subdirectory(actions)
add_subdirectory(applications) # needs to be put at the end
add_subdirectory(cmake) # rules for cmake install
# Validate and write down the Project.xml file
# This file contains all the CamiTK project description with subprojects and their CMake target dependencies
# 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})
# 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)
......@@ -56,4 +66,4 @@ if ( MSVC )
application-imp
RUNTIME_LIBRARY_DIRS "%VTK_DIR%/bin/$(OutDir)" "%ITK_DIR%/bin/$(OutDir)"
)
endif( MSVC )
endif( MSVC )
\ No newline at end of file
......@@ -292,7 +292,7 @@ macro(component_extension)
foreach(COMPONENT_NEEDED ${${COMPONENT_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
string(TOUPPER ${COMPONENT_NEEDED} ${COMPONENT_NEEDED}_INTERNAL)
set(COMPONENT_${${COMPONENT_NEEDED}_INTERNAL} ON CACHE BOOL "Required by component extension ${COMPONENT_NAME}" FORCE )
set(COMPONENT_EXTENSION_LIBRARIES ${COMPONENT_EXTENSION_LIBRARIES} ${COMPONENT_NEEDED})
set(COMPONENT_EXTENSION_LIBRARIES ${COMPONENT_EXTENSION_LIBRARIES} component-${COMPONENT_NEEDED})
include_directories(${CAMITK_INCLUDE_DIR}/components/${COMPONENT_NEEDED})
endforeach()
endif()
......@@ -333,6 +333,10 @@ macro(component_extension)
# build the component extension module (library)
add_library(${COMPONENT_TARGET_NAME} SHARED ${${COMPONENT_NAME_CMAKE}_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(${COMPONENT_TARGET_NAME} ${CAMITK_CORE_LIB} ${${COMPONENT_EXTENSION_LIBRARIES}} ${TOOL_LIBRARIES})
# dependences to component and specific libraries
# A component has to be linked with ${CAMITK_CORE_LIB}. As CAMTIK_CORE_LIB is always a DLL/shared lib, there should
# be no symbol loaded multiple times
......@@ -610,19 +614,11 @@ macro(action_extension)
foreach(COMPONENT_NEEDED ${${ACTION_NAME_CMAKE}_NEEDS_COMPONENT_EXTENSION})
string(TOUPPER ${COMPONENT_NEEDED} ${COMPONENT_NEEDED}_INTERNAL)
set(COMPONENT_${${COMPONENT_NEEDED}_INTERNAL} ON CACHE BOOL "Required by action ${ACTION_NAME}" FORCE )
set(COMPONENT_EXTENSION_LIBRARIES ${COMPONENT_EXTENSION_LIBRARIES} ${COMPONENT_NEEDED})
set(COMPONENT_EXTENSION_LIBRARIES ${COMPONENT_EXTENSION_LIBRARIES} component-${COMPONENT_NEEDED})
include_directories(${CAMITK_INCLUDE_DIR}/components/${COMPONENT_NEEDED})
endforeach()
endif()
# check for intra-action extension
if(${ACTION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION)
foreach(ACTION_NEEDED ${${ACTION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
string(TOUPPER ${ACTION_NEEDED} ${ACTION_NEEDED}_INTERNAL)
set(ACTION_${${ACTION_NEEDED}_INTERNAL} ON CACHE BOOL "Required by action ${ACTION_NAME}" FORCE )
set(ACTION_EXTENSION_LIBRARIES ${ACTION_EXTENSION_LIBRARIES} ${ACTION_NEEDED})
include_directories(${CAMITK_INCLUDE_DIR}/actions/${ACTION_NEEDED})
endforeach()
endif()
set(ACTION_EXTENSION_LIBRARIES)
# check for intra-action extension
......@@ -630,7 +626,7 @@ macro(action_extension)
foreach(ACTION_NEEDED ${${ACTION_NAME_CMAKE}_NEEDS_ACTION_EXTENSION})
string(TOUPPER ${ACTION_NEEDED} ${ACTION_NEEDED}_INTERNAL)
set(ACTION_${${ACTION_NEEDED}_INTERNAL} ON CACHE BOOL "Required by action ${ACTION_NAME}" FORCE )
set(ACTION_EXTENSION_LIBRARIES ${ACTION_EXTENSION_LIBRARIES} ${ACTION_NEEDED})
set(ACTION_EXTENSION_LIBRARIES ${ACTION_EXTENSION_LIBRARIES} action-${ACTION_NEEDED})
include_directories(${CAMITK_INCLUDE_DIR}/actions/${ACTION_NEEDED})
endforeach()
endif()
......@@ -666,6 +662,10 @@ macro(action_extension)
# build the action extension module (library)
add_library(${ACTION_TARGET_NAME} SHARED ${${ACTION_NAME_CMAKE}_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(${ACTION_TARGET_NAME} ${CAMITK_CORE_LIB} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${TOOL_LIBRARIES})
# dependences to action and specific libraries
# An action has to be linked with ${CAMITK_CORE_LIB}. As CAMTIK_CORE_LIB is always a DLL/shared lib, there should
# be no symbol loaded multiple times
......@@ -829,6 +829,10 @@ 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} ${CAMITK_CORE_LIB} ${TOOL_LIBRARIES})
target_link_libraries(${APPLICATION_TARGET_NAME} ${CAMITK_LIBRARIES} ${CAMITK_CORE_LIB} ${TOOL_LIBRARIES} ${XERCESC_LIBRARY} )
# target properties
......@@ -962,5 +966,63 @@ macro(export_headers)
endmacro()
# MACRO initXmlSubProject
#
# Initialize the xml_subprojects variable to gather CamiTK subprojects
#
# usage:
# initXmlSubProject()
macro(initXmlSubProject)
set(CAMITK_XML_PROJECT_DESCRIPTION "<Project name=\"CamiTK\">" CACHE INTERNAL "")
endmacro()
# MACRO addSubProject
#
# 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
# DEPENDENCIES : (optional) the library dependencies to build the target
macro(addSubProject target)
# 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}\"/>")
endforeach()
set(xml_subproject ${xml_subproject} " </SubProject>")
# Please note that no "\n" character is used, avoiding cmake cache to throw an "Offending entry"
# At the moment I did not find a way to solve this one.
# Add it to the list of different nodes
set(CAMITK_XML_PROJECT_DESCRIPTION ${CAMITK_XML_PROJECT_DESCRIPTION} ${xml_subproject} CACHE INTERNAL "")
endmacro()
# MACRO validateXmlSubProjects
#
# 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
# Then create the 'dir'/Project.xml file
# Use this file to send to the DashBoard to get the CamiTK project and subprojects definition
#
# usage:
# validateXmlSubProjects(DIR)
# DIR: The path to the directory where to store the xml data file
macro(validateXmlSubProjects dir)
set(CAMITK_XML_PROJECT_DESCRIPTION ${CAMITK_XML_PROJECT_DESCRIPTION} "\n</Project>")
set(filename "${dir}/Project.xml")
file(WRITE ${filename} ${CAMITK_XML_PROJECT_DESCRIPTION})
message(STATUS "Generated: ${filename}")
endmacro()
# TODO write a viewer_extension macro in CamiTK
Supports Markdown
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