Merge pull request #324 from akva2/export_targets

added: add exported targets
This commit is contained in:
Atgeirr Flø Rasmussen 2018-02-14 09:16:24 +01:00 committed by GitHub
commit d501d183e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 9 deletions

View File

@ -20,10 +20,16 @@ macro (opm_install opm)
)
endforeach (_hdr)
install (
TARGETS ${${opm}_TARGET}
TARGETS ${${opm}_TARGET} ${${opm}_EXTRA_TARGETS}
EXPORT ${opm}-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
)
if(NOT "${${opm}_TARGET}" STREQUAL "")
export(TARGETS ${${opm}_TARGET} ${${opm}_EXTRA_TARGETS}
FILE ${opm}-targets.cmake)
install(EXPORT ${opm}-targets DESTINATION "share/cmake/${opm}")
endif()
# only /usr/lib/debug seems to be searched for debug info; if we have
# write access to that directory (package installation), then default
# to use it; otherwise put the debug files together with the library

View File

@ -270,10 +270,11 @@ if (COMMAND tests_hook)
endif (COMMAND tests_hook)
# make datafiles necessary for tests available in output directory
if (BUILD_TESTING)
opm_data (tests datafiles "${tests_DIR}")
opm_compile_satellites (${project} tests "" "${tests_REGEXP}")
endif (BUILD_TESTING)
opm_data (tests datafiles "${tests_DIR}")
if(NOT BUILD_TESTING)
set(excl_all EXCLUDE_FROM_ALL)
endif()
opm_compile_satellites (${project} tests "${excl_all}" "${tests_REGEXP}")
# use this target to check local git commits
add_custom_target(check-commits

View File

@ -95,6 +95,13 @@ function (opm_cmake_config name)
${PROJECT_SOURCE_DIR}
)
# The next replace will result in bogus entries if install directory is
# a subdirectory of source tree,
# and we have existing entries pointing to that install directory.
# Since they will yield a duplicate in next replace anyways, we filter them out first
# to get avoid those the bogus entries.
string(REPLACE "${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}" "" ${name}_INCLUDE_DIRS "${${name}_INCLUDE_DIRS}")
# replace the build directory with the target directory in the
# variables that contains build paths
string (REPLACE

View File

@ -82,11 +82,12 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp)
# variable with regular expression doubles as a flag for
# whether tests should be setup or not
set(_sat_FANCY)
if (NOT "${test_regexp}" STREQUAL "")
foreach (_regexp IN ITEMS ${test_regexp})
if ("${_sat_NAME}" MATCHES "${_regexp}")
string (REGEX REPLACE "${_regexp}" "\\1" _sat_FANCY "${_sat_NAME}")
else()
elseif(NOT _sat_FANCY)
set(_sat_FANCY ${_sat_NAME})
endif()
endforeach (_regexp)
@ -141,7 +142,7 @@ macro (opm_data satellite target dirname)
# even if there are no datafiles, create the directory so the
# satellite programs have a homedir to run in
execute_process (
COMMAND ${CMAKE_COMMAND} -E make_directory ${dirname}
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/${dirname}
)
# if ever huge test datafiles are necessary, then change this

View File

@ -42,8 +42,8 @@ if(NOT @opm-project_NAME@_FOUND)
# add the library as a target, so that other things in the project including
# this file may depend on it and get rebuild if this library changes.
if(NOT TARGET @opm-project_TARGET@)
add_library (@opm-project_TARGET@ UNKNOWN IMPORTED)
set_property (TARGET @opm-project_TARGET@ PROPERTY IMPORTED_LOCATION "${@opm-project_NAME@_LIBRARY}")
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${_dir}/@opm-project_NAME@-targets.cmake")
endif()
endif (NOT "@opm-project_TARGET@" STREQUAL "")