Skip to content

Commit

Permalink
Merge pull request #591 from TriBITSPub/582-raw-cmake-as-tribits-package
Browse files Browse the repository at this point in the history
Allow 100% raw CMake to be used in a TriBITS-compliant package (#582)
  • Loading branch information
bartlettroscoe authored Sep 21, 2023
2 parents 8c1874c + c941426 commit 685c8d5
Show file tree
Hide file tree
Showing 64 changed files with 981 additions and 287 deletions.
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ check-filenames =
check-hidden =
# Disable warnings about binary files
quiet-level = 2
skip = */.git,*/common_tools/cloc,*/TriBITSDoc,*/tribits/doc/guides/rst2latex.tex
skip = */.git,*/common_tools/cloc,*/TriBITSDoc,*/tribits/doc/guides/rst2latex.tex,*/*.js,*/*.svg,*/tribits/doc/sphinx/*/index.html
ignore-words-list = thur,inout,te,nd,lod,aci,nin,nnumber,wile,reall,bu,somewhere
2 changes: 1 addition & 1 deletion test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tribits_add_advanced_test( TestingFunctionMacro_UnitTests
-D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR}
-P "${CMAKE_CURRENT_SOURCE_DIR}/TestingFunctionMacro_UnitTests.cmake"
PASS_REGULAR_EXPRESSION_ALL
"Final UnitTests Result: num_run = 721"
"Final UnitTests Result: num_run = 720"
"Final UnitTests Result: PASSED"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ set(${PROJECT_NAME}_TRACE_ADD_TEST TRUE)
set(${PROJECT_NAME}_TRIBITS_DIR ${TRIBITS_DIR})
set(PACKAGE_NAME ${PROJECT_NAME})
set(${PACKAGE_NAME}_ENABLE_TESTS TRUE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${TRIBITS_DIR}/core/utils
${TRIBITS_DIR}/core/package_arch )
list(PREPEND CMAKE_MODULE_PATH ${TRIBITS_DIR}/core/test_support)
include(TribitsAddAdvancedTest)
include(CTest)
enable_testing()
50 changes: 35 additions & 15 deletions test/core/ExamplesUnitTests/TribitsExampleApp2_Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,40 @@ endif()


function(TribitsExampleApp2 tribitsExProj2TestNameBaseBase
sharedOrStatic fullOrComponents
sharedOrStatic package1TribitsOrRawCMake fullOrComponents
)

if (sharedOrStatic STREQUAL "SHARED")
set(buildSharedLibsArg -DBUILD_SHARED_LIBS=ON)
elseif (sharedOrStatic STREQUAL "STATIC")
set(buildSharedLibsArg -DBUILD_SHARED_LIBS=OFF)
else()
message(FATAL_ERROR "Invalid value of buildSharedLibsArg='${buildSharedLibsArg}'!")
message(FATAL_ERROR "Invalid value of sharedOrStatic='${sharedOrStatic}'!")
endif()
set(tribitsExProj2Suffix "${sharedOrStatic}")

if ( (package1TribitsOrRawCMake STREQUAL "") OR
(package1TribitsOrRawCMake STREQUAL "PACKAGE1_USE_TRIBITS")
)
set(package1UseRawCMakeArgs "")
elseif (package1TribitsOrRawCMake STREQUAL "PACKAGE1_USE_RAW_CMAKE")
set(package1UseRawCMakeArgs "-D Package1_USE_RAW_CMAKE=TRUE")
string(APPEND tribitsExProj2Suffix "_${package1TribitsOrRawCMake}")
else()
message(FATAL_ERROR "package1UseRawCMakeArgs='${package1UseRawCMakeArgs}' Invalid!")
endif()


set(fullDepsRegex "Full Deps: Package3{Package2{Package1{tpl1}, Tpl3{Tpl2a{tpl1}, Tpl2b{no deps}}}, Package1{tpl1}, Tpl4{Tpl3{Tpl2a{tpl1}, Tpl2b{no deps}}, Tpl2a{tpl1}, Tpl2b{no deps}}, Tpl2a{tpl1}, Tpl2b{no deps}}")

if (fullOrComponents STREQUAL "FULL")
set(tribitsExProjUseComponentsArg "")
set(packageListRegex "TribitsExProj2_PACKAGE_LIST = Package3[;]Package2[;]Package1")
elseif (fullOrComponents STREQUAL "COMPONENTS")
set(tribitsExProjUseComponentsArg
-DTribitsExApp2_FIND_INDIVIDUAL_PACKAGES=ON
-DTribitsExApp2_USE_COMPONENTS="Package1,Package2,Package3")
set(packageListRegex "Found Package1;Found Package2;Found Package3")
else()
message(FATAL_ERROR "Invalid value of fullOrComponents='${fullOrComponents}'!")
endif()
Expand All @@ -113,7 +129,7 @@ function(TribitsExampleApp2 tribitsExProj2TestNameBaseBase
set(fullDepsRegex "Full Deps: Package3{Package1{tpl1}, Tpl2a{tpl1}, Tpl2b{no deps}}")
endif()

set(testSuffix ${sharedOrStatic}_${fullOrComponents})
set(testSuffix ${tribitsExProj2Suffix}_${fullOrComponents})
set(testBaseName
${CMAKE_CURRENT_FUNCTION}_${tribitsExProj2TestNameBaseBase}_${testSuffix})
set(testName ${PACKAGE_NAME}_${testBaseName})
Expand All @@ -129,11 +145,11 @@ function(TribitsExampleApp2 tribitsExProj2TestNameBaseBase
MESSAGE "Configure TribitsExampleApp2 locally against already installed TribitsExProject2"
WORKING_DIRECTORY app_build
CMND ${CMAKE_COMMAND} ARGS
-DCMAKE_PREFIX_PATH=${${tribitsExProj2TestNameBaseBase}_${sharedOrStatic}_INSTALL_DIR}
-DCMAKE_PREFIX_PATH=${${tribitsExProj2TestNameBaseBase}_${tribitsExProj2Suffix}_INSTALL_DIR}
${tribitsExProjUseComponentsArg}
${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleApp2
PASS_REGULAR_EXPRESSION_ALL
"TribitsExProj2_PACKAGE_LIST = Package3[;]Package2[;]Package1"
"${packageListRegex}"
"-- Configuring done"
"-- Generating done"
"-- Build files have been written to: .*/${testName}/app_build"
Expand Down Expand Up @@ -169,20 +185,24 @@ function(TribitsExampleApp2 tribitsExProj2TestNameBaseBase

if (${testNameBase}_NAME)
set_tests_properties(${${testNameBase}_NAME}
PROPERTIES DEPENDS ${${tribitsExProj2TestNameBaseBase}_${sharedOrStatic}_NAME} )
PROPERTIES DEPENDS ${${tribitsExProj2TestNameBaseBase}_${tribitsExProj2Suffix}_NAME}
)
endif()

endfunction()


TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts STATIC FULL)
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts STATIC "" FULL)
# NOTE: We don't need to test the permutation SHARED FULL as well. That does
# not really test anything new given that shared is tested with COMPONENTS.
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts STATIC COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts SHARED COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts_no_optional_packages_tpls STATIC COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts_no_optional_packages_tpls SHARED COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_explicit_tpl_vars STATIC COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_explicit_tpl_vars SHARED COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_package SHARED COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_package STATIC COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts STATIC "" COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts SHARED "" COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts_no_optional_packages_tpls STATIC "" COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_tpl_parts_no_optional_packages_tpls SHARED "" COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_explicit_tpl_vars STATIC "" COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_explicit_tpl_vars SHARED "" COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_package SHARED "" COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_package STATIC "" COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_package SHARED PACKAGE1_USE_RAW_CMAKE COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_package STATIC PACKAGE1_USE_RAW_CMAKE COMPONENTS)
TribitsExampleApp2(TribitsExampleProject2_find_package STATIC PACKAGE1_USE_RAW_CMAKE FULL)
Loading

0 comments on commit 685c8d5

Please sign in to comment.