Skip to content

Commit

Permalink
WIP: Add failing test for using raw CMake for Package1 in TriBITS pro…
Browse files Browse the repository at this point in the history
…ject (TriBITSPub#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.
  • Loading branch information
bartlettroscoe committed Jul 26, 2023
1 parent 5d6e826 commit ce9f7bd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
27 changes: 20 additions & 7 deletions test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}")

Expand All @@ -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
Expand Down Expand Up @@ -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)


########################################################################
Expand Down Expand Up @@ -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)



Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit ce9f7bd

Please sign in to comment.