Commit 7a06f9cb authored by Emmanuel Promayon's avatar Emmanuel Promayon

Merge branch 'bug/library-header-install-dir' into 'develop'

FIXED library header installation

Closes #87

See merge request !121
parents 5ea35f6b 70e51439
......@@ -47,19 +47,22 @@ macro(export_headers)
# special case for components: remove prefix for the destination directory
string(REGEX REPLACE "^component-|^component_|^action-|^action_|^library_|^library-" "" EXPORT_HEADER_DESTINATION "${EXPORT_HEADER_COMPONENT}")
#
# 1. Create the build-time directory tree
#
# define where to install files
set(EXPORT_HEADER_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/${CAMITK_SHORT_VERSION_STRING})
set(EXPORT_HEADER_INSTALL_ROOT ${CMAKE_INSTALL_PREFIX})
# Check group
if(EXPORT_HEADER_GROUP)
# check directory
if (NOT EXISTS "${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}")
add_custom_command(TARGET ${EXPORT_HEADER_COMPONENT}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}
COMMENT "Creating build-time group include dir ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}"
VERBATIM
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}
COMMENT "Creating build-time group include dir ${EXPORT_HEADER_INCLUDE_DIR}/${EXPORT_HEADER_GROUP}"
VERBATIM
)
endif()
set(EXPORT_HEADER_DESTINATION ${EXPORT_HEADER_GROUP}/${EXPORT_HEADER_DESTINATION})
......@@ -89,6 +92,9 @@ macro(export_headers)
endif()
endif()
#
# 2. Install the file (build-time and install-time)
#
# at build time, copy the files to build directory include files when the target is built
foreach(HEADER ${EXPORT_HEADER_UNPARSED_ARGUMENTS})
......@@ -107,7 +113,6 @@ macro(export_headers)
# during installation, copy the files to install directory
install(FILES ${EXPORT_HEADER_UNPARSED_ARGUMENTS}
# DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${CAMITK_SHORT_VERSION_STRING}/${EXPORT_HEADER_DESTINATION}/
DESTINATION include/${CAMITK_SHORT_VERSION_STRING}/${EXPORT_HEADER_DESTINATION}/
COMPONENT ${EXPORT_HEADER_COMPONENT}
)
......
......@@ -71,7 +71,9 @@
#! The headers are installed ${CAMITK_BUILD_INCLUDE_DIR}/COMPONENT_NAME
#! 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!
#! making a list and using HEADERS_TO_INSTALL parameter instead.
#! Only the files matching the regex *.h will be install. If you need to add
#! other files, you need to use the HEADERS_TO_INSTALL option.
#! \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 communityedition.
......
......@@ -11,6 +11,9 @@
#!
#! This macro keeps header files directories tree structure at installation. In other words, if your extension
#! has its header files located in subdirectories, this tree structure will be kept the same at installation.
#!
#! Note that only file matching regex "*.h" in the source dir and subdir are considered headers.
#! If you need to add other files, you need to use the HEADERS_TO_INSTALL option.
#!
#! Usage:
#! \code
......@@ -46,9 +49,12 @@ macro(camitk_install_all_headers)
set(multiValueArgs "")
cmake_parse_arguments(CAMITK_INSTALL_ALL_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
#
# 1. Create the build-time directory tree
#
# The base include directories
set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CMAKE_BINARY_DIR}/include/${CAMITK_SHORT_VERSION_STRING})
set(CAMITK_INSTALL_ALL_HEADERS_INSTALL_RELATIVE_DIR include/${CAMITK_SHORT_VERSION_STRING})
# Get action, component or library name without its prefix
set(CAMITK_INSTALL_ALL_HEADERS_TARGET_NAME ${CAMITK_INSTALL_ALL_HEADERS_COMPONENT})
......@@ -67,7 +73,6 @@ macro(camitk_install_all_headers)
endif()
# Update base dirs
set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_GROUP})
set(CAMITK_INSTALL_ALL_HEADERS_INSTALL_RELATIVE_DIR ${CAMITK_INSTALL_ALL_HEADERS_INSTALL_RELATIVE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_GROUP})
endif()
# Create component directory if not already existing
......@@ -81,10 +86,15 @@ macro(camitk_install_all_headers)
endif()
# Update base dirs
set(CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR ${CAMITK_INSTALL_ALL_HEADERS_BUILD_BASE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT})
set(CAMITK_INSTALL_ALL_HEADERS_INSTALL_RELATIVE_DIR ${CAMITK_INSTALL_ALL_HEADERS_INSTALL_RELATIVE_DIR}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT})
# Build time installation
#
# 2. Install the file (build-time and install-time)
#
# get the list of headers
file(GLOB_RECURSE HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ *.h)
# Build time installation
foreach(HEADER ${HEADERS})
# Get the subdirectory name of the header
string(REGEX MATCH ".*/" SUBDIR ${HEADER})
......@@ -111,12 +121,14 @@ macro(camitk_install_all_headers)
endforeach()
# Install time, copy all the .h directories structure
install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMPONENT ${CAMITK_INSTALL_ALL_HEADERS_TARGET_NAME}
DESTINATION ${CAMITK_INSTALL_ALL_HEADERS_INSTALL_RELATIVE_DIR}
FILES_MATCHING
PATTERN "*.h"
)
foreach(HEADER ${HEADERS})
# Get the subdirectory name of the header
string(REGEX MATCH ".*/" SUBDIR ${HEADER})
install(FILES ${HEADER}
DESTINATION include/${CAMITK_SHORT_VERSION_STRING}/${CAMITK_INSTALL_ALL_HEADERS_GROUP}/${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}/${SUBDIR}
COMPONENT ${CAMITK_INSTALL_ALL_HEADERS_COMPONENT}
)
endforeach()
endmacro()
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