Commit 62827ea5 authored by GILLES Sebastien's avatar GILLES Sebastien

#1220 [WIP] Making a config package work.

parent 77463ac1
......@@ -142,6 +142,7 @@ set(MOREFEM_INSTALL_DIR_LIB ${MOREFEM_INSTALL_DIR}/lib)
set(MOREFEM_INSTALL_DIR_INCL ${MOREFEM_INSTALL_DIR}/include)
set(MOREFEM_INSTALL_DIR_CMAKE ${MOREFEM_INSTALL_DIR}/cmake)
######################################################
# Settings to make shared library work correctly
######################################################
......
......@@ -72,18 +72,19 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ DESTINATION ${MOREFEM_INSTALL_DIR_I
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ DESTINATION ${MOREFEM_INSTALL_DIR_INCL}
FILES_MATCHING PATTERN "*.hxx")
message("CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS})
# TODO: also make the multiple lib case work!
# list(APPEND header_files "")
# extract_header_files(MoReFEM header_files)
list(APPEND header_files "")
extract_header_files(MoReFEM header_files ${CMAKE_CURRENT_LIST_DIR})
#message("HEAD" ${header_files})
#
# #### Lifted from Xtl
#
# add_library(morefem INTERFACE)
# # target_include_directories(xtl INTERFACE $<BUILD_INTERFACE:${XTL_INCLUDE_DIR}>
# # $<INSTALL_INTERFACE:include>)
add_library(morefem_cmake INTERFACE)
target_include_directories(morefem_cmake INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)
# #
#
#
......@@ -91,37 +92,44 @@ message("CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS})
# # ============
#
# #include(GNUInstallDirs)
# include(CMakePackageConfigHelpers)
#
# install(TARGETS morefem
# EXPORT ${PROJECT_NAME}-targets)
include(CMakePackageConfigHelpers)
#Alias
set(MoReFEM_CMAKE_INCLUDE_DIRS ${MOREFEM_INSTALL_DIR_INCL})
message("MoReFEM_CMAKE_INCLUDE_DIRS => " ${MoReFEM_CMAKE_INCLUDE_DIRS})
install(TARGETS morefem_cmake
EXPORT ${PROJECT_NAME}-targets)
#
# # Makes the project importable from the build directory
# export(EXPORT ${PROJECT_NAME}-targets
# FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
#
# # install(FILES ${XTL_HEADERS}
# # DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtl)
#
# # set(XTL_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE
# # STRING "install path for xtlConfig.cmake")
#
# configure_package_config_file(../cmake/${PROJECT_NAME}Config.cmake.in
# "${CMAKE_CURRENT_BINARY_DIR}/../cmake/${PROJECT_NAME}Config.cmake"
# INSTALL_DESTINATION ${MOREFEM_INSTALL_DIR_CMAKE})
#
# write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
# VERSION 1.0
# COMPATIBILITY AnyNewerVersion)
#
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
install(FILES ${header_files}
DESTINATION ${MOREFEM_INSTALL_DIR_INCL})
# set(XTL_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE
# STRING "install path for xtlConfig.cmake")
message("CHECK " ${CMAKE_CURRENT_BINARY_DIR})
configure_package_config_file(../cmake/${PROJECT_NAME}Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${MOREFEM_INSTALL_DIR_CMAKE})
#
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
# ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
# DESTINATION ${MOREFEM_INSTALL_DIR_CMAKE})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
DESTINATION ${MOREFEM_INSTALL_DIR_CMAKE})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../cmake/CustomCommands.cmake
DESTINATION ${MOREFEM_INSTALL_DIR_CMAKE})
#
# install(EXPORT ${PROJECT_NAME}-targets
# FILE ${PROJECT_NAME}Targets.cmake
# DESTINATION ${MOREFEM_INSTALL_DIR_CMAKE})
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION ${MOREFEM_INSTALL_DIR_CMAKE})
#
#
#
......@@ -124,18 +124,25 @@ endfunction()
# \param[in] _target The target for which header files are sought.
# \param[out] _list The list of header files found.
# ##########################################################################################
function(extract_header_files _target _list)
function(extract_header_files _target _list _include_dir)
get_property(sources TARGET ${_target} PROPERTY SOURCES)
list(APPEND ret "")
foreach(source in ${sources})
string(REGEX MATCH .h$ h ${source})
string(REGEX MATCH .hpp$ hpp ${source})
string(REGEX MATCH .hxx$ hxx ${source})
if(h OR hpp OR hxx)
list(APPEND ret ${source})
string(REPLACE ${_include_dir} "\${MOREFEM_INSTALL_DIR_INCL}" shorter_path ${source})
message("NCL " ${_include_dir})
message("SOURCE " ${source} " => " ${shorter_path})
list(APPEND ret ${shorter_path})
endif()
endforeach()
......
# morefem cmake module
# This module sets the following variables in your project::
#
# MoReFEM_CMAKE_FOUND - true if morefem found on the system
# MoReFEM_CMAKE_INCLUDE_DIRS - the directory containing morefem headers
# MoReFEM_CMAKE_LIBRARY - empty
@PACKAGE_INIT@
if(NOT TARGET @PROJECT_NAME@)
message("CMAKE ${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
get_target_property(@PROJECT_NAME@_INCLUDE_DIRS morefem_cmake INTERFACE_INCLUDE_DIRECTORIES)
message("INCL " ${@PROJECT_NAME@_INCLUDE_DIRS})
include("${CMAKE_CURRENT_LIST_DIR}/CustomCommands.cmake")
endif()
\ No newline at end of file
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