|
file(WRITE "${config_file_in}" "@PACKAGE_INIT@\n\ninclude(\"\${CMAKE_CURRENT_LIST_DIR}/${ARG_PACKAGE_NAME}Targets.cmake\")\n") |
Your BPMCreateInstallPackage currently writes a config file that only includes the targets file:
file(WRITE "${config_file_in}" "@PACKAGE_INIT@\n\ninclude(\"\${CMAKE_CURRENT_LIST_DIR}/${ARG_PACKAGE_NAME}Targets.cmake\")\n")
That means even after solving the export error, consumers may still fail later because httplib::httplib and glaze::glaze are not defined before ascomTargets.cmake is loaded.
Add a DEPENDENCIES argument to BPMCreateInstallPackage, and emit find_dependency(...) before including the targets file.
Minimal patch:
set(multiValueArgs
TARGETS
PUBLIC_INCLUDE_DIRS
HEADER_FILES_MATCHING
DEPENDENCIES
)
Then:
set(dependency_code "")
if(ARG_DEPENDENCIES)
string(APPEND dependency_code "include(CMakeFindDependencyMacro)\n")
foreach(dep IN LISTS ARG_DEPENDENCIES)
string(APPEND dependency_code "find_dependency(${dep})\n")
endforeach()
string(APPEND dependency_code "\n")
endif()
file(WRITE "${config_file_in}"
"@PACKAGE_INIT@
${dependency_code}
include(\"\${CMAKE_CURRENT_LIST_DIR}/${ARG_PACKAGE_NAME}Targets.cmake\")
")
Then call:
BPMCreateInstallPackage(
PACKAGE_NAME ascom
NAMESPACE ascom
TARGETS ascom
DEPENDENCIES httplib glaze
)
BPM.cmake/BPM.cmake
Line 2707 in e0a0776
Your BPMCreateInstallPackage currently writes a config file that only includes the targets file:
That means even after solving the export error, consumers may still fail later because httplib::httplib and glaze::glaze are not defined before ascomTargets.cmake is loaded.
Add a
DEPENDENCIESargument to BPMCreateInstallPackage, and emit find_dependency(...) before including the targets file.Minimal patch:
set(multiValueArgs TARGETS PUBLIC_INCLUDE_DIRS HEADER_FILES_MATCHING DEPENDENCIES )Then:
Then call: