From 8b730ed78e52b09ed57aaf59caa8571945f1f7ad Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 27 Jan 2023 16:24:11 -0700 Subject: [PATCH] Complete full implementation of pre-building/pre-installing stages of packages (#63) This commit should complete what is "Use Case 3: Configure/build pointing to a subset of already installed TriBITS packages in same repo." To complete this, this commit geneates wrapper Config.cmake files for TriBITS-compatible external packages. This provides the info needed for downstream internal TriBITS package's Config.camke files to get the upstream TriBITS-compatible external package. This commit makes the earlier test: TriBITS_TribitsExampleProject_External_Package_by_Package fully pass. However, we need to still add more tests, documentation and error checking but the initial functionality should be complete. --- .../TribitsProcessEnabledTpls.cmake | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tribits/core/package_arch/TribitsProcessEnabledTpls.cmake b/tribits/core/package_arch/TribitsProcessEnabledTpls.cmake index 303697bb8..03560a006 100644 --- a/tribits/core/package_arch/TribitsProcessEnabledTpls.cmake +++ b/tribits/core/package_arch/TribitsProcessEnabledTpls.cmake @@ -156,6 +156,9 @@ macro(tribits_process_enabled_tribits_compatible_tpl TPL_NAME) set(TPL_${TPL_NAME}_PARTS_ALREADY_SET FALSE) # ToDo: Take out? if (NOT TPL_${TPL_NAME}_PARTS_ALREADY_SET) find_package(${TPL_NAME} CONFIG REQUIRED) + tribits_write_tribits_compatible_external_package_config_file(${TPL_NAME}) + tribits_generate_tpl_version_file_and_add_package_config_install_targets( + ${TPL_NAME}) set(TPL_${TPL_NAME}_PARTS_ALREADY_SET TRUE) endif() endmacro() @@ -253,3 +256,28 @@ function(tribits_generate_tpl_version_file_and_add_package_config_install_target tribits_extpkg_install_config_version_file(${TPL_NAME} "${tplConfigVersionFile}") endfunction() + + +# Generate a Config.cmake wrapper file for a fully TriBITS-compliant +# external package and put it in the external_packages/ directory so it can be +# included like any external package/TPL. +# +function(tribits_write_tribits_compatible_external_package_config_file tplName) + # Create Config.cmake file + set(configFileStr "") + string(APPEND configFileStr + "include(CMakeFindDependencyMacro)\n" ) + if (${externalPkg}_DIR) + string(APPEND configFileStr + "set(${tplName}_DIR \"${${tplName}_DIR}\")\n" ) + endif() + string(APPEND configFileStr + "find_dependency(${tplName} CONFIG REQUIRED)\n" + ) + set(buildDirExternalPkgsDir + "${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}") + set(tplConfigFile + "${buildDirExternalPkgsDir}/${tplName}/${tplName}Config.cmake") + file(WRITE "${tplConfigFile}" "${configFileStr}") + +endfunction()