Skip to content

Missing dependencies for installation in BPMCreateInstallPackage  #3

Description

@QtlTobias

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
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions