From 80a9b1a57827f42f96eea17063df6c13dd92ff41 Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 14 Jul 2023 11:03:57 -0600 Subject: [PATCH] WIP: Add failing test for using raw CMake for Package1 in TriBITS project (#582) Now we can update TriBITS and the raw Package1 build system for it to work as a TriBITS package but without calling any TriBITS macros or functions. --- .../TribitsExampleProject2_Tests.cmake | 27 ++++++++++++++----- .../packages/package1/CMakeLists.txt | 10 ++++--- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake index b4be154f9..d80d6cc4e 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake @@ -541,10 +541,23 @@ TribitsExampleProject2_explicit_tpl_vars(SHARED) ######################################################################## -function(TribitsExampleProject2_find_package sharedOrStatic) +function(TribitsExampleProject2_find_package sharedOrStatic package1TribitsOrRawCMake) TribitsExampleProject2_test_setup_header() + if ( (package1TribitsOrRawCMake STREQUAL "") OR + (package1TribitsOrRawCMake STREQUAL "PACKAGE1_USE_TRIBITS") + ) + set(package1UseRawCMakeArgs "") + set(testNameSuffix "") + elseif (package1TribitsOrRawCMake STREQUAL "PACKAGE1_USE_RAW_CMAKE") + set(package1UseRawCMakeArgs "-D Package1_USE_RAW_CMAKE=TRUE") + set(testNameSuffix "_${package1TribitsOrRawCMake}") + else() + message(FATAL_ERROR "package1UseRawCMakeArgs='${package1UseRawCMakeArgs}' Invalid!") + endif() + print_var(package1UseRawCMakeArgs) + # Allow skipping delete of src and build dirs to aid in debugging if (TribitsExampleProject2_Tests_SKIP_DELETE_SRC_AND_BUILD) set(deleteSrcAndBuildDirsCmndArgs @@ -554,7 +567,7 @@ function(TribitsExampleProject2_find_package sharedOrStatic) CMND ${CMAKE_COMMAND} ARGS -E rm -rf TribitsExampleProject2 BUILD) endif() - set(testNameBase ${CMAKE_CURRENT_FUNCTION}_${sharedOrStatic}) + set(testNameBase ${CMAKE_CURRENT_FUNCTION}_${sharedOrStatic}${testNameSuffix}) set(testName ${PACKAGE_NAME}_${testNameBase}) set(testDir "${CMAKE_CURRENT_BINARY_DIR}/${testName}") @@ -579,6 +592,7 @@ function(TribitsExampleProject2_find_package sharedOrStatic) -DCMAKE_BUILD_TYPE=DEBUG -DTPL_ENABLE_Tpl3=ON -DTPL_ENABLE_Tpl4=ON + ${package1UseRawCMakeArgs} -DTribitsExProj2_ENABLE_ALL_PACKAGES=ON -DTribitsExProj2_ENABLE_TESTS=ON -DCMAKE_INSTALL_PREFIX=${testDir}/install @@ -658,8 +672,10 @@ function(TribitsExampleProject2_find_package sharedOrStatic) endfunction() -TribitsExampleProject2_find_package(STATIC) -TribitsExampleProject2_find_package(SHARED) +TribitsExampleProject2_find_package(STATIC "") +TribitsExampleProject2_find_package(SHARED "") +TribitsExampleProject2_find_package(STATIC PACKAGE1_USE_RAW_CMAKE) +TribitsExampleProject2_find_package(SHARED PACKAGE1_USE_RAW_CMAKE) ######################################################################## @@ -1359,6 +1375,3 @@ TribitsExampleProject2_External_RawPackage1_then_Package_by_Package(STATIC TPL_ TribitsExampleProject2_External_RawPackage1_then_Package_by_Package(SHARED TPL_LIBRARY_AND_INCLUDE_DIRS) TribitsExampleProject2_External_RawPackage1_then_Package_by_Package(STATIC CMAKE_PREFIX_PATH_CACHE) TribitsExampleProject2_External_RawPackage1_then_Package_by_Package(SHARED CMAKE_PREFIX_PATH_CACHE) - - - diff --git a/tribits/examples/TribitsExampleProject2/packages/package1/CMakeLists.txt b/tribits/examples/TribitsExampleProject2/packages/package1/CMakeLists.txt index 5f3b156eb..2344a4ef8 100644 --- a/tribits/examples/TribitsExampleProject2/packages/package1/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject2/packages/package1/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required(VERSION 3.23.0 FATAL_ERROR) macro(include_raw_cmake_build) - if (NOT COMMAND tribits_project) + if ((NOT COMMAND tribits_project) OR Package1_USE_RAW_CMAKE) include("${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.raw.cmake" NO_POLICY_SCOPE) return() endif() endmacro() -if (COMMAND tribits_package) +if ((COMMAND tribits_package) AND (NOT Package1_USE_RAW_CMAKE)) # Being processed as a TriBITS package tribits_package(Package1) @@ -18,7 +18,11 @@ if (COMMAND tribits_package) else() - message("Configuring raw CMake project Package1") + if (COMMAND tribits_package) + message("Configuring raw CMake package Package1") + else() + message("Configuring raw CMake project Package1") + endif() project(Package1 LANGUAGES C CXX) include(GNUInstallDirs) find_package(Tpl1 CONFIG REQUIRED)