Skip to content

Commit

Permalink
Use 'check_required_components' macro to check missing components
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Sep 21, 2015
1 parent 8d04c1c commit cf2ea1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
6 changes: 5 additions & 1 deletion Foo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ write_basic_package_version_file(
# Use variables:
# * targets_export_name
# * PROJECT_NAME
configure_file("cmake/Config.cmake.in" "${project_config}" @ONLY)
configure_package_config_file(
"cmake/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)

# Targets:
# * <prefix>/lib/libbar.a
Expand Down
16 changes: 2 additions & 14 deletions Foo/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
set(_package_components "${@PROJECT_NAME@_FIND_COMPONENTS}")
string(COMPARE NOTEQUAL "${_package_components}" "" _has_components)
if(_has_components)
set(_error_message "Package `@PROJECT_NAME@` has no components:")
foreach(x ${_package_components})
set(_error_message "${_error_message}\n ${x}")
endforeach()
set(
_error_message
"${_error_message}\nPlease check your `find_package` call."
)

message(FATAL_ERROR "${_error_message}")
endif()
@PACKAGE_INIT@

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

0 comments on commit cf2ea1d

Please sign in to comment.