Skip to content

Commit

Permalink
Handle no-target case through a user information. (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier-stasse authored Jun 19, 2020
1 parent 272d644 commit f4863ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ IF(COMMAND ADD_REQUIRED_DEPENDENCY)
ENDFOREACH()
ENDIF(COMMAND ADD_REQUIRED_DEPENDENCY)

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
@INCLUDE_TARGETS_FILE@

foreach(component ${@PROJECT_NAME@_FIND_COMPONENTS})
set(comp_file "${CMAKE_CURRENT_LIST_DIR}/${component}Config.cmake")
Expand Down
7 changes: 7 additions & 0 deletions base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
# This tells jrl-cmakemodules that you are using export functionalities so it will
# hook the installation of your configuration files. Defaults to false
#
# .. variable:: PROJECT_EXPORT_NO_TARGET
#
# This tells jrl-cmakemodules that there is no targets in the project.
# However the export functionalities are still provided to detect the
# project properties. Not setting this variable when no target is present
# will result in an error.
#
# Macros
# ------
#
Expand Down
14 changes: 12 additions & 2 deletions package-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ if(_PKG_CONFIG_REQUIRES)
endforeach()
list(REMOVE_DUPLICATES _PKG_CONFIG_REQUIRES_LIST)
endif(_PKG_CONFIG_REQUIRES)

if(NOT PROJECT_EXPORT_NO_TARGET)
set(INCLUDE_TARGETS_FILE "include(\"\${CMAKE_CURRENT_LIST_DIR}/${TARGETS_EXPORT_NAME}.cmake\")")
else()
set(INCLUDE_TARGETS_FILE "# Package with no targets")
endif()

configure_package_config_file(
"cmake/Config.cmake.in"
"${PROJECT_CONFIG}"
Expand All @@ -170,11 +177,14 @@ install(

# Config
# * <prefix>/lib/cmake/Foo/FooTargets.cmake
install(
if(NOT PROJECT_EXPORT_NO_TARGET)
install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${CONFIG_INSTALL_DIR}"
)
)
endif()

ENDMACRO(SETUP_PROJECT_PACKAGE_FINALIZE)

#.rst:
Expand Down

0 comments on commit f4863ab

Please sign in to comment.