diff --git a/.github/workflows/tribits_testing.yml b/.github/workflows/tribits_testing.yml index 600a222a4..7f64e6e2c 100644 --- a/.github/workflows/tribits_testing.yml +++ b/.github/workflows/tribits_testing.yml @@ -93,6 +93,9 @@ jobs: - name: URL to results on CDash run: | cd .. - echo "Result on CDash are posted at:" + echo "See results posted on CDash:" + echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" echo - cat tribits-build/BUILD/CDashBuildUrl.txt + cat tribits-build/BUILD/CDashResults.txt + echo + echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 87446c066..8622e3bcf 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -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 = 695" + "Final UnitTests Result: num_run = 703" "Final UnitTests Result: PASSED" ) diff --git a/test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake index ab26db95d..37ddd7c47 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleApp_Tests.cmake @@ -526,7 +526,7 @@ TribitsExampleApp_EnableSingleSubpackage(FULL STATIC) ################################################################################ -function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic) +function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic serialOrMpi) if (byProjectOrPackage STREQUAL "ByProject") set(findByProjectOrPackageArg -DTribitsExApp_FIND_INDIVIDUAL_PACKAGES=OFF) @@ -535,12 +535,21 @@ function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic) set(findByProjectOrPackageArg -DTribitsExApp_FIND_INDIVIDUAL_PACKAGES=ON) set(foundProjectOrPackageStr "Found SimpleCxx") else() - message(FATAL_ERROR "Invalid value for findByProjectOrPackageArg='${findByProjectOrPackageArg}'!") + message(FATAL_ERROR + "Invalid value findByProjectOrPackageArg='${findByProjectOrPackageArg}'!") endif() TribitsExampleApp_process_sharedOrStatic_arg() - set(testBaseName ${CMAKE_CURRENT_FUNCTION}_${byProjectOrPackage}_${sharedOrStatic}) + if (serialOrMpi STREQUAL "SERIAL") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=OFF) + elseif (serialOrMpi STREQUAL "MPI") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=ON) + else() + message(FATAL_ERROR "Invalid value tplEnableMpiArg='${tplEnableMpiArg}'!") + endif() + + set(testBaseName ${CMAKE_CURRENT_FUNCTION}_${byProjectOrPackage}_${sharedOrStatic}_${serialOrMpi}) set(testName ${PACKAGE_NAME}_${testBaseName}) set(testDir ${CMAKE_CURRENT_BINARY_DIR}/${testName}) @@ -577,6 +586,7 @@ function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic) -DSimpleTpl_INCLUDE_DIRS=${SimpleTpl_install_${sharedOrStatic}_DIR}/install/include -DSimpleTpl_LIBRARY_DIRS=${SimpleTpl_install_${sharedOrStatic}_DIR}/install/lib ${buildSharedLibsArg} + ${tplEnableMpiArg} -DCMAKE_INSTALL_PREFIX=${testDir}/install ${testDir}/TribitsExampleProject @@ -641,10 +651,10 @@ function(TribitsExampleApp_ALL_ST byProjectOrPackage sharedOrStatic) endfunction() -TribitsExampleApp_ALL_ST(ByProject STATIC) -TribitsExampleApp_ALL_ST(ByProject SHARED) -TribitsExampleApp_ALL_ST(ByPackage STATIC) -TribitsExampleApp_ALL_ST(ByPackage SHARED) +TribitsExampleApp_ALL_ST(ByProject STATIC SERIAL) +TribitsExampleApp_ALL_ST(ByProject SHARED MPI) +TribitsExampleApp_ALL_ST(ByPackage STATIC MPI) +TribitsExampleApp_ALL_ST(ByPackage SHARED SERIAL) ################################################################################ diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake index bc51580a0..e51c87a7c 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject2_Tests.cmake @@ -208,12 +208,10 @@ function(TribitsExampleProject2_find_tpl_parts sharedOrStatic findingTplsMethod) "set[(]Package3_ENABLE_Package1 ON[)]" "set[(]Package3_ENABLE_Package2 ON[)]" "set[(]Package3_ENABLE_Tpl2 ON[)]" - "set[(]Package3_ENABLE_Tpl1 ON[)]" "set[(]Package3_ENABLE_Tpl4 ON[)]" - "set[(]Package3_ENABLE_Tpl3 ON[)]" TEST_2 - MESSAGE "Build verbose to check the link line of Package3" + MESSAGE "Build verbose to check the link lines" CMND ${CMAKE_COMMAND} ARGS --build . -v PASS_REGULAR_EXPRESSION_ALL "[-]o packages/package1/src/package1-prg .* ${tplInstallBaseDir}/install_tpl1/lib/libtpl1${libextregex}" @@ -253,9 +251,7 @@ function(TribitsExampleProject2_find_tpl_parts sharedOrStatic findingTplsMethod) "set[(]Package3_ENABLE_Package1 ON[)]" "set[(]Package3_ENABLE_Package2 ON[)]" "set[(]Package3_ENABLE_Tpl2 ON[)]" - "set[(]Package3_ENABLE_Tpl1 ON[)]" "set[(]Package3_ENABLE_Tpl4 ON[)]" - "set[(]Package3_ENABLE_Tpl3 ON[)]" ${ENV_PATH_HACK_FOR_TPL1_${sharedOrStatic}_ARG} @@ -345,9 +341,7 @@ function(TribitsExampleProject2_find_tpl_parts_no_optional_packages_tpls sharedO "set[(]Package3_ENABLE_Package1 ON[)]" "set[(]Package3_ENABLE_Package2 OFF[)]" "set[(]Package3_ENABLE_Tpl2 ON[)]" - "set[(]Package3_ENABLE_Tpl1 ON[)]" "set[(]Package3_ENABLE_Tpl4 OFF[)]" - "set[(]Package3_ENABLE_Tpl3 OFF[)]" TEST_2 MESSAGE "Build verbose to check the link line of Package3" @@ -378,9 +372,7 @@ function(TribitsExampleProject2_find_tpl_parts_no_optional_packages_tpls sharedO "set[(]Package3_ENABLE_Package1 ON[)]" "set[(]Package3_ENABLE_Package2 OFF[)]" "set[(]Package3_ENABLE_Tpl2 ON[)]" - "set[(]Package3_ENABLE_Tpl1 ON[)]" "set[(]Package3_ENABLE_Tpl4 OFF[)]" - "set[(]Package3_ENABLE_Tpl3 OFF[)]" ADDED_TEST_NAME_OUT ${testNameBase}_NAME ) diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 4dbcf5a5b..51b57fef4 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -66,369 +66,419 @@ set(LabelsForSubprojects_REGEX ######################################################################## -tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran - OVERALL_WORKING_DIRECTORY TEST_NAME - OVERALL_NUM_MPI_PROCS 1 - XHOSTTYPE Darwin - - TEST_0 - MESSAGE "Do the initial configure (and test a lot of things at once)" - CMND ${CMAKE_COMMAND} - ARGS - ${TribitsExampleProject_COMMON_CONFIG_ARGS} - -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} - -DTribitsExProj_ENABLE_Fortran=OFF - -DTribitsExProj_ENABLE_ALL_PACKAGES=ON - -DTribitsExProj_ENABLE_TESTS=ON - -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON - -DTribitsExProj_TRACE_FILE_PROCESSING=ON - -DTribitsExProj_ENABLE_CPACK_PACKAGING=ON - -DTribitsExProj_DUMP_CPACK_SOURCE_IGNORE_FILES=ON - -DTribitsExProj_DUMP_PACKAGE_DEPENDENCIES=ON - -DTribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES=ON - -DCMAKE_CXX_FLAGS=-DSIMPLECXX_SHOW_DEPRECATED_WARNINGS=1 - -DCMAKE_INSTALL_PREFIX=install - ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject - PASS_REGULAR_EXPRESSION_ALL - "Configuring TribitsExProj build directory" - "-- PROJECT_SOURCE_DIR=" - "-- PROJECT_BINARY_DIR=" - "-- TribitsExProj_TRIBITS_DIR=" - "-- TriBITS_VERSION_STRING=" - "-- CMAKE_VERSION=" - "-- CMAKE_HOST_SYSTEM_NAME=" - "-- TribitsExProj_HOSTNAME=" - - "NOTE: Setting TribitsExProj_ENABLE_WrapExternal=OFF because TribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES='ON'" - "NOTE: Setting TribitsExProj_ENABLE_MixedLang=OFF because TribitsExProj_ENABLE_Fortran" - "Printing package dependencies ..." - "-- TribitsExProj_PACKAGES: SimpleCxx MixedLang WithSubpackages WrapExternal" - "-- TribitsExProj_SE_PACKAGES: SimpleCxx MixedLang WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages WrapExternal" - - "-- SimpleCxx_LIB_REQUIRED_DEP_TPLS: HeaderOnlyTpl" - "-- MixedLang: No dependencies!" - "-- WithSubpackagesA_LIB_REQUIRED_DEP_PACKAGES: SimpleCxx" - "-- WithSubpackagesB_LIB_REQUIRED_DEP_PACKAGES: SimpleCxx" - "-- WithSubpackagesB_LIB_OPTIONAL_DEP_PACKAGES: WithSubpackagesA" - "-- WithSubpackagesB_TEST_OPTIONAL_DEP_PACKAGES: MixedLang" - "-- WithSubpackagesC_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA WithSubpackagesB" - "-- WithSubpackages_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA" - "-- WithSubpackages_LIB_OPTIONAL_DEP_PACKAGES: WithSubpackagesB WithSubpackagesC" - "-- WrapExternal_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA" - "-- WrapExternal_LIB_OPTIONAL_DEP_PACKAGES: MixedLang" - "-- SimpleCxx: No library dependencies!" - "-- WithSubpackagesA_FULL_ENABLED_DEP_PACKAGES: SimpleCxx" - "-- WithSubpackagesB_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesA SimpleCxx" - "-- WithSubpackagesC_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesB WithSubpackagesA SimpleCxx" - "-- WithSubpackages_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesC WithSubpackagesB WithSubpackagesA SimpleCxx" - "Explicitly enabled packages on input .by user.: 0" - "Explicitly disabled packages on input .by user or by default.: MixedLang WrapExternal 2" - "Enabling all SE packages that are not currently disabled because of TribitsExProj_ENABLE_ALL_PACKAGES=ON " - "Setting TribitsExProj_ENABLE_SimpleCxx=ON" - "Setting TribitsExProj_ENABLE_WithSubpackages=ON" - "Setting TPL_ENABLE_HeaderOnlyTpl=ON because it is required by the enabled package SimpleCxx" - "Set cache entries for optional packages/TPLs and tests/examples for packages actually enabled ..." - "Dumping direct dependencies for each SE package ..." - "-- SimpleCxx_LIB_ENABLED_DEPENDENCIES: HeaderOnlyTpl" - "-- SimpleCxx_LIB_ALL_DEPENDENCIES: HeaderOnlyTpl SimpleTpl" - "-- MixedLang_LIB_ALL_DEPENDENCIES: " - "-- WithSubpackagesA_LIB_ENABLED_DEPENDENCIES: SimpleCxx" - "-- WithSubpackagesA_LIB_ALL_DEPENDENCIES: SimpleCxx" - "-- WithSubpackagesB_LIB_ENABLED_DEPENDENCIES: SimpleCxx WithSubpackagesA" - "-- WithSubpackagesB_LIB_ALL_DEPENDENCIES: SimpleCxx WithSubpackagesA" - "-- WithSubpackagesB_TEST_ALL_DEPENDENCIES: MixedLang" - "-- WithSubpackagesC_LIB_ENABLED_DEPENDENCIES: WithSubpackagesA WithSubpackagesB" - "-- WithSubpackagesC_LIB_ALL_DEPENDENCIES: WithSubpackagesA WithSubpackagesB" - "-- WithSubpackages_LIB_ENABLED_DEPENDENCIES: WithSubpackagesA WithSubpackagesB WithSubpackagesC" - "-- WithSubpackages_LIB_ALL_DEPENDENCIES: WithSubpackagesA WithSubpackagesB WithSubpackagesC" - "-- WrapExternal_LIB_ALL_DEPENDENCIES: WithSubpackagesA MixedLang" - "Final set of enabled packages: SimpleCxx WithSubpackages 2" - "Final set of enabled SE packages: SimpleCxx WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages 5" - "Final set of enabled TPLs: ${FINAL_ENABLED_TPLS}" - "Final set of non-enabled packages: MixedLang WrapExternal 2" - "Processing enabled TPL: HeaderOnlyTpl" - "-- File Trace: TPL INCLUDE .+/TribitsExampleProject/cmake/tpls/FindTPLHeaderOnlyTpl.cmake" - "-- TPL_HeaderOnlyTpl_INCLUDE_DIRS='.+/examples/tpls/HeaderOnlyTpl'" - "Performing Test HAVE_SIMPLECXX___INT64" - "Configuring done" - "Generating done" - "Build files have been written to: .*ExamplesUnitTests/TriBITS_TribitsExampleProject_ALL_ST_NoFortran" - "-- File Trace: PROJECT INCLUDE .*/TribitsExampleProject/Version.cmake" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/cmake/CallbackSetupExtraOptions.cmake" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/PackagesList.cmake" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/TPLsList.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/mixed_lang/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/a/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/b/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/c/cmake/Dependencies.cmake" - "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/wrap_external/cmake/Dependencies.cmake" - "-- File Trace: PROJECT CONFIGURE .*/TribitsExampleProject/cmake/ctest/CTestCustom.cmake.in" - "-- File Trace: REPOSITORY READ .*/TribitsExampleProject/Copyright.txt" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/Version.cmake" - "${TPL_MPI_FILE_TRACE}" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/simple_cxx/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/simple_cxx/test/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/a/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/a/tests/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/b/tests/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/c/CMakeLists.txt" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/c/tests/CMakeLists.txt" - "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/cmake/CallbackDefineRepositoryPackaging.cmake" - "-- File Trace: PROJECT INCLUDE .*/TribitsExampleProject/cmake/CallbackDefineProjectPackaging.cmake" - ALWAYS_FAIL_ON_NONZERO_RETURN - - TEST_1 - MESSAGE "Make sure that 'LabelsForSubprojects' is set to list of packages" - CMND ${LabelsForSubprojects_CMND_AND_ARGS} - PASS_REGULAR_EXPRESSION "${LabelsForSubprojects_REGEX}" - - TEST_2 - MESSAGE "Build the default 'all' target using raw 'make'" - CMND make ARGS ${CTEST_BUILD_FLAGS} - PASS_REGULAR_EXPRESSION_ALL - "Built target simplecxx" - "${DEPRECATED_WARNING_1_STR}" - "${DEPRECATED_WARNING_2_STR}" - "Built target pws_a" - "Built target pws_b" - "Built target pws_c" - ALWAYS_FAIL_ON_NONZERO_RETURN +function(TribitsExampleProject_ALL_ST_NoFortran sharedOrStatic serialOrMpi) - TEST_3 - MESSAGE "Run all the tests with raw 'ctest'" - CMND ${CMAKE_CTEST_COMMAND} ARGS -VV - PASS_REGULAR_EXPRESSION_ALL - "SimpleCxx_HelloWorldTests${TEST_MPI_1_SUFFIX} .* Passed" - "WithSubpackagesA_test_of_a .* Passed" - "WithSubpackagesB_test_of_b .* Passed" - "WithSubpackagesC_test_of_c .* Passed" - "WithSubpackagesC_test_of_c_util.* Passed" - "100% tests passed, 0 tests failed out of 6" - ALWAYS_FAIL_ON_NONZERO_RETURN - - TEST_4 - MESSAGE "Create and configure a dummy project that includes" - " WithSubpackagesConfig.cmake from the build tree" - CMND ${CMAKE_COMMAND} - ARGS - -DDUMMY_PROJECT_NAME=DummyProject - -DDUMMY_PROJECT_DIR=dummy_client_of_build_WithSubpackages - -DEXPORT_VAR_PREFIX=WithSubpackages - -DEXPORT_CONFIG_FILE=../cmake_packages/WithSubpackages/WithSubpackagesConfig.cmake - -DCMAKE_COMMAND=${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake - PASS_REGULAR_EXPRESSION_ALL - "WithSubpackages_CMAKE_BUILD_TYPE = 'RELEASE'" - "WithSubpackages_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" - "WithSubpackages_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" - "WithSubpackages_Fortran_COMPILER = ''" - "WithSubpackages_FORTRAN_COMPILER = ''" - "WithSubpackages_CXX_FLAGS = '.*'" - "WithSubpackages_C_FLAGS = '.*'" - "WithSubpackages_Fortran_FLAGS = '.*'" - "WithSubpackages_EXTRA_LD_FLAGS = '.*'" - "WithSubpackages_SHARED_LIB_RPATH_COMMAND = '.*'" - "WithSubpackages_BUILD_SHARED_LIBS = '.*'" - "WithSubpackages_LINKER = '.+'" - "WithSubpackages_AR = '.+'" - "WithSubpackages_INSTALL_DIR = .*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install" - "WithSubpackages_INCLUDE_DIRS = .+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/b/src;.+/TribitsExampleProject/packages/with_subpackages/b/src;.+/TribitsExampleProject/packages/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/simple_cxx/src;.+/TribitsExampleProject/packages/simple_cxx/src;.+/tpls/HeaderOnlyTpl;.+/TribitsExampleProject/packages/with_subpackages/c" - "WithSubpackages_LIBRARY_DIRS = '.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/simple_cxx/src;.+/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/packages/with_subpackages/c'" - "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/tribits/examples/tpls/HeaderOnlyTpl'" - "WithSubpackages_TPL_LIBRARY_DIRS = ''" - "WithSubpackages_TPL_LIBRARIES = ''" - "WithSubpackages_MPI_LIBRARIES = ''" - "WithSubpackages_MPI_LIBRARY_DIRS = ''" - "WithSubpackages_MPI_INCLUDE_DIRS = ''" - "WithSubpackages_MPI_EXEC = '${MPI_EXEC}'" - "WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'" - "WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'" - "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" - "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" - "-- Configuring done" - "-- Generating done" - ALWAYS_FAIL_ON_NONZERO_RETURN - - TEST_5 - MESSAGE "Build 'install' target using raw 'make'" - CMND make ARGS install ${CTEST_BUILD_FLAGS} - PASS_REGULAR_EXPRESSION_ALL - "Install configuration: .RELEASE." - "Installing: .*/install/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfig.cmake" - "Installing: .*/install/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfigVersion.cmake" - "Installing: .+/install/include/TribitsExProj_version.h" - "Installing: .+/install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake" - "Installing: .+/install/lib/cmake/TribitsExProj/TribitsExProjConfigVersion.cmake" - "Installing: .+/install/include/TribitsExProjConfig.cmake" - "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxConfig.cmake" - "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxTargets.cmake" - "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxTargets-release.cmake" - "Installing: .+/install/lib/libsimplecxx.a" - "Installing: .+/install/include/SimpleCxx_HelloWorld.hpp" - "Installing: .+/install/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake" - "Installing: .+/install/lib/libpws_a.a" - "Installing: .+/install/include/A.hpp" - "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesAConfig.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesATargets.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesATargets-release.cmake" - "Installing: .+/install/lib/libpws_b.a" - "Installing: .+/install/include/B.hpp" - "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBConfig.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets-release.cmake" - "Installing: .+/install/lib/libpws_c.a" - "Installing: .+/install/include/wsp_c/C.hpp" - "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCConfig.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets.cmake" - "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets-release.cmake" - ALWAYS_FAIL_ON_NONZERO_RETURN - - TEST_6 - MESSAGE "Create and configure a dummy project that includes" - " WithSubpackagesConfig.cmake from the install tree" - CMND ${CMAKE_COMMAND} - ARGS - -DDUMMY_PROJECT_NAME=DummyProject - -DDUMMY_PROJECT_DIR=dummy_client_of_WithSubpackages - -DEXPORT_VAR_PREFIX=WithSubpackages - -DEXPORT_CONFIG_FILE=../install/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake - -DCMAKE_COMMAND=${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake - PASS_REGULAR_EXPRESSION_ALL - "WithSubpackages_CMAKE_BUILD_TYPE = 'RELEASE'" - "WithSubpackages_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" - "WithSubpackages_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" - "WithSubpackages_Fortran_COMPILER = ''" - "WithSubpackages_FORTRAN_COMPILER = ''" - "WithSubpackages_CXX_FLAGS = '.*'" - "WithSubpackages_C_FLAGS = '.*'" - "WithSubpackages_Fortran_FLAGS = '.*'" - "WithSubpackages_EXTRA_LD_FLAGS = '.*'" - "WithSubpackages_SHARED_LIB_RPATH_COMMAND = '.*'" - "WithSubpackages_BUILD_SHARED_LIBS = '.*'" - "WithSubpackages_LINKER = '.+'" - "WithSubpackages_AR = '.+'" - "WithSubpackages_INSTALL_DIR = '.+/install'" - "WithSubpackages_INCLUDE_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../include'" - "WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'" - "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/examples/tpls/HeaderOnlyTpl'" - "WithSubpackages_TPL_LIBRARY_DIRS = ''" - "WithSubpackages_TPL_LIBRARIES = ''" - "WithSubpackages_MPI_LIBRARIES = ''" - "WithSubpackages_MPI_LIBRARY_DIRS = ''" - "WithSubpackages_MPI_INCLUDE_DIRS = ''" - "WithSubpackages_MPI_EXEC = '${MPI_EXEC}'" - "WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'" - "WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'" - "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" - "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" - ALWAYS_FAIL_ON_NONZERO_RETURN + set(testBaseName ${CMAKE_CURRENT_FUNCTION}_${sharedOrStatic}_${serialOrMpi}) + set(testName ${PACKAGE_NAME}_${testBaseName}) - TEST_7 - MESSAGE "Create and configure a dummy project that includes" - " TribitsExProjConfig.cmake from the install tree" - CMND ${CMAKE_COMMAND} - ARGS - -DDUMMY_PROJECT_NAME=DummyProject - -DDUMMY_PROJECT_DIR=dummy_client_of_TribitsExProj - -DEXPORT_VAR_PREFIX=TribitsExProj - -DEXPORT_CONFIG_FILE=../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake - -DCMAKE_COMMAND=${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake - PASS_REGULAR_EXPRESSION_ALL - "DUMMY_PROJECT_NAME = 'DummyProject'" - "DUMMY_PROJECT_DIR = 'dummy_client_of_TribitsExProj'" - "EXPORT_CONFIG_FILE = '../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" - "EXPORT_VAR_PREFIX = 'TribitsExProj'" - "CMAKE_COMMAND = '${CMAKE_COMMAND}" - "Create the dummy client directory ..." - "Create dummy dummy_client_of_TribitsExProj/CMakeLists.txt file ..." - "Configure the dummy project to print the variables in .*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/dummy_client_of_TribitsExProj ..." - "DUMMY_PROJECT_NAME = 'DummyProject'" - "EXPORT_CONFIG_FILE = '../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" - "EXPORT_VAR_PREFIX = 'TribitsExProj'" - "Including file '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/dummy_client_of_TribitsExProj/../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" - "TribitsExProj_CMAKE_BUILD_TYPE = 'RELEASE'" - "TribitsExProj_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" - "TribitsExProj_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" - "TribitsExProj_Fortran_COMPILER = ''" - "TribitsExProj_FORTRAN_COMPILER = ''" - "TribitsExProj_CXX_FLAGS = ''" - "TribitsExProj_C_FLAGS = ''" - "TribitsExProj_Fortran_FLAGS = ''" - "TribitsExProj_EXTRA_LD_FLAGS = ''" - "TribitsExProj_SHARED_LIB_RPATH_COMMAND = ''" - "TribitsExProj_BUILD_SHARED_LIBS = 'FALSE'" - "TribitsExProj_LINKER = '.*'" - "TribitsExProj_AR = '.*'" - "TribitsExProj_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install'" - "TribitsExProj_INCLUDE_DIRS = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install/include'" - "TribitsExProj_LIBRARY_DIRS = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/install/lib'" - "TribitsExProj_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "TribitsExProj_TPL_INCLUDE_DIRS = '.*/examples/tpls/HeaderOnlyTpl" - "TribitsExProj_TPL_LIBRARY_DIRS = ''" - "TribitsExProj_TPL_LIBRARIES = ''" - "TribitsExProj_MPI_LIBRARIES = ''" - "TribitsExProj_MPI_LIBRARY_DIRS = ''" - "TribitsExProj_MPI_INCLUDE_DIRS = ''" - "TribitsExProj_MPI_EXEC = '.*'" - "TribitsExProj_MPI_EXEC_MAX_NUMPROCS = '[1-9]*'" # Is null for an MPI build - "TribitsExProj_MPI_EXEC_NUMPROCS_FLAG = '.*'" - "TribitsExProj_PACKAGE_LIST = 'WithSubpackages[;]WithSubpackagesC[;]WithSubpackagesB[;]WithSubpackagesA[;]SimpleCxx'" - "TribitsExProj_TPL_LIST = 'HeaderOnlyTpl" # Must work for no MPI too - "-- Configuring done" - "-- Generating done" - ALWAYS_FAIL_ON_NONZERO_RETURN + if (sharedOrStatic STREQUAL "SHARED") + set(BUILD_SHARED_LIBS_VAL ON) + set(libExtRegex "[.]so[.].*") + elseif (sharedOrStatic STREQUAL "STATIC") + set(BUILD_SHARED_LIBS_VAL OFF) + set(libExtRegex "[.]a") + else() + message(FATAL_ERROR "Invalid value sharedOrStatic='${sharedOrStatic}'!") + endif() - # ToDo: Add test for the components parts of Config.cmake ... + if (serialOrMpi STREQUAL "SERIAL") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=OFF) + set(TPL_MPI_FILE_TRACE "") + set(FINAL_ENABLED_TPLS "HeaderOnlyTpl 1") + set(TEST_MPI_1_SUFFIX "") + set(WithSubpackages_TPL_LIBRARIES HeaderOnlyTpl::all_libs) + set(WithSubpackages_TPL_LIST HeaderOnlyTpl) + set(TribitsExProj_TPL_LIBRARIES HeaderOnlyTpl::all_libs) + set(TribitsExProj_TPL_LIST HeaderOnlyTpl) + set(TribitsExProj_SHARED_LIB_RPATH_COMMAND_REGEX "") + elseif (serialOrMpi STREQUAL "MPI") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=ON) + set(TPL_MPI_FILE_TRACE + "-- File Trace: TPL INCLUDE .*/core/std_tpls/FindTPLMPI.cmake") + set(FINAL_ENABLED_TPLS "MPI HeaderOnlyTpl 2") + set(TEST_MPI_1_SUFFIX "_MPI_1") + set(WithSubpackages_TPL_LIBRARIES "HeaderOnlyTpl::all_libs;MPI::all_libs") + set(WithSubpackages_TPL_LIST "HeaderOnlyTpl;MPI") + set(TribitsExProj_TPL_LIBRARIES "HeaderOnlyTpl::all_libs;MPI::all_libs") + set(TribitsExProj_TPL_LIST "HeaderOnlyTpl;MPI") + set(TribitsExProj_SHARED_LIB_RPATH_COMMAND_REGEX + "-Wl,-rpath,.*/${testName}/install/lib") + else() + message(FATAL_ERROR "Invalid value tplEnableMpiArg='${tplEnableMpiArg}'!") + endif() - # ToDo: Add test that actually builds a C++ project and links to these libs - # to make sure this works! + tribits_add_advanced_test( ${testBaseName} + OVERALL_WORKING_DIRECTORY TEST_NAME + OVERALL_NUM_MPI_PROCS 1 + XHOSTTYPE Darwin - TEST_8 - MESSAGE "Create the tarball" - CMND make ARGS package_source - PASS_REGULAR_EXPRESSION_ALL - "Run CPack packaging tool for source..." - "CPack: Create package using TGZ" - "CPack: Install projects" - "CPack: - Install directory: .*/examples/TribitsExampleProject" - "CPack: Create package" - "CPack: - package: .*/ExamplesUnitTests/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/tribitsexproj-1.1-Source.tar.gz generated." - "CPack: Create package using TBZ2" - "CPack: Install projects" - "CPack: - Install directory: .*/examples/TribitsExampleProject" - "CPack: Create package" - "CPack: - package: .*/ExamplesUnitTests/TriBITS_TribitsExampleProject_ALL_ST_NoFortran/tribitsexproj-1.1-Source.tar.bz2 generated." - ALWAYS_FAIL_ON_NONZERO_RETURN + TEST_0 + MESSAGE "Do the initial configure (and test a lot of things at once)" + CMND ${CMAKE_COMMAND} + ARGS + ${TribitsExampleProject_COMMON_CONFIG_ARGS} + -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS_VAL} + ${tplEnableMpiArg} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DTribitsExProj_ENABLE_Fortran=OFF + -DTribitsExProj_ENABLE_ALL_PACKAGES=ON + -DTribitsExProj_ENABLE_TESTS=ON + -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON + -DTribitsExProj_TRACE_FILE_PROCESSING=ON + -DTribitsExProj_ENABLE_CPACK_PACKAGING=ON + -DTribitsExProj_DUMP_CPACK_SOURCE_IGNORE_FILES=ON + -DTribitsExProj_DUMP_PACKAGE_DEPENDENCIES=ON + -DTribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES=ON + -DCMAKE_CXX_FLAGS=-DSIMPLECXX_SHOW_DEPRECATED_WARNINGS=1 + -DCMAKE_INSTALL_PREFIX=install + ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject + PASS_REGULAR_EXPRESSION_ALL + "Configuring TribitsExProj build directory" + "-- PROJECT_SOURCE_DIR=" + "-- PROJECT_BINARY_DIR=" + "-- TribitsExProj_TRIBITS_DIR=" + "-- TriBITS_VERSION_STRING=" + "-- CMAKE_VERSION=" + "-- CMAKE_HOST_SYSTEM_NAME=" + "-- TribitsExProj_HOSTNAME=" + + "NOTE: Setting TribitsExProj_ENABLE_WrapExternal=OFF because TribitsExProj_ENABLE_INSTALL_CMAKE_CONFIG_FILES='ON'" + "NOTE: Setting TribitsExProj_ENABLE_MixedLang=OFF because TribitsExProj_ENABLE_Fortran" + "Printing package dependencies ..." + "-- TribitsExProj_PACKAGES: SimpleCxx MixedLang WithSubpackages WrapExternal" + "-- TribitsExProj_SE_PACKAGES: SimpleCxx MixedLang WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages WrapExternal" + + "-- SimpleCxx_LIB_REQUIRED_DEP_TPLS: HeaderOnlyTpl" + "-- MixedLang: No dependencies!" + "-- WithSubpackagesA_LIB_REQUIRED_DEP_PACKAGES: SimpleCxx" + "-- WithSubpackagesB_LIB_REQUIRED_DEP_PACKAGES: SimpleCxx" + "-- WithSubpackagesB_LIB_OPTIONAL_DEP_PACKAGES: WithSubpackagesA" + "-- WithSubpackagesB_TEST_OPTIONAL_DEP_PACKAGES: MixedLang" + "-- WithSubpackagesC_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA WithSubpackagesB" + "-- WithSubpackages_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA" + "-- WithSubpackages_LIB_OPTIONAL_DEP_PACKAGES: WithSubpackagesB WithSubpackagesC" + "-- WrapExternal_LIB_REQUIRED_DEP_PACKAGES: WithSubpackagesA" + "-- WrapExternal_LIB_OPTIONAL_DEP_PACKAGES: MixedLang" + "-- SimpleCxx: No library dependencies!" + "-- WithSubpackagesA_FULL_ENABLED_DEP_PACKAGES: SimpleCxx" + "-- WithSubpackagesB_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesA SimpleCxx" + "-- WithSubpackagesC_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesB WithSubpackagesA SimpleCxx" + "-- WithSubpackages_FULL_ENABLED_DEP_PACKAGES: WithSubpackagesC WithSubpackagesB WithSubpackagesA SimpleCxx" + "Explicitly enabled packages on input .by user.: 0" + "Explicitly disabled packages on input .by user or by default.: MixedLang WrapExternal 2" + "Enabling all SE packages that are not currently disabled because of TribitsExProj_ENABLE_ALL_PACKAGES=ON " + "Setting TribitsExProj_ENABLE_SimpleCxx=ON" + "Setting TribitsExProj_ENABLE_WithSubpackages=ON" + "Setting TPL_ENABLE_HeaderOnlyTpl=ON because it is required by the enabled package SimpleCxx" + "Set cache entries for optional packages/TPLs and tests/examples for packages actually enabled ..." + "Dumping direct dependencies for each SE package ..." + "-- SimpleCxx_LIB_ENABLED_DEPENDENCIES: HeaderOnlyTpl" + "-- SimpleCxx_LIB_ALL_DEPENDENCIES: HeaderOnlyTpl SimpleTpl" + "-- MixedLang_LIB_ALL_DEPENDENCIES: " + "-- WithSubpackagesA_LIB_ENABLED_DEPENDENCIES: SimpleCxx" + "-- WithSubpackagesA_LIB_ALL_DEPENDENCIES: SimpleCxx" + "-- WithSubpackagesB_LIB_ENABLED_DEPENDENCIES: SimpleCxx WithSubpackagesA" + "-- WithSubpackagesB_LIB_ALL_DEPENDENCIES: SimpleCxx WithSubpackagesA" + "-- WithSubpackagesB_TEST_ALL_DEPENDENCIES: MixedLang" + "-- WithSubpackagesC_LIB_ENABLED_DEPENDENCIES: WithSubpackagesA WithSubpackagesB" + "-- WithSubpackagesC_LIB_ALL_DEPENDENCIES: WithSubpackagesA WithSubpackagesB" + "-- WithSubpackages_LIB_ENABLED_DEPENDENCIES: WithSubpackagesA WithSubpackagesB WithSubpackagesC" + "-- WithSubpackages_LIB_ALL_DEPENDENCIES: WithSubpackagesA WithSubpackagesB WithSubpackagesC" + "-- WrapExternal_LIB_ALL_DEPENDENCIES: WithSubpackagesA MixedLang" + "Final set of enabled packages: SimpleCxx WithSubpackages 2" + "Final set of enabled SE packages: SimpleCxx WithSubpackagesA WithSubpackagesB WithSubpackagesC WithSubpackages 5" + "Final set of enabled TPLs: ${FINAL_ENABLED_TPLS}" + "Final set of non-enabled packages: MixedLang WrapExternal 2" + "Processing enabled TPL: HeaderOnlyTpl" + "-- File Trace: TPL INCLUDE .+/TribitsExampleProject/cmake/tpls/FindTPLHeaderOnlyTpl.cmake" + "-- TPL_HeaderOnlyTpl_INCLUDE_DIRS='.+/examples/tpls/HeaderOnlyTpl'" + "Performing Test HAVE_SIMPLECXX___INT64" + "Configuring done" + "Generating done" + "Build files have been written to: .*ExamplesUnitTests/${testName}" + "-- File Trace: PROJECT INCLUDE .*/TribitsExampleProject/Version.cmake" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/cmake/CallbackSetupExtraOptions.cmake" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/PackagesList.cmake" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/TPLsList.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/mixed_lang/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/a/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/b/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/with_subpackages/c/cmake/Dependencies.cmake" + "-- File Trace: PACKAGE INCLUDE .*/TribitsExampleProject/packages/wrap_external/cmake/Dependencies.cmake" + "-- File Trace: PROJECT CONFIGURE .*/TribitsExampleProject/cmake/ctest/CTestCustom.cmake.in" + "-- File Trace: REPOSITORY READ .*/TribitsExampleProject/Copyright.txt" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/Version.cmake" + "${TPL_MPI_FILE_TRACE}" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/simple_cxx/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/simple_cxx/test/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/a/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/a/tests/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/b/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/b/tests/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/c/CMakeLists.txt" + "-- File Trace: PACKAGE ADD_SUBDIR .*/TribitsExampleProject/packages/with_subpackages/c/tests/CMakeLists.txt" + "-- File Trace: REPOSITORY INCLUDE .*/TribitsExampleProject/cmake/CallbackDefineRepositoryPackaging.cmake" + "-- File Trace: PROJECT INCLUDE .*/TribitsExampleProject/cmake/CallbackDefineProjectPackaging.cmake" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_1 + MESSAGE "Make sure that 'LabelsForSubprojects' is set to list of packages" + CMND ${LabelsForSubprojects_CMND_AND_ARGS} + PASS_REGULAR_EXPRESSION "${LabelsForSubprojects_REGEX}" + + TEST_2 + MESSAGE "Build the default 'all' target using raw 'make'" + CMND make ARGS ${CTEST_BUILD_FLAGS} + PASS_REGULAR_EXPRESSION_ALL + "Built target simplecxx" + "${DEPRECATED_WARNING_1_STR}" + "${DEPRECATED_WARNING_2_STR}" + "Built target pws_a" + "Built target pws_b" + "Built target pws_c" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_3 + MESSAGE "Run all the tests with raw 'ctest'" + CMND ${CMAKE_CTEST_COMMAND} ARGS -VV + PASS_REGULAR_EXPRESSION_ALL + "SimpleCxx_HelloWorldTests${TEST_MPI_1_SUFFIX} .* Passed" + "WithSubpackagesA_test_of_a .* Passed" + "WithSubpackagesB_test_of_b .* Passed" + "WithSubpackagesC_test_of_c .* Passed" + "WithSubpackagesC_test_of_c_util.* Passed" + "100% tests passed, 0 tests failed out of 6" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_4 + MESSAGE "Create and configure a dummy project that includes" + " WithSubpackagesConfig.cmake from the build tree" + CMND ${CMAKE_COMMAND} + ARGS + -DDUMMY_PROJECT_NAME=DummyProject + -DDUMMY_PROJECT_DIR=dummy_client_of_build_WithSubpackages + -DEXPORT_VAR_PREFIX=WithSubpackages + -DEXPORT_CONFIG_FILE=../cmake_packages/WithSubpackages/WithSubpackagesConfig.cmake + -DCMAKE_COMMAND=${CMAKE_COMMAND} + -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake + PASS_REGULAR_EXPRESSION_ALL + "WithSubpackages_CMAKE_BUILD_TYPE = 'RELEASE'" + "WithSubpackages_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" + "WithSubpackages_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" + "WithSubpackages_Fortran_COMPILER = ''" + "WithSubpackages_FORTRAN_COMPILER = ''" + "WithSubpackages_CXX_FLAGS = '.*'" + "WithSubpackages_C_FLAGS = '.*'" + "WithSubpackages_Fortran_FLAGS = '.*'" + "WithSubpackages_EXTRA_LD_FLAGS = '.*'" + "WithSubpackages_SHARED_LIB_RPATH_COMMAND = '.*'" + "WithSubpackages_BUILD_SHARED_LIBS = '.*'" + "WithSubpackages_LINKER = '.+'" + "WithSubpackages_AR = '.+'" + "WithSubpackages_INSTALL_DIR = .*/${testName}/install" + "WithSubpackages_INCLUDE_DIRS = ''" + "WithSubpackages_LIBRARY_DIRS = ''" + "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" + "WithSubpackages_TPL_LIBRARY_DIRS = ''" + "WithSubpackages_TPL_LIBRARIES = '${WithSubpackages_TPL_LIBRARIES}'" + "WithSubpackages_MPI_LIBRARIES = ''" + "WithSubpackages_MPI_LIBRARY_DIRS = ''" + "WithSubpackages_MPI_INCLUDE_DIRS = ''" + "WithSubpackages_MPI_EXEC = '${MPI_EXEC}'" + "WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'" + "WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'" + "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" + "WithSubpackages_TPL_LIST = '${WithSubpackages_TPL_LIST}'" + "-- Configuring done" + "-- Generating done" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_5 + MESSAGE "Build 'install' target using raw 'make'" + CMND make ARGS install ${CTEST_BUILD_FLAGS} + PASS_REGULAR_EXPRESSION_ALL + "Install configuration: .RELEASE." + "Installing: .*/install/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfig.cmake" + "Installing: .*/install/lib/external_packages/HeaderOnlyTpl/HeaderOnlyTplConfigVersion.cmake" + "Installing: .+/install/include/TribitsExProj_version.h" + "Installing: .+/install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake" + "Installing: .+/install/lib/cmake/TribitsExProj/TribitsExProjConfigVersion.cmake" + "Installing: .+/install/include/TribitsExProjConfig.cmake" + "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxConfig.cmake" + "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxTargets.cmake" + "Installing: .+/install/lib/cmake/SimpleCxx/SimpleCxxTargets-release.cmake" + "Installing: .+/install/lib/libsimplecxx${libExtRegex}" + "Installing: .+/install/include/SimpleCxx_HelloWorld.hpp" + "Installing: .+/install/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake" + "Installing: .+/install/lib/libpws_a${libExtRegex}" + "Installing: .+/install/include/A.hpp" + "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesAConfig.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesATargets.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesA/WithSubpackagesATargets-release.cmake" + "Installing: .+/install/lib/libpws_b${libExtRegex}" + "Installing: .+/install/include/B.hpp" + "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBConfig.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesB/WithSubpackagesBTargets-release.cmake" + "Installing: .+/install/lib/libpws_c${libExtRegex}" + "Installing: .+/install/include/wsp_c/C.hpp" + "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCConfig.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets.cmake" + "Installing: .+/install/lib/cmake/WithSubpackagesC/WithSubpackagesCTargets-release.cmake" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_6 + MESSAGE "Create and configure a dummy project that includes" + " WithSubpackagesConfig.cmake from the install tree" + CMND ${CMAKE_COMMAND} + ARGS + -DDUMMY_PROJECT_NAME=DummyProject + -DDUMMY_PROJECT_DIR=dummy_client_of_WithSubpackages + -DEXPORT_VAR_PREFIX=WithSubpackages + -DEXPORT_CONFIG_FILE=../install/lib/cmake/WithSubpackages/WithSubpackagesConfig.cmake + -DCMAKE_COMMAND=${CMAKE_COMMAND} + -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake + PASS_REGULAR_EXPRESSION_ALL + "WithSubpackages_CMAKE_BUILD_TYPE = 'RELEASE'" + "WithSubpackages_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" + "WithSubpackages_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" + "WithSubpackages_Fortran_COMPILER = ''" + "WithSubpackages_FORTRAN_COMPILER = ''" + "WithSubpackages_CXX_FLAGS = '.*'" + "WithSubpackages_C_FLAGS = '.*'" + "WithSubpackages_Fortran_FLAGS = '.*'" + "WithSubpackages_EXTRA_LD_FLAGS = '.*'" + "WithSubpackages_SHARED_LIB_RPATH_COMMAND = '.*'" + "WithSubpackages_BUILD_SHARED_LIBS = '.*'" + "WithSubpackages_LINKER = '.+'" + "WithSubpackages_AR = '.+'" + "WithSubpackages_INSTALL_DIR = '.+/install'" + "WithSubpackages_INCLUDE_DIRS = ''" + "WithSubpackages_LIBRARY_DIRS = ''" + "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" + "WithSubpackages_TPL_LIBRARY_DIRS = ''" + "WithSubpackages_TPL_LIBRARIES = '${WithSubpackages_TPL_LIBRARIES}'" + "WithSubpackages_MPI_LIBRARIES = ''" + "WithSubpackages_MPI_LIBRARY_DIRS = ''" + "WithSubpackages_MPI_INCLUDE_DIRS = ''" + "WithSubpackages_MPI_EXEC = '${MPI_EXEC}'" + "WithSubpackages_MPI_EXEC_MAX_NUMPROCS = '${MPI_EXEC_MAX_NUMPROCS}'" + "WithSubpackages_MPI_EXEC_NUMPROCS_FLAG = '${MPI_EXEC_NUMPROCS_FLAG}'" + "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" + "WithSubpackages_TPL_LIST = '${WithSubpackages_TPL_LIST}'" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_7 + MESSAGE "Create and configure a dummy project that includes" + " TribitsExProjConfig.cmake from the install tree" + CMND ${CMAKE_COMMAND} + ARGS + -DDUMMY_PROJECT_NAME=DummyProject + -DDUMMY_PROJECT_DIR=dummy_client_of_TribitsExProj + -DEXPORT_VAR_PREFIX=TribitsExProj + -DEXPORT_CONFIG_FILE=../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake + -DCMAKE_COMMAND=${CMAKE_COMMAND} + -P ${CMAKE_CURRENT_SOURCE_DIR}/RunDummyPackageClientBulid.cmake + PASS_REGULAR_EXPRESSION_ALL + "DUMMY_PROJECT_NAME = 'DummyProject'" + "DUMMY_PROJECT_DIR = 'dummy_client_of_TribitsExProj'" + "EXPORT_CONFIG_FILE = '../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" + "EXPORT_VAR_PREFIX = 'TribitsExProj'" + "CMAKE_COMMAND = '${CMAKE_COMMAND}" + "Create the dummy client directory ..." + "Create dummy dummy_client_of_TribitsExProj/CMakeLists.txt file ..." + "Configure the dummy project to print the variables in .*/${testName}/dummy_client_of_TribitsExProj ..." + "DUMMY_PROJECT_NAME = 'DummyProject'" + "EXPORT_CONFIG_FILE = '../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" + "EXPORT_VAR_PREFIX = 'TribitsExProj'" + "Including file '.*/${testName}/dummy_client_of_TribitsExProj/../install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" + "TribitsExProj_CMAKE_BUILD_TYPE = 'RELEASE'" + "TribitsExProj_CXX_COMPILER = '${CMAKE_CXX_COMPILER_FOR_REGEX}'" + "TribitsExProj_C_COMPILER = '${CMAKE_C_COMPILER_FOR_REGEX}'" + "TribitsExProj_Fortran_COMPILER = ''" + "TribitsExProj_FORTRAN_COMPILER = ''" + "TribitsExProj_CXX_FLAGS = ''" + "TribitsExProj_C_FLAGS = ''" + "TribitsExProj_Fortran_FLAGS = ''" + "TribitsExProj_EXTRA_LD_FLAGS = ''" + "TribitsExProj_SHARED_LIB_RPATH_COMMAND = '${TribitsExProj_SHARED_LIB_RPATH_COMMAND_REGEX}'" + "TribitsExProj_BUILD_SHARED_LIBS = '${BUILD_SHARED_LIBS_VAL}'" + "TribitsExProj_LINKER = '.*'" + "TribitsExProj_AR = '.*'" + "TribitsExProj_INSTALL_DIR = '.*/${testName}/install'" + "TribitsExProj_INCLUDE_DIRS = '.*/${testName}/install/include'" + "TribitsExProj_LIBRARY_DIRS = ''" + "TribitsExProj_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" + "TribitsExProj_TPL_INCLUDE_DIRS = ''" + "TribitsExProj_TPL_LIBRARY_DIRS = ''" + "TribitsExProj_TPL_LIBRARIES = '${TribitsExProj_TPL_LIBRARIES}'" + "TribitsExProj_MPI_LIBRARIES = ''" + "TribitsExProj_MPI_LIBRARY_DIRS = ''" + "TribitsExProj_MPI_INCLUDE_DIRS = ''" + "TribitsExProj_MPI_EXEC = '.*'" + "TribitsExProj_MPI_EXEC_MAX_NUMPROCS = '[1-9]*'" # Is null for an MPI build + "TribitsExProj_MPI_EXEC_NUMPROCS_FLAG = '.*'" + "TribitsExProj_PACKAGE_LIST = 'WithSubpackages[;]WithSubpackagesC[;]WithSubpackagesB[;]WithSubpackagesA[;]SimpleCxx'" + "TribitsExProj_TPL_LIST = '${TribitsExProj_TPL_LIST}'" + "-- Configuring done" + "-- Generating done" + ALWAYS_FAIL_ON_NONZERO_RETURN + + # ToDo: Add test for the components parts of Config.cmake ... + + # ToDo: Add test that actually builds a C++ project and links to these libs + # to make sure this works! + + TEST_8 + MESSAGE "Create the tarball" + CMND make ARGS package_source + PASS_REGULAR_EXPRESSION_ALL + "Run CPack packaging tool for source..." + "CPack: Create package using TGZ" + "CPack: Install projects" + "CPack: - Install directory: .*/examples/TribitsExampleProject" + "CPack: Create package" + "CPack: - package: .*/ExamplesUnitTests/${testName}/tribitsexproj-1.1-Source.tar.gz generated." + "CPack: Create package using TBZ2" + "CPack: Install projects" + "CPack: - Install directory: .*/examples/TribitsExampleProject" + "CPack: Create package" + "CPack: - package: .*/ExamplesUnitTests/${testName}/tribitsexproj-1.1-Source.tar.bz2 generated." + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_9 + MESSAGE "Untar the tarball" + CMND tar ARGS -xzf tribitsexproj-1.1-Source.tar.gz + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_10 + MESSAGE "Make sure right directoires are excluced" + CMND diff + ARGS -qr + ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject + tribitsexproj-1.1-Source + PASS_REGULAR_EXPRESSION_ALL + "Only in .*/TribitsExampleProject/cmake: ctest" + ${REGEX_FOR_GITIGNORE} + "Only in .*/TribitsExampleProject/packages: mixed_lang" + "Only in .*/TribitsExampleProject/packages: wrap_external" + "Only in .*/TribitsExampleProject/packages/with_subpackages/b: ExcludeFromRelease.txt" + "Only in .*/TribitsExampleProject/packages/with_subpackages/b/src: AlsoExcludeFromTarball.txt" + # NOTE: We don't check return code because diff returns nonzero - TEST_9 - MESSAGE "Untar the tarball" - CMND tar ARGS -xzf tribitsexproj-1.1-Source.tar.gz - ALWAYS_FAIL_ON_NONZERO_RETURN + ) - TEST_10 - MESSAGE "Make sure right directoires are excluced" - CMND diff - ARGS -qr - ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject - tribitsexproj-1.1-Source - PASS_REGULAR_EXPRESSION_ALL - "Only in .*/TribitsExampleProject/cmake: ctest" - ${REGEX_FOR_GITIGNORE} - "Only in .*/TribitsExampleProject/packages: mixed_lang" - "Only in .*/TribitsExampleProject/packages: wrap_external" - "Only in .*/TribitsExampleProject/packages/with_subpackages/b: ExcludeFromRelease.txt" - "Only in .*/TribitsExampleProject/packages/with_subpackages/b/src: AlsoExcludeFromTarball.txt" - # NOTE: We don't check return code because diff returns nonzero +endfunction() - ) +TribitsExampleProject_ALL_ST_NoFortran(STATIC SERIAL) +TribitsExampleProject_ALL_ST_NoFortran(SHARED MPI) ######################################################################## @@ -972,6 +1022,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja -DTribitsExProj_WRITE_NINJA_MAKEFILES=OFF ${TribitsExampleProject_COMMON_CONFIG_ARGS} -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DTPL_ENABLE_MPI=OFF -DTribitsExProj_ENABLE_Fortran=OFF -DTribitsExProj_ENABLE_ALL_PACKAGES=ON -DTribitsExProj_ENABLE_TESTS=ON @@ -1017,7 +1068,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja TEST_4 CMND ${CMAKE_CTEST_COMMAND} ARGS -VV MESSAGE "Run all the tests with raw 'ctest'" PASS_REGULAR_EXPRESSION_ALL - "SimpleCxx_HelloWorldTests${TEST_MPI_1_SUFFIX} .* Passed" + "SimpleCxx_HelloWorldTests .* Passed" "WithSubpackagesA_test_of_a .* Passed" "WithSubpackagesB_test_of_b .* Passed" "WithSubpackagesC_test_of_c .* Passed" @@ -1038,7 +1089,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran_Ninja/install'" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/tribits/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1062,9 +1113,9 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja MESSAGE "Create and configure a dummy project that includes WithSubpackagesConfig.cmake" PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran_Ninja/install'" - "WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'" + "WithSubpackages_LIBRARY_DIRS = ''" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1112,6 +1163,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefile -GNinja ${TribitsExampleProject_COMMON_CONFIG_ARGS} -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DTPL_ENABLE_MPI=OFF -DTribitsExProj_ENABLE_Fortran=OFF -DTribitsExProj_ENABLE_ALL_PACKAGES=ON -DTribitsExProj_ENABLE_TESTS=ON @@ -1141,7 +1193,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefile TEST_2 CMND ${CMAKE_CTEST_COMMAND} ARGS -VV MESSAGE "Run all the tests with raw 'ctest'" PASS_REGULAR_EXPRESSION_ALL - "SimpleCxx_HelloWorldTests${TEST_MPI_1_SUFFIX} .* Passed" + "SimpleCxx_HelloWorldTests .* Passed" "WithSubpackagesA_test_of_a .* Passed" "WithSubpackagesB_test_of_b .* Passed" "WithSubpackagesC_test_of_c .* Passed" @@ -1162,7 +1214,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefile PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefiles/install'" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/tribits/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1186,9 +1238,9 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefile MESSAGE "Create and configure a dummy project that includes WithSubpackagesConfig.cmake" PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.*/TriBITS_TribitsExampleProject_ALL_ST_NoFortran_Ninja_Makefiles/install'" - "WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'" + "WithSubpackages_LIBRARY_DIRS = ''" "WithSubpackages_LIBRARIES = 'WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "WithSubpackages_TPL_INCLUDE_DIRS = '.+/examples/tpls/HeaderOnlyTpl'" + "WithSubpackages_TPL_INCLUDE_DIRS = ''" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesC.WithSubpackagesB.WithSubpackagesA.SimpleCxx'" "WithSubpackages_TPL_LIST = 'HeaderOnlyTpl'" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1357,8 +1409,8 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_PT_NoFortran MESSAGE "Create and configure a dummy project that includes WithSubpackagesConfig.cmake" PASS_REGULAR_EXPRESSION_ALL "WithSubpackages_INSTALL_DIR = '.+/install'" - "WithSubpackages_INCLUDE_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../include'" - "WithSubpackages_LIBRARY_DIRS = '.+/install/lib/cmake/WithSubpackages/../../../lib'" + "WithSubpackages_INCLUDE_DIRS = ''" + "WithSubpackages_LIBRARY_DIRS = ''" "WithSubpackages_LIBRARIES = 'WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" "WithSubpackages_PACKAGE_LIST = 'WithSubpackagesA.SimpleCxx'" ) @@ -1512,31 +1564,31 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage # TEST_1 - MESSAGE "Show deprecated warning when trying to link lib from upstream SE package." + MESSAGE "Show deprecated warning when trying to link lib from upstream package." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_UPSTREAM_DEPLIBS_ERROR=ON . PASS_REGULAR_EXPRESSION_ALL - "WARNING: 'simplecxx' in DEPLIBS is not a lib in this SE package" + "WARNING: 'simplecxx' in DEPLIBS is not a lib in this package" "packages/with_subpackages/b/src/CMakeLists.txt:.* [(]tribits_add_library[)]" "Generating done" "Build files have been written to: .*/TriBITS_TribitsExampleProject_ALL_ST_LibUsage" TEST_2 - MESSAGE "Show deprecated warning when passing a lib from this SE package through IMPORTEDLIBS." + MESSAGE "Show deprecated warning when passing a lib from this package through IMPORTEDLIBS." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_SE_PKG_LIB_IMPORTEDLIBS_ERROR=ON -DSPKB_SHOW_UPSTREAM_DEPLIBS_ERROR= . PASS_REGULAR_EXPRESSION_ALL - "WARNING: Lib 'pws_b' in IMPORTEDLIBS is in this SE package " + "WARNING: Lib 'pws_b' in IMPORTEDLIBS is in this package " "packages/with_subpackages/b/tests/testlib/CMakeLists.txt:.* [(]tribits_add_library[)]" "Generating done" "Build files have been written to: .*/TriBITS_TribitsExampleProject_ALL_ST_LibUsage" TEST_3 MESSAGE "Show deprecated warning when passing a lib from upstream" - " SE package through IMPORTEDLIBS." + " package through IMPORTEDLIBS." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_UPSTREAM_SE_PKG_LIB_IMPORTEDLIBS_ERROR=ON -DSPKB_SHOW_SE_PKG_LIB_IMPORTEDLIBS_ERROR= @@ -1612,7 +1664,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage "Configuring incomplete, errors occurred!" TEST_9 - MESSAGE "Show error when trying to link SE package lib using TESTONLYLIBS" + MESSAGE "Show error when trying to link package lib using TESTONLYLIBS" CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_IMPORTED_LIBS_THIS_PKG_ERROR=ON -DSPKB_SHOW_NON_TESTONLY_LIB_ERROR= @@ -1696,31 +1748,31 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage_LibPrefix # TEST_1 - MESSAGE "Show deprecated warning when trying to link lib from upstream SE package." + MESSAGE "Show deprecated warning when trying to link lib from upstream package." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_UPSTREAM_DEPLIBS_ERROR=ON . PASS_REGULAR_EXPRESSION_ALL - "WARNING: 'simplecxx' in DEPLIBS is not a lib in this SE package" + "WARNING: 'simplecxx' in DEPLIBS is not a lib in this package" "packages/with_subpackages/b/src/CMakeLists.txt:.* [(]tribits_add_library[)]" "Generating done" "Build files have been written to: .*/TriBITS_TribitsExampleProject_ALL_ST_LibUsage_LibPrefix" TEST_2 - MESSAGE "Show deprecated warning when passing a lib from this SE package through IMPORTEDLIBS." + MESSAGE "Show deprecated warning when passing a lib from this package through IMPORTEDLIBS." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_SE_PKG_LIB_IMPORTEDLIBS_ERROR=ON -DSPKB_SHOW_UPSTREAM_DEPLIBS_ERROR= . PASS_REGULAR_EXPRESSION_ALL - "WARNING: Lib 'pws_b' in IMPORTEDLIBS is in this SE package " + "WARNING: Lib 'pws_b' in IMPORTEDLIBS is in this package " "packages/with_subpackages/b/tests/testlib/CMakeLists.txt:.* [(]tribits_add_library[)]" "Generating done" "Build files have been written to: .*/TriBITS_TribitsExampleProject_ALL_ST_LibUsage_LibPrefix" TEST_3 MESSAGE "Show deprecated warning when passing a lib from upstream" - " SE package through IMPORTEDLIBS." + " package through IMPORTEDLIBS." CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_UPSTREAM_SE_PKG_LIB_IMPORTEDLIBS_ERROR=ON -DSPKB_SHOW_SE_PKG_LIB_IMPORTEDLIBS_ERROR= @@ -1796,7 +1848,7 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_ST_LibUsage_LibPrefix "Configuring incomplete, errors occurred!" TEST_9 - MESSAGE "Show error when trying to link SE package lib using TESTONLYLIBS" + MESSAGE "Show error when trying to link package lib using TESTONLYLIBS" CMND ${CMAKE_COMMAND} ARGS -DSPKB_SHOW_IMPORTED_LIBS_THIS_PKG_ERROR=ON -DSPKB_SHOW_NON_TESTONLY_LIB_ERROR= @@ -2183,30 +2235,16 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_NoFortran_WrapExternal_Verb "HeaderOnlyTpl_INCLUDE_DIRS='.+/examples/tpls/HeaderOnlyTpl'" "-- TPL_HeaderOnlyTpl_INCLUDE_DIRS='.+/examples/tpls/HeaderOnlyTpl'" - "SimpleCxx_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "SimpleCxx_LIBRARY_DIRS='.+/packages/simple_cxx/src'" "SimpleCxx_LIBRARIES='SimpleCxx::simplecxx'" - "WithSubpackagesA_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "WithSubpackagesA_LIBRARY_DIRS='.+/packages/with_subpackages/a[;].+/packages/simple_cxx/src'" "WithSubpackagesA_LIBRARIES='WithSubpackagesA::pws_a'" - "b_test_utils_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl[;].+/TribitsExampleProject/packages/with_subpackages/b/tests/testlib'" - - "WithSubpackagesB_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "WithSubpackagesB_LIBRARY_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src'" "WithSubpackagesB_LIBRARIES='WithSubpackagesB::pws_b'" - "WithSubpackagesC_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl[;].+/TribitsExampleProject/packages/with_subpackages/c'" - "WithSubpackagesC_LIBRARY_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/c'" "WithSubpackagesC_LIBRARIES='WithSubpackagesC::pws_c'" - "WithSubpackages_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/b/src[;].+/TribitsExampleProject/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl[;].+/TribitsExampleProject/packages/with_subpackages/c'" - "WithSubpackages_LIBRARY_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/b/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/simple_cxx/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_WrapExternal_VerboseConfigure/packages/with_subpackages/c'" "WithSubpackages_LIBRARIES='WithSubpackagesC::pws_c[;]WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a'" - "WrapExternal_INCLUDE_DIRS='.+/packages/wrap_external/external_func'" - "WrapExternal_LIBRARY_DIRS=''" "WrapExternal_LIBRARIES='external_func[;]pws_a'" "pws_b_TARGET_NAME='pws_b'" @@ -2214,17 +2252,6 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_NoFortran_WrapExternal_Verb "test_of_b_TEST_NAME='WithSubpackagesB_test_of_b'" "c_util_TEST_NAME='WithSubpackagesC_test_of_c_util${TEST_MPI_1_SUFFIX}'" - "-- simplecxx:LINK_LIBS=''" - "-- HelloWorldTests:LINK_LIBS='SimpleCxx::simplecxx'" - "-- pws_a:LINK_LIBS='SimpleCxx::simplecxx'" - "-- a_test:LINK_LIBS='WithSubpackagesA::pws_a'" - "-- pws_b:LINK_LIBS='WithSubpackagesA::pws_a;SimpleCxx::simplecxx'" - "-- b_test:LINK_LIBS='WithSubpackagesB::pws_b'" - "-- c_util:LINK_LIBS='WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a'" - "-- pws_c:LINK_LIBS='WithSubpackagesB::pws_b[;]WithSubpackagesA::pws_a'" - "-- c_test:LINK_LIBS='WithSubpackagesC::pws_c'" - "-- run_external_func:LINK_LIBS='external_func[;]pws_a'" - ) @@ -2282,23 +2309,12 @@ tribits_add_advanced_test( TribitsExampleProject_ALL_NoFortran_OverridePackageSo "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a/CMakeLists[.]txt" "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a/tests/CMakeLists[.]txt" - "-- WithSubpackagesA_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/CMakeLists[.]txt" "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/tests/CMakeLists[.]txt" - "-- WithSubpackagesB_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/packages/simple_cxx/src[;].+/examples/tpls/HeaderOnlyTpl'" - "-- WithSubpackagesB_LIBRARY_DIRS='.*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/a[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src'" - "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/c/CMakeLists[.]txt" "-- File Trace: PACKAGE ADD_SUBDIR .*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/c/tests/CMakeLists[.]txt" - "-- WithSubpackagesC_INCLUDE_DIRS='.*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/packages/simple_cxx/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/c'" - "-- WithSubpackagesC_LIBRARY_DIRS='.*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/a[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/c'" - - "-- WithSubpackages_INCLUDE_DIRS='.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/b/src;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/a;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/packages/simple_cxx/src;.+/examples/tpls/HeaderOnlyTpl;.+/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/TribitsExampleProject/with_subpackages/c'" - "-- WithSubpackages_LIBRARY_DIRS='.*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/b/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/a[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/packages/simple_cxx/src[;].*/TriBITS_TribitsExampleProject_ALL_NoFortran_OverridePackageSourceDir/with_subpackages/c'" - TEST_4 CMND make ARGS ${CTEST_BUILD_FLAGS} PASS_REGULAR_EXPRESSION_ALL @@ -2918,10 +2934,10 @@ tribits_add_advanced_test( TribitsExampleProject_compiler_flags ) # NOTE: The above tests checks the compiler flags that are set by TriBITS for # the various use cases. This is a hard test to make portable because we -# really need to check that the comiler options are set all the way down. To +# really need to check that the compiler options are set all the way down. To # make this more portable, we only do this on Linux systems and only with GCC. # -# We actaully build known targets with 'make VERBOSE=1 ' and then grep +# We actually build known targets with 'make VERBOSE=1 ' and then grep # the output to make sure the compiler flags drill down all the way to the # actual targets. # @@ -2931,3 +2947,62 @@ tribits_add_advanced_test( TribitsExampleProject_compiler_flags # NOTE: Above, we had to switch to Ninja and 'cmake --build . -v [--target # ] in order to get verbose output when run inside of a cmake -S # script with CMake 3.23-rc2. Not sure why this is but this is better anyway. + + +################################################################################### + + +tribits_add_advanced_test( TribitsExampleProject_extra_link_flags + OVERALL_WORKING_DIRECTORY TEST_NAME + OVERALL_NUM_MPI_PROCS 1 + EXCLUDE_IF_NOT_TRUE IS_REAL_LINUX_SYSTEM ${PROJECT_NAME}_ENABLE_Fortran + NINJA_EXE + + TEST_0 + MESSAGE "Configure by setting _EXTRA_LINK_FLAGS" + CMND ${CMAKE_COMMAND} + ARGS + -GNinja + -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DTribitsExProj_ENABLE_Fortran=ON + -DTribitsExProj_ENABLE_TESTS=ON + -DTribitsExProj_ENABLE_ALL_PACKAGES=ON + -DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON + -DTPL_ENABLE_SimpleTpl=ON + -DSimpleTpl_INCLUDE_DIRS=${SimpleTpl_install_STATIC_DIR}/install/include + -DSimpleTpl_LIBRARY_DIRS=${SimpleTpl_install_STATIC_DIR}/install/lib + -DTribitsExProj_EXTRA_LINK_FLAGS="-lgfortran -ldl" + ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject + PASS_REGULAR_EXPRESSION_ALL + "Processing enabled TPL: TribitsExProjTribitsLastLib" + "TPL_TribitsExProjTribitsLastLib_LIBRARIES='-lgfortran[;]-ldl'" + ALWAYS_FAIL_ON_NONZERO_RETURN + # NOTE: Above, we use two libraries to ensure that the logic in TriBITS can + # handle these correctly. + + TEST_1 + MESSAGE "Build verbose to check the link lines" + CMND ${CMAKE_COMMAND} ARGS --build . -v + PASS_REGULAR_EXPRESSION_ALL + "-o packages/simple_cxx/src/simplecxx-helloworld .* packages/simple_cxx/src/libsimplecxx.a +${SimpleTpl_install_STATIC_DIR}/install/lib/libsimpletpl.a +-lgfortran +-ldl" + "-o packages/mixed_lang/test/MixedLang_RayTracerTests.exe packages/mixed_lang/src/libmixedlang.a +-lgfortran +-ldl" + "-o packages/with_subpackages/c/c_util +packages/with_subpackages/b/src/libpws_b.a +packages/with_subpackages/a/libpws_a.a +packages/simple_cxx/src/libsimplecxx.a +${SimpleTpl_install_STATIC_DIR}/install/lib/libsimpletpl.a + packages/mixed_lang/src/libmixedlang.a +-lgfortran +-ldl" + ALWAYS_FAIL_ON_NONZERO_RETURN + + ADDED_TEST_NAME_OUT TribitsExampleProject_extra_link_flags_NAME + ) + # NOTE: The above test ensures that _EXTRA_LINK_FLAGS is handled + # correctly. Note that the package MixedLang has no TPL dependencies so + # that fact that the extra libs gets tacked on to the end proves that they + # get sets even for packages without TPLs. The package SimpleCxx that + # depends on SimpleTPL proves that the extra libs get tacked on after the + # TPL's libs. Also, the fact that the extra libs are tacked on at the very + # end of the link lik for the 'c_util' exec shows that CMake is respecting + # the dependency of libmixedlang.a on these extra libs. This test also + # shows that TriBITS and CMake do a good job of not listing the same libs + # more than once. + +if (TribitsExampleProject_extra_link_flags_NAME) + set_tests_properties(${TribitsExampleProject_extra_link_flags_NAME} + PROPERTIES DEPENDS ${SimpleTpl_install_STATIC_NAME} ) +endif() diff --git a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake index 4d1787bd7..fa53aebb5 100644 --- a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake @@ -768,7 +768,7 @@ tribits_add_advanced_test( TribitsHelloWorld_install_config_dummy_proj "TribitsHelloWorld_AR = '.*'" "TribitsHelloWorld_INSTALL_DIR = '.*/TriBITS_TribitsHelloWorld_install_config_dummy_proj/install'" "TribitsHelloWorld_INCLUDE_DIRS = '.*/TriBITS_TribitsHelloWorld_install_config_dummy_proj/install/include'" - "TribitsHelloWorld_LIBRARY_DIRS = '.*/TriBITS_TribitsHelloWorld_install_config_dummy_proj/install/lib'" + "TribitsHelloWorld_LIBRARY_DIRS = ''" "TribitsHelloWorld_LIBRARIES = 'HelloWorld::hello_world_lib'" "TribitsHelloWorld_TPL_INCLUDE_DIRS = '" "TribitsHelloWorld_TPL_LIBRARY_DIRS = ''" diff --git a/test/core/ExamplesUnitTests/TribitsOldSimpleExampleApp_Tests.cmake b/test/core/ExamplesUnitTests/TribitsOldSimpleExampleApp_Tests.cmake index e298c22ac..c48c15584 100644 --- a/test/core/ExamplesUnitTests/TribitsOldSimpleExampleApp_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsOldSimpleExampleApp_Tests.cmake @@ -52,7 +52,7 @@ set_default_and_from_env( # TribitsOldSimpleExampleApp. -function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) +function(TribitsOldSimpleExampleApp sharedOrStatic serialOrMpi useDeprecatedTargets) set(appConfigurePassRegexAll "") @@ -61,7 +61,15 @@ function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) elseif (sharedOrStatic STREQUAL "STATIC") set(buildSharedLibsArg -DBUILD_SHARED_LIBS=OFF) else() - message(FATAL_ERROR "Invalid value for sharedOrStatic='${sharedOrStatic}'!") + message(FATAL_ERROR "Invalid value sharedOrStatic='${sharedOrStatic}'!") + endif() + + if (serialOrMpi STREQUAL "SERIAL") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=OFF) + elseif (serialOrMpi STREQUAL "MPI") + set(tplEnableMpiArg -DTPL_ENABLE_MPI=ON) + else() + message(FATAL_ERROR "Invalid value tplEnableMpiArg='${tplEnableMpiArg}'!") endif() if (useDeprecatedTargets STREQUAL "USE_DEPRECATED_TARGETS") @@ -82,10 +90,11 @@ function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) elseif (useDeprecatedTargets STREQUAL "USE_NEW_TARGETS") set(useDeprecatedTargetsArg "") else() - message(FATAL_ERROR "Invalid value for useDeprecatedTargets='${useDeprecatedTargets}'!") + message(FATAL_ERROR "Invalid value useDeprecatedTargets='${useDeprecatedTargets}'!") endif() - set(testBaseName ${CMAKE_CURRENT_FUNCTION}_${sharedOrStatic}_${useDeprecatedTargets}) + set(testBaseName + ${CMAKE_CURRENT_FUNCTION}_${sharedOrStatic}_${serialOrMpi}_${useDeprecatedTargets}) set(testName ${PACKAGE_NAME}_${testBaseName}) set(testDir ${CMAKE_CURRENT_BINARY_DIR}/${testName}) @@ -109,6 +118,7 @@ function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) -DSimpleTpl_INCLUDE_DIRS=${SimpleTpl_install_${sharedOrStatic}_DIR}/install/include -DSimpleTpl_LIBRARY_DIRS=${SimpleTpl_install_${sharedOrStatic}_DIR}/install/lib ${buildSharedLibsArg} + ${tplEnableMpiArg} -DCMAKE_INSTALL_PREFIX=${testDir}/install ${TribitsOldSimpleExampleApp_TribitsExampleProject_TRIBITS_DIR}/examples/TribitsExampleProject @@ -169,5 +179,6 @@ function(TribitsOldSimpleExampleApp sharedOrStatic useDeprecatedTargets) endfunction() -TribitsOldSimpleExampleApp(STATIC USE_DEPRECATED_TARGETS) -TribitsOldSimpleExampleApp(SHARED USE_NEW_TARGETS) +TribitsOldSimpleExampleApp(STATIC MPI USE_DEPRECATED_TARGETS) +TribitsOldSimpleExampleApp(STATIC SERIAL USE_DEPRECATED_TARGETS) +TribitsOldSimpleExampleApp(SHARED SERIAL USE_NEW_TARGETS) diff --git a/test/core/ExamplesUnitTests/UserErrorChecking_Tests.cmake b/test/core/ExamplesUnitTests/UserErrorChecking_Tests.cmake index b69fa541c..a18c57e26 100644 --- a/test/core/ExamplesUnitTests/UserErrorChecking_Tests.cmake +++ b/test/core/ExamplesUnitTests/UserErrorChecking_Tests.cmake @@ -298,7 +298,7 @@ tribits_add_advanced_test( TribitsExampleProject_PkgWithUserErrors_UNPARSED_ARGU -DTribitsExProj_ENABLE_TESTS=ON TribitsExampleProject PASS_REGULAR_EXPRESSION_ALL - "CMake Error at.*TribitsGeneralMacros.cmake:" + "CMake Error at.*TribitsParseArgumentsHelpers.cmake:" "Arguments passed in unrecognized. PARSE_UNPARSED_ARGUMENTS =" "nonsense_jdslkfhlskd" "tribits_read_toplevel_package_deps_files_add_to_graph" @@ -320,7 +320,7 @@ tribits_add_advanced_test( TribitsExampleProject_PkgWithUserErrors_UNPARSED_ARGU -DTribitsExProj_ENABLE_TESTS=ON TribitsExampleProject PASS_REGULAR_EXPRESSION_ALL - "CMake Error at.*TribitsGeneralMacros.cmake:" + "CMake Error at.*TribitsParseArgumentsHelpers.cmake:" "Arguments passed in unrecognized. PARSE_UNPARSED_ARGUMENTS =" "this_shouldnt_be_here" "PkgWithUserErrors/CMakeLists.txt.*tribits_add_library" @@ -343,7 +343,7 @@ tribits_add_advanced_test( TribitsExampleProject_PkgWithUserErrors_UNPARSED_ARGU -DTribitsExProj_ENABLE_TESTS=ON TribitsExampleProject PASS_REGULAR_EXPRESSION_ALL - "CMake Error at.*TribitsGeneralMacros.cmake:" + "CMake Error at.*TribitsParseArgumentsHelpers.cmake:" "Arguments passed in unrecognized. PARSE_UNPARSED_ARGUMENTS =" "misspelled_argument" "PkgWithUserErrors/CMakeLists.txt.*tribits_add_executable" diff --git a/test/core/TestingFunctionMacro_UnitTests.cmake b/test/core/TestingFunctionMacro_UnitTests.cmake index b22067f7a..027c23fc0 100644 --- a/test/core/TestingFunctionMacro_UnitTests.cmake +++ b/test/core/TestingFunctionMacro_UnitTests.cmake @@ -60,34 +60,30 @@ include(TribitsFilepathHelpers) include(TribitsGetVersionDate) include(TribitsTplFindIncludeDirsAndLibraries) include(TribitsReportInvalidTribitsUsage) +include(TribitsGitRepoVersionInfo) include(UnitTestHelpers) include(GlobalSet) include(GlobalNullSet) include(AppendStringVar) -##################################################################### +################################################################################ # -# Unit tests for tribits_add_xxx(...) CMake commands run as CMake code +# Unit tests for a collection of TriBITS Core CMake code # -# This file contains a set of unit tests for the package_arch macros -# tribits_add_xxx(...) functions. These unit tests are written in CMake -# itself. This is not a very advanced unit testing system and it not that -# easy to work with. However, it does perform some pretty strong testing and -# is much better than doing nothing. +# These unit tests are written in CMake itself. This is not a very advanced +# unit testing system and it not that easy to work with. However, it does +# perform some pretty strong testing and is much better than doing nothing. +# Each set of tests is in a function scope so as not to impact other tests. # -##################################################################### +################################################################################ +################################################################################ # -# Set up unit test functions that will be called below to actually run the -# unit tests. -# -# The reason that we use functions is so that we can change variables just -# inside of the functions that have their own variable scoping. In that way, -# we can keep variables that are set in one unit test from affecting the -# others. +# Testing misc functions and macros # +################################################################################ function(unittest_append_string_var) @@ -492,6 +488,55 @@ function(unittest_tribits_get_version_date_from_raw_git_commit_utc_time) endfunction() +function(unittest_tribits_git_repo_sha1) + + message("\n***") + message("*** Testing tribits_git_repo_sha1()") + message("***\n") + + find_program(GIT_EXECUTABLE ${GIT_NAME}) + + set(tribitsProjDir "${${PROJECT_NAME}_TRIBITS_DIR}/..") + + # Matches any 40-char SHA1 + set(anySha1Regex "") + foreach(i RANGE 0 39) + string(APPEND anySha1Regex "[a-z0-9]") + endforeach() + + if (IS_DIRECTORY "${tribitsProjDir}/.git") + + message("Testing tribits_git_repo_sha1() with the base TriBITS project (without FAILURE_MESSAGE_OUT)\n") + tribits_git_repo_sha1("${tribitsProjDir}" gitRepoSha1) + unittest_string_var_regex(gitRepoSha1 REGEX_STRINGS "${anySha1Regex}") + + message("Testing tribits_git_repo_sha1() with the base TriBITS project (with FAILURE_MESSAGE_OUT)\n") + tribits_git_repo_sha1("${tribitsProjDir}" gitRepoSha1 + FAILURE_MESSAGE_OUT failureMsg) + unittest_string_var_regex(gitRepoSha1 REGEX_STRINGS "${anySha1Regex}") + unittest_compare_const(failureMsg "") + + endif() + + message("Testing tribits_git_repo_sha1(): No GIT_EXECUTABLE (with FAILURE_MESSAGE_OUT)\n") + set(GIT_EXECUTABLE_SAVED "${GIT_EXECUTABLE}") + set(GIT_EXECUTABLE "") + tribits_git_repo_sha1("${tribitsProjDir}" gitRepoSha1 + FAILURE_MESSAGE_OUT failureMsg) + unittest_compare_const(gitRepoSha1 "") + unittest_compare_const(failureMsg "ERROR: The program 'git' could not be found!") + set(GIT_EXECUTABLE "${GIT_EXECUTABLE_SAVED}") + unset(GIT_EXECUTABLE_SAVED) + + message("Testing tribits_git_repo_sha1(): Invalid repo dir (with FAILURE_MESSAGE_OUT)\n") + tribits_git_repo_sha1("/repo/does/not/exist" gitRepoSha1 + FAILURE_MESSAGE_OUT failureMsg) + unittest_compare_const(gitRepoSha1 "") + unittest_compare_const(failureMsg "ERROR: The directory /repo/does/not/exist/.git does not exist!") + +endfunction() + + function(unittest_tribits_tpl_allow_pre_find_package) message("\n***") @@ -670,6 +715,13 @@ function(unittest_tribits_report_invalid_tribits_usage) endfunction() +################################################################################ +# +# Testing tribits_add_test() +# +################################################################################ + + function(unittest_tribits_add_test_basic) message("\n***") @@ -1304,6 +1356,22 @@ function(unittest_tribits_add_test_basic) "NAME;${PACKEXEN};COMMAND;/some/abs/path/${PACKEXEN}.exe;arg1" ) + # + # ADD_DIR_TO_NAME + # + + message("Add a test with ADD_DIR_TO_NAME") + set(PACKAGE_SOURCE_DIR "/base/project/package/mypackage") + set(CMAKE_CURRENT_SOURCE_DIR "/base/project/package/mypackage/tests/unit-tests/test1") + global_set(TRIBITS_ADD_TEST_ADD_TEST_INPUT) + tribits_add_test( ${EXEN} ADD_DIR_TO_NAME ARGS arg1 ) + unittest_compare_const( + TRIBITS_ADD_TEST_ADD_TEST_INPUT + "NAME;${PACKAGE_NAME}_tests_unit-tests_test1_${EXEN};COMMAND;${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_tests_unit-tests_test1_${EXEN}.exe;arg1" + ) + unset(PACKAGE_SOURCE_DIR) + unset(CMAKE_CURRENT_SOURCE_DIR) + # # _EXTRA_ARGS # @@ -2314,6 +2382,13 @@ function(unittest_tribits_add_test_properties) endfunction() +################################################################################ +# +# Testing tribits_add_advanced_test() +# +################################################################################ + + function(unittest_tribits_add_advanced_test_basic) message("\n***") @@ -4118,6 +4193,13 @@ function(unittest_tribits_add_executable_and_test) endfunction() +################################################################################ +# +# Testing TriBITS ETI support code +# +################################################################################ + + function(unittest_tribits_eti_type_expansion) message("*** Test passing invalid arguments to tribits_eti_type_expansion( ... )\n") @@ -4265,6 +4347,7 @@ function(unittest_tribits_add_eti_instantiations_initial) endfunction() + function(unittest_tribits_add_eti_instantiations_cumulative) set(package ${PROJECT_NAME}Framework) @@ -4346,6 +4429,7 @@ function(unittest_tribits_eti_explode) endfunction() + function(unittest_tribits_eti_mangle_symbol) message("*** Testing ETI Mangling ***") @@ -4469,9 +4553,12 @@ function(unittest_tribits_eti_generate_macros) endfunction() + +################################################################################ # # Execute the unit tests # +################################################################################ # Set up some global environment stuff set(${PROJECT_NAME}_HOSTNAME testhost.nowhere.com) @@ -4487,7 +4574,7 @@ set( TRIBITS_ADD_TEST_ADD_TEST_UNITTEST TRUE ) set( TRIBITS_ADD_TEST_ADD_TEST_CAPTURE TRUE ) message("\n***") -message("*** Running little bits of tests") +message("*** Testing misc TriBITS functions and macros") message("***\n") unittest_append_string_var() @@ -4499,6 +4586,7 @@ unittest_tribits_misc() unittest_tribits_strip_quotes_from_str() unittest_tribits_get_version_date_from_raw_git_commit_utc_time() unittest_tribits_get_raw_git_commit_utc_time() +unittest_tribits_git_repo_sha1() unittest_tribits_tpl_allow_pre_find_package() unittest_tribits_report_invalid_tribits_usage() @@ -4555,4 +4643,4 @@ message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(695) +unittest_final_result(703) diff --git a/test/core/TribitsWriteClientExportFiles_UnitTests.cmake b/test/core/TribitsWriteClientExportFiles_UnitTests.cmake index 607c104fb..e565d171f 100644 --- a/test/core/TribitsWriteClientExportFiles_UnitTests.cmake +++ b/test/core/TribitsWriteClientExportFiles_UnitTests.cmake @@ -135,14 +135,14 @@ function(unittest_write_specialized_package_export_makefile_rtop_before_libs) unittest_file_regex("${GENERATED_EXPORT_CONFIG_FOR_BUILD}" REGEX_STRINGS "set[(]RTOp1_CMAKE_BUILD_TYPE .DEBUG." - "set[(]RTOp1_INCLUDE_DIRS .teuchos/core/include.teuchos/numeric/include.." - "set[(]RTOp1_LIBRARY_DIRS .teuchos/core/src.teuchos/numeric/src.." - "set[(]RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.." - "set[(]RTOp1_TPL_INCLUDE_DIRS .lapackhpath/include.blaspath/include.." - "set[(]RTOp1_TPL_LIBRARY_DIRS .lapackhpath/lib.blashpath/lib.." - "set[(]RTOp1_TPL_LIBRARIES .lapackpath/lib/liblapack.a.blaspath/lib/libblas.a.." - "set[(]RTOp1_PACKAGE_LIST .Teuchos.." - "set[(]RTOp1_TPL_LIST .LAPACK.BLAS.." + "set[(]RTOp1_INCLUDE_DIRS ..[)]" + "set[(]RTOp1_LIBRARY_DIRS ..[)]" + "set[(]RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.[)]" + "set[(]RTOp1_TPL_INCLUDE_DIRS ..[)]" + "set[(]RTOp1_TPL_LIBRARY_DIRS ..[)]" + "set[(]RTOp1_TPL_LIBRARIES .LAPACK::all_libs[;]BLAS::all_libs.[)]" + "set[(]RTOp1_PACKAGE_LIST .Teuchos.[)]" + "set[(]RTOp1_TPL_LIST .LAPACK.BLAS.[)]" "set[(]RTOp1_ENABLE_Teuchos ON[)]" ) @@ -150,14 +150,14 @@ function(unittest_write_specialized_package_export_makefile_rtop_before_libs) unittest_file_regex("${GENERATED_EXPORT_CONFIG_FOR_INSTALL}" REGEX_STRINGS "set[(]RTOp1_CMAKE_BUILD_TYPE .DEBUG." - "set[(]RTOp1_INCLUDE_DIRS .*/dummy_install_include_dir" - "set[(]RTOp1_LIBRARY_DIRS .*/dummy_install_lib_dir" - "set[(]RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.." - "set[(]RTOp1_TPL_INCLUDE_DIRS .lapackhpath/include.blaspath/include.." - "set[(]RTOp1_TPL_LIBRARY_DIRS .lapackhpath/lib.blashpath/lib.." - "set[(]RTOp1_TPL_LIBRARIES .lapackpath/lib/liblapack.a.blaspath/lib/libblas.a.." - "set[(]RTOp1_PACKAGE_LIST .Teuchos.." - "set[(]RTOp1_TPL_LIST .LAPACK.BLAS.." + "set[(]RTOp1_INCLUDE_DIRS ..[)]" + "set[(]RTOp1_LIBRARY_DIRS ..[)]" + "set[(]RTOp1_LIBRARIES .teuchoscore.teuchosnumeric.[)]" + "set[(]RTOp1_TPL_INCLUDE_DIRS ..[)]" + "set[(]RTOp1_TPL_LIBRARY_DIRS ..[)]" + "set[(]RTOp1_TPL_LIBRARIES .LAPACK::all_libs[;]BLAS::all_libs.[)]" + "set[(]RTOp1_PACKAGE_LIST .Teuchos.[)]" + "set[(]RTOp1_TPL_LIST .LAPACK.BLAS.[)]" "set[(]RTOp1_ENABLE_Teuchos ON[)]" ) @@ -225,14 +225,14 @@ function(unittest_write_specialized_package_export_makefile_rtop_after_libs) unittest_file_regex("${GENERATED_EXPORT_CONFIG_FOR_BUILD}" REGEX_STRINGS "set[(]RTOp2_CMAKE_BUILD_TYPE .RELEASE." - "set[(]RTOp2_INCLUDE_DIRS .rtop/include.teuchos/core/include.teuchos/numeric/include.." - "set[(]RTOp2_LIBRARY_DIRS .rtop/src.teuchos/core/src.teuchos/numeric/src.." - "set[(]RTOp2_LIBRARIES .rtop.teuchoscore.teuchosnumeric.." - "set[(]RTOp2_TPL_INCLUDE_DIRS .lapackhpath/include.blaspath/include.." - "set[(]RTOp2_TPL_LIBRARY_DIRS .lapackhpath/lib.blashpath/lib.." - "set[(]RTOp2_TPL_LIBRARIES .lapackpath/lib/liblapack.a.blaspath/lib/libblas.a.." - "set[(]RTOp2_PACKAGE_LIST .RTOp.Teuchos.." - "set[(]RTOp2_TPL_LIST .LAPACK.BLAS.." + "set[(]RTOp2_INCLUDE_DIRS ..[)]" + "set[(]RTOp2_LIBRARY_DIRS ..[)]" + "set[(]RTOp2_LIBRARIES .rtop.teuchoscore.teuchosnumeric.[)]" + "set[(]RTOp2_TPL_INCLUDE_DIRS ..[)]" + "set[(]RTOp2_TPL_LIBRARY_DIRS ..[)]" + "set[(]RTOp2_TPL_LIBRARIES .LAPACK::all_libs[;]BLAS::all_libs.[)]" + "set[(]RTOp2_PACKAGE_LIST .RTOp.Teuchos.[)]" + "set[(]RTOp2_TPL_LIST .LAPACK.BLAS.[)]" "set[(]RTOp2_ENABLE_Teuchos ON[)]" ) diff --git a/test/ctest_driver/CMakeLists.txt b/test/ctest_driver/CMakeLists.txt index e4b75a620..92455ce4f 100644 --- a/test/ctest_driver/CMakeLists.txt +++ b/test/ctest_driver/CMakeLists.txt @@ -6,7 +6,7 @@ tribits_add_advanced_test( CTestDriverUnitTests -D${PROJECT_NAME}_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/CTestDriverUnitTests.cmake" PASS_REGULAR_EXPRESSION_ALL - "Final UnitTests Result: num_run = 6" + "Final UnitTests Result: num_run = 9" "Final UnitTests Result: PASSED" ) diff --git a/test/ctest_driver/CTestDriverUnitTests.cmake b/test/ctest_driver/CTestDriverUnitTests.cmake index d81d299e7..d8d19f89a 100644 --- a/test/ctest_driver/CTestDriverUnitTests.cmake +++ b/test/ctest_driver/CTestDriverUnitTests.cmake @@ -50,7 +50,43 @@ include(GlobalSet) include(UnitTestHelpers) include(TribitsReadTagFile) -include(TribitsGetCDashUrlFromTagFile) +include(TribitsGetCDashUrlsInsideCTestS) + + +function(unittest_tribits_get_cdash_revision_builds_url) + + message("\n***") + message("*** Testing tribits_get_cdash_revision_builds_url()") + message("***\n") + + tribits_get_cdash_revision_builds_url( + CDASH_SITE_URL "somesite.com/my-cdash" + PROJECT_NAME goodProject + GIT_REPO_SHA1 "abc123" + CDASH_REVISION_BUILDS_URL_OUT cdashRevesionBuildsUrlOut + ) + unittest_compare_const(cdashRevesionBuildsUrlOut + "somesite.com/my-cdash/index.php?project=goodProject&filtercount=1&showfilters=1&field1=revision&compare1=61&value1=abc123") + +endfunction() + + +function(unittest_tribits_get_cdash_revision_nonpassing_tests_url) + + message("\n***") + message("*** Testing tribits_get_cdash_revision_nonpassing_tests_url()") + message("***\n") + + tribits_get_cdash_revision_nonpassing_tests_url( + CDASH_SITE_URL "somesite.com/my-cdash" + PROJECT_NAME goodProject + GIT_REPO_SHA1 "abc123" + CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrlOut + ) + unittest_compare_const(cdashRevisionNonpassingTestsUrlOut + "somesite.com/my-cdash/queryTests.php?project=goodProject&filtercount=2&showfilters=1&filtercombine=and&field1=revision&compare1=61&value1=abc123&field2=status&compare2=62&value2=passed") + +endfunction() function(unittest_tribits_read_ctest_tag_file) @@ -73,6 +109,23 @@ function(unittest_tribits_read_ctest_tag_file) endfunction() +function(unittest_tribits_get_cdash_site_from_drop_site_and_location) + + message("\n***") + message("*** Testing tribits_get_cdash_site_from_drop_site_and_location()") + message("***\n") + + tribits_get_cdash_site_from_drop_site_and_location( + CTEST_DROP_SITE "some.site.com" + CTEST_DROP_LOCATION "/cdash/submit.php?project=SomeProject" + CDASH_SITE_URL_OUT cdashSiteUrl + ) + + unittest_compare_const(cdashSiteUrl "https://some.site.com/cdash") + +endfunction() + + function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location) message("\n***") @@ -85,7 +138,7 @@ function(unittest_tribits_get_cdash_index_php_from_drop_site_and_location) INDEX_PHP_URL_OUT indexPhpUrl ) - unittest_compare_const(indexPhpUrl "some.site.com/cdash/index.php") + unittest_compare_const(indexPhpUrl "https://some.site.com/cdash/index.php") endfunction() @@ -141,7 +194,10 @@ endfunction() unittest_initialize_vars() # Run the unit test functions +unittest_tribits_get_cdash_revision_builds_url() +unittest_tribits_get_cdash_revision_nonpassing_tests_url() unittest_tribits_read_ctest_tag_file() +unittest_tribits_get_cdash_site_from_drop_site_and_location() unittest_tribits_get_cdash_index_php_from_drop_site_and_location() unittest_tribits_get_cdash_build_url_from_parts() unittest_tribits_get_cdash_build_url_from_tag_file() @@ -151,4 +207,4 @@ message("*** Determine final result of all unit tests") message("***\n") # Pass in the number of expected tests that must pass! -unittest_final_result(6) +unittest_final_result(9) diff --git a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt index 17a553913..15e465a5a 100644 --- a/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleMetaProject/CMakeLists.txt @@ -98,6 +98,19 @@ set(TribitsExampleMetaProject_COMMON_CONFIG_ARGS ########################################################################################## + set(cdash_build_url_expected_regex + "https://testing[.]sandia[.]gov/cdash/index[.]php[?]project=TribitsExampleMetaProject&filtercount=3&showfilters=1&filtercombine=and&field1=site&compare1=61&value1=CustomSite&field2=buildname&compare2=61&value2=CTestDriver_TribitsExMetaProj_clone_default_branch_remote&field3=buildstamp&compare3=61&value3=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-Continuous" ) + # NOTE: Above, we have to repeat [0-9] 8 times and 4 times for the regex for + # the number of digits in the buildstarttime. CMake regex does not support + # \d{8}-\d{4} :-( + + set(cdash_revisions_builds_url_expected_regex + "https://testing[.]sandia[.]gov/cdash/index.php[?]project=TribitsExampleMetaProject&filtercount=1&showfilters=1&field1=revision&compare1=61&value1=863461e3035d24c632e175c087761e83db28bdc3") + + set(cdash_revisions_nonpassing_tests_expected_regex + "https://testing[.]sandia[.]gov/cdash/queryTests.php[?]project=TribitsExampleMetaProject&filtercount=2&showfilters=1&filtercombine=and&field1=revision&compare1=61&value1=863461e3035d24c632e175c087761e83db28bdc3&field2=status&compare2=62&value2=passed" ) + + tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_remote OVERALL_WORKING_DIRECTORY TEST_NAME OVERALL_NUM_MPI_PROCS 1 @@ -111,11 +124,19 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re ${COMMON_ENV_ARGS} TribitsExMetaProj_ENABLE_SECONDARY_TESTED_CODE=TRUE CTEST_BUILD_NAME=CTestDriver_TribitsExMetaProj_clone_default_branch_remote + CTEST_SITE=CustomSite ${CTEST_S_SCRIPT_ARGS} PASS_REGULAR_EXPRESSION_ALL "CTEST_NOTES_FILES=''" "First perform the initial checkout: .*/git. clone -o origin .*github.com.tribits/TribitsExampleMetaProject.git" "Perform checkout in directory: .*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote" + "Results will be submitted on CDash at the following links:" + "Link to this build's results on CDash:" + "${cdash_build_url_expected_regex}" + "Link to all builds for this repo version on CDash:" + "${cdash_revisions_builds_url_expected_regex}" + "Link to all nonpassing tests for all builds for this repo version on CDash:" + "${cdash_revisions_nonpassing_tests_expected_regex}" "Calling ctest_update[(][)] to update base source repo '.*/TriBITS_CTestDriver_TribitsExMetaProj_clone_default_branch_remote/TribitsExampleMetaProject" "Old revision of repository is: [a-z0-9]+" "New revision of repository is: [a-z0-9]+" @@ -315,6 +336,11 @@ tribits_add_advanced_test( CTestDriver_TribitsExMetaProj_clone_default_branch_re # * Makes sure some git commit SHA1s are shown in 'Old/New revision of # repository' printouts from ctest_update(). # + # * Checks that CDash URLs that get produced, including for all builds with + # * the same repo version. (This check has to be here since the base + # * project repo must have a .git/ directory and we must know the exact SHA1 + # * of that repo for the test, which we don in this case.) + # # NOTE: The reason that so many tests are done in a single ctest test is the # cost of the initial configure which checks the compilers which is very # expensive. The other runs use diff --git a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt index cb9402d6f..1201b75c4 100644 --- a/test/ctest_driver/TribitsExampleProject/CMakeLists.txt +++ b/test/ctest_driver/TribitsExampleProject/CMakeLists.txt @@ -704,7 +704,7 @@ tribits_add_advanced_test( CTestDriver_PBP_Dashboard_ST_ALL_PASS "Running package-by-package experimental dashboard" "A[)] Clean out the list of packages" "B[)] Run the dashboard command setting the list of packages" - "Running: env TRIBITS_PROJECT_ROOT=.*/tribits/examples/TribitsExampleProject TribitsExProj_TRIBITS_DIR=.*/tribits TribitsExProj_WARNINGS_AS_ERRORS_FLAGS='' TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON TribitsExProj_CTEST_DO_ALL_AT_ONCE=FALSE CTEST_DO_COVERAGE_TESTING=OFF CTEST_DO_SUBMIT=.* CTEST_DROP_METHOD=.* CTEST_DROP_SITE=.* CTEST_DROP_LOCATION=.* TribitsExProj_EXTRAREPOS_FILE=.*/tribits/examples/TribitsExampleProject/cmake/ExtraRepositoriesList.cmake TribitsExProj_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE= TribitsExProj_IGNORE_MISSING_EXTRA_REPOSITORIES=FALSE TribitsExProj_EXTRA_REPOSITORIES= TribitsExProj_PACKAGES=SimpleCxx[;]MixedLang[;]WithSubpackagesA[;]WithSubpackagesB[;]WithSubpackagesC[;]WithSubpackages[;]WrapExternal PROJECT_SOURCE_DIR=.*/tribits/examples/TribitsExampleProject .*/bin/ctest -V -S .*/tribits/ctest_driver/experimental_build_test.cmake" + "Running: env TRIBITS_PROJECT_ROOT=.*/tribits/examples/TribitsExampleProject TribitsExProj_TRIBITS_DIR=.*/tribits TribitsExProj_WARNINGS_AS_ERRORS_FLAGS='' TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON CTEST_DO_UPDATES=OFF TribitsExProj_CTEST_DO_ALL_AT_ONCE=FALSE CTEST_DO_COVERAGE_TESTING=OFF CTEST_DO_SUBMIT=.* CTEST_DROP_METHOD=.* CTEST_DROP_SITE=.* CTEST_DROP_LOCATION=.* TribitsExProj_EXTRAREPOS_FILE=.*/tribits/examples/TribitsExampleProject/cmake/ExtraRepositoriesList.cmake TribitsExProj_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE= TribitsExProj_IGNORE_MISSING_EXTRA_REPOSITORIES=FALSE TribitsExProj_EXTRA_REPOSITORIES= TribitsExProj_PACKAGES=SimpleCxx[;]MixedLang[;]WithSubpackagesA[;]WithSubpackagesB[;]WithSubpackagesC[;]WithSubpackages[;]WrapExternal PROJECT_SOURCE_DIR=.*/tribits/examples/TribitsExampleProject .*/bin/ctest -V -S .*/tribits/ctest_driver/experimental_build_test.cmake" "-- ENV_TribitsExProj_ENABLE_SECONDARY_TESTED_CODE='ON'" "TribitsExProj_ENABLE_SECONDARY_TESTED_CODE='ON'" "Final set of packages to be explicitly processed by CTest/CDash: SimpleCxx MixedLang WithSubpackages WrapExternal 4" @@ -785,7 +785,7 @@ tribits_add_advanced_test( CTestDriver_AAO_Dashboard_ForwardArgs CTEST_DASHBOARD_ROOT= make dashboard PASS_REGULAR_EXPRESSION_ALL - "Running: env TRIBITS_PROJECT_ROOT=.*/tribits/examples/TribitsExampleProject TribitsExProj_TRIBITS_DIR=.*/tribits TribitsExProj_WARNINGS_AS_ERRORS_FLAGS='' TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=OFF TribitsExProj_CTEST_DO_ALL_AT_ONCE=TRUE CTEST_BUILD_NAME=MyCustomBuildName CTEST_DO_COVERAGE_TESTING=FALSE CTEST_BUILD_FLAGS='-j6' CTEST_PARALLEL_LEVEL=10 CTEST_DO_SUBMIT=FALSE CTEST_DROP_METHOD=OFF CTEST_DROP_SITE=OFF CTEST_DROP_LOCATION=OFF CTEST_DROP_SITE_COVERAGE=FALSE CTEST_DROP_LOCATION_COVERAGE=FALSE TRIBITS_2ND_CTEST_DROP_LOCATION=FALSE TRIBITS_2ND_CTEST_DROP_SITE=FALSE TribitsExProj_EXTRAREPOS_FILE=FALSE TribitsExProj_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE=NONE TribitsExProj_IGNORE_MISSING_EXTRA_REPOSITORIES=TRUE TribitsExProj_EXTRA_REPOSITORIES=DummyRepo1,DummyRepo2,DummyRepo3 TribitsExProj_PACKAGES=${TribitsExProj_PACKAGES_list} PROJECT_SOURCE_DIR=.*/tribits/examples/TribitsExampleProject .*/ctest -VV -S .*/tribits/ctest_driver/experimental_build_test.cmake" + "Running: env TRIBITS_PROJECT_ROOT=.*/tribits/examples/TribitsExampleProject TribitsExProj_TRIBITS_DIR=.*/tribits TribitsExProj_WARNINGS_AS_ERRORS_FLAGS='' TribitsExProj_ENABLE_SECONDARY_TESTED_CODE=OFF CTEST_DO_UPDATES=OFF TribitsExProj_CTEST_DO_ALL_AT_ONCE=TRUE CTEST_BUILD_NAME=MyCustomBuildName CTEST_DO_COVERAGE_TESTING=FALSE CTEST_BUILD_FLAGS='-j6' CTEST_PARALLEL_LEVEL=10 CTEST_DO_SUBMIT=FALSE CTEST_DROP_METHOD=OFF CTEST_DROP_SITE=OFF CTEST_DROP_LOCATION=OFF CTEST_DROP_SITE_COVERAGE=FALSE CTEST_DROP_LOCATION_COVERAGE=FALSE TRIBITS_2ND_CTEST_DROP_LOCATION=FALSE TRIBITS_2ND_CTEST_DROP_SITE=FALSE TribitsExProj_EXTRAREPOS_FILE=FALSE TribitsExProj_ENABLE_KNOWN_EXTERNAL_REPOS_TYPE=NONE TribitsExProj_IGNORE_MISSING_EXTRA_REPOSITORIES=TRUE TribitsExProj_EXTRA_REPOSITORIES=DummyRepo1,DummyRepo2,DummyRepo3 TribitsExProj_PACKAGES=${TribitsExProj_PACKAGES_list} PROJECT_SOURCE_DIR=.*/tribits/examples/TribitsExampleProject .*/ctest -VV -S .*/tribits/ctest_driver/experimental_build_test.cmake" "ENV_PROJECT_SOURCE_DIR='.*/tribits/examples/TribitsExampleProject'" "ENV_CTEST_BUILD_NAME='MyCustomBuildName'" @@ -1264,7 +1264,8 @@ function(generate_aao_tests) # CONFIGURE_OPTIONS list is checked to make sure that it does not change # without being noticed. Follow-on tests will not check all of that. - set(cdash_url_expected_regex + + set(cdash_build_url_expected_regex "https://cdash[.]site[.]com/cdash/index[.]php[?]project=CustomTribitsExProj&filtercount=3&showfilters=1&filtercombine=and&field1=site&compare1=61&value1=My%20Site&field2=buildname&compare2=61&value2=TriBITS_CTestDriver_AAOP_CDASH_URL&field3=buildstamp&compare3=61&value3=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]-Custom%20CDash%20Group" ) # NOTE: Above, we have to repeat [0-9] 8 times and 4 times for the regex for # the number of digits in the buildstarttime. CMake regex does not support @@ -1285,7 +1286,7 @@ function(generate_aao_tests) CTEST_DASHBOARD_ROOT=PWD ${AAO_COMMON_ENV_ARGS} CTEST_PARALLEL_LEVEL=3 - CTEST_DO_SUBMIT=OFF # Never submit this + CTEST_DO_SUBMIT=OFF # Never submit this (see below note) CTEST_SITE="My Site" CTEST_DROP_SITE="cdash.site.com" CTEST_PROJECT_NAME="CustomTribitsExProj" @@ -1299,17 +1300,19 @@ function(generate_aao_tests) "NONE does not exist, skipping extra repositories" "Final set of enabled packages: SimpleCxx 1" "Final set of enabled SE packages: SimpleCxx 1" - "Results will be submitted on CDash at:" + "Results will be submitted on CDash at the following links:" + "Link to this build's results on CDash:" + "${cdash_build_url_expected_regex}" "File '' does NOT exist so all tests passed" - "See results submitted on CDash at:" - "${cdash_url_expected_regex}" + "See results submitted on CDash at the following links:" "TRIBITS_CTEST_DRIVER: OVERALL: ALL PASSED" ALWAYS_FAIL_ON_NONZERO_RETURN TEST_2 - MESSAGE "Check that CDashBuildUrl.txt exists and lists the right URL." - CMND cat ARGS BUILD/CDashBuildUrl.txt + MESSAGE "Check that CDashResults.txt exists and lists the right URL." + CMND cat ARGS BUILD/CDashResults.txt PASS_REGULAR_EXPRESSION_ALL - "${cdash_url_expected_regex}" + "Link to this build's results on CDash:" + "${cdash_build_url_expected_regex}" ) # NOTE: The above test is never actually submitted to CDash, even when # ${PACKAGE_NAME}_CTEST_DRIVER_SUBMIT_TO is set. This is so we can @@ -2477,7 +2480,7 @@ function(generate_aao_tests) "EXPORT_CONFIG_FILE = '../BUILD/install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" "TribitsExProj_FIND_COMPONENTS = 'SimpleCxx[;]WithSubpackagesA[;]WrapExternal'" "TribitsExProj_LIBRARIES = 'WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "TribitsExProj_TPL_INCLUDE_DIRS = '.*/examples/tpls/HeaderOnlyTpl'" + "TribitsExProj_TPL_INCLUDE_DIRS = ''" "TribitsExProj_PACKAGE_LIST = 'WithSubpackages[;]WithSubpackagesC[;]WithSubpackagesB[;]WithSubpackagesA[;]MixedLang[;]SimpleCxx'" "TribitsExProj_TPL_LIST = 'HeaderOnlyTpl'" "TribitsExProj_WithSubpackages_FOUND = ''" @@ -2595,7 +2598,7 @@ function(generate_aao_tests) "EXPORT_CONFIG_FILE = '../BUILD/install/lib/cmake/TribitsExProj/TribitsExProjConfig.cmake'" "TribitsExProj_FIND_COMPONENTS = 'SimpleCxx[;]WithSubpackagesA'" "TribitsExProj_LIBRARIES = 'WithSubpackagesA::pws_a[;]SimpleCxx::simplecxx'" - "TribitsExProj_TPL_INCLUDE_DIRS = '.*/examples/tpls/HeaderOnlyTpl'" + "TribitsExProj_TPL_INCLUDE_DIRS = ''" "TribitsExProj_PACKAGE_LIST = 'WithSubpackages[;]WithSubpackagesC[;]WithSubpackagesB[;]WithSubpackagesA[;]MixedLang[;]SimpleCxx'" "TribitsExProj_TPL_LIST = 'HeaderOnlyTpl'" "TribitsExProj_WithSubpackages_FOUND = ''" diff --git a/tribits/CHANGELOG.md b/tribits/CHANGELOG.md index 27e339c0f..63761777b 100644 --- a/tribits/CHANGELOG.md +++ b/tribits/CHANGELOG.md @@ -4,6 +4,47 @@ ChangeLog for TriBITS ## 2022-05-16: +* **Changed:** All compliant external packages (TPLs) must now set the + imported target `::all_libs` in their `FindTPL.cmake` + files instead of the variables `TPL__INCLUDE` and + `TPL__LIBRARIES`. + +* **Changed:** The project-level variables `_INCLUDE_DIRS`, + `_TPL_INCLUDE_DIRS`, `_LIBRARY_DIRS` and + `_TPL_LIBRARY_DIRS` from the file `Config.cmake` and + package-level variables `_INCLUDE_DIRS`, + `_TPL_INCLUDE_DIRS`, `_LIBRARY_DIRS` and + `_TPL_LIBRARY_DIRS` from the installed files + `Config.cmake` are now set to empty. Downstream CMake projects + will need to link against the exported project-level target + `::all_libs` or `::all_selected_libs` or the package-level + targets `::all_libs` in order to get the list of include + directories that are propagated through those targets by CMake. + +* **Changed:** The function `tribits_add_library()` no longer sets the + directory property `INCLUDE_DIRECTORIES` and instead passes include + directory information between targets directly using the + `INTERFACE_INCLUDE_DIRECTORIES` target property. This may result in + situations where include directories were getting set through the directory + property `INCLUDE_DIRECTORIES` and getting picked up in the builds of + targets that lacked the proper library dependencies. Therefore, this is + technically a break in backward compatibility, but not for well-formed + TriBITS projects. + +* **Changed:** Variables `${PACKAGE_NAME}_ENABLE_` are now set to + `TRUE` for required upstream internal and external packages/TPLs `` + (in order to simplify internal TriBITS logic). However, a side-effect of + this change is that CMake code that was ifed out with an `if + (${PACKAGE_NAME}_ENABLE_)` statement (because that variable was not + defined and therefore defaults to `FLASE`) for a required upstream + dependency `` will now be enabled. (This mistake can happen when an + optional dependency `` is changed to a required dependency but the + `if()` statements based on `${PACKAGE_NAME}_ENABLE_` are not + removed. Well-formed TriBITS projects and packages should not experience + this problem or notice any change.) + +## 2022-05-16: + * **Added:** The function `tribits_add_advanced_test(`) now correctly accepts a list of regexes for `PASS_REGULAR_EXPRESSION` and `FAIL_REGULAR_EXPRESSION` and behave the same as the raw CTest properties of diff --git a/tribits/common_tpls/FindTPLNetcdf.cmake b/tribits/common_tpls/FindTPLNetcdf.cmake index a5a98ce2c..9ffd66c06 100644 --- a/tribits/common_tpls/FindTPLNetcdf.cmake +++ b/tribits/common_tpls/FindTPLNetcdf.cmake @@ -48,6 +48,10 @@ set(REQUIRED_HEADERS netcdf.h) set(REQUIRED_LIBS_NAMES netcdf) +if (TPL_ENABLE_MPI) + set(REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} pnetcdf) +endif() + # # Second, search for Netcdf components (if allowed) using the standard # find_package(NetCDF ...). @@ -62,7 +66,7 @@ if (Netcdf_ALLOW_PREFIND) "${CMAKE_CURRENT_LIST_DIR}/find_modules" "${CMAKE_CURRENT_LIST_DIR}/utils" ) - + find_package(NetCDF) if (NetCDF_FOUND) @@ -71,7 +75,7 @@ if (Netcdf_ALLOW_PREFIND) "True if netcdf enables netcdf-4") set(TPL_Netcdf_Enables_PNetcdf ${NetCDF_NEEDS_PNetCDF} CACHE BOOL "True if netcdf enables pnetcdf") - set(TPL_Netcdf_PARALLEL ${NetCDF_PARALLEL} CACHE BOOL + set(TPL_Netcdf_PARALLEL ${NetCDF_PARALLEL} CACHE INTERNAL "True if netcdf compiled with parallel enabled") set(TPL_Netcdf_LIBRARY_DIRS ${_hdf5_LIBRARY_SEARCH_DIRS} CACHE PATH "${DOCSTR} library files") @@ -80,7 +84,20 @@ if (Netcdf_ALLOW_PREFIND) set(TPL_Netcdf_INCLUDE_DIRS ${NetCDF_INCLUDE_DIRS} CACHE PATH "${DOCSTR} header files.") endif() - +else() + # Curl library is only required if DAP is enabled; should detect inside + # FindNetCDF.cmake, but that is not being called... SEMS has DAP enabled; + # many HPC systems don't, but they override these settings... + find_program(NC_CONFIG "nc-config") + if (NC_CONFIG) + execute_process(COMMAND "nc-config --has-dap2" + OUTPUT_VARIABLE NETCDF_HAS_DAP2) + execute_process(COMMAND "nc-config --has-dap4" + OUTPUT_VARIABLE NETCDF_HAS_DAP4) + endif() + if ((NOT NC_CONFIG) OR NETCDF_HAS_DAP2 OR NETCDF_HAS_DAP4) + set(REQUIRED_LIBS_NAMES ${REQUIRED_LIBS_NAMES} curl) + endif() endif() # @@ -95,3 +112,30 @@ tribits_tpl_find_include_dirs_and_libraries( Netcdf # variables TPL_Netcdf_INCLUDE_DIRS and TPL_Netcdf_LIBRARIES and then print # them out (and set some other standard variables as well). This is the final # "hook" into the TriBITS TPL system. + +# If the `find_package(NetCDF)` is not run, then this may not be set +# Need to determine how this is set in the library that is being used... + +if ("${TPL_Netcdf_PARALLEL}" STREQUAL "") + assert_defined(TPL_Netcdf_INCLUDE_DIRS) + find_path(meta_path + NAMES "netcdf_meta.h" + HINTS ${TPL_Netcdf_INCLUDE_DIRS} + NO_DEFAULT_PATH) + + if (meta_path) + # Search meta for NC_HAS_PARALLEL setting... + # Note that there is both NC_HAS_PARALLEL and NC_HAS_PARALLEL4, only want first... + file(STRINGS "${meta_path}/netcdf_meta.h" netcdf_par_string REGEX "NC_HAS_PARALLEL ") + string(REGEX MATCH "[01]" netcdf_par_val "${netcdf_par_string}") + if (netcdf_par_val EQUAL 1) + set(TPL_Netcdf_PARALLEL True CACHE INTERNAL + "True if netcdf compiled with parallel enabled") + endif() + endif() + if ("${TPL_Netcdf_PARALLEL}" STREQUAL "") + set(TPL_Netcdf_PARALLEL False CACHE INTERNAL + "True if netcdf compiled with parallel enabled") + endif() +endif() +message(STATUS "TPL_Netcdf_PARALLEL is ${TPL_Netcdf_PARALLEL}") diff --git a/tribits/common_tpls/FindTPLProjectLastLib.cmake b/tribits/common_tpls/FindTPLProjectLastLib.cmake new file mode 100644 index 000000000..97d052978 --- /dev/null +++ b/tribits/common_tpls/FindTPLProjectLastLib.cmake @@ -0,0 +1,9 @@ +# This is a hack to handle the ${PROJECT_NAME}_EXTRA_LINK_FLAGS options as a +# TPL that every downstream TPL and package will depend on. + +separate_arguments(TPL_${PROJECT_NAME}TribitsLastLib_LIBRARIES NATIVE_COMMAND + "${${PROJECT_NAME}_EXTRA_LINK_FLAGS}") + +tribits_tpl_find_include_dirs_and_libraries( ${PROJECT_NAME}TribitsLastLib + REQUIRED_LIBS_NAMES NEVER_USED + ) diff --git a/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in b/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in index f92d40c80..1b11675c7 100644 --- a/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in +++ b/tribits/core/installation/TribitsPackageConfigTemplate.cmake.in @@ -45,6 +45,8 @@ # ############################################################################## +include_guard(GLOBAL) + ## --------------------------------------------------------------------------- ## Compilers used by ${PROJECT_NAME}/${PACKAGE_NAME} build ## --------------------------------------------------------------------------- @@ -93,19 +95,19 @@ set(${EXPORT_FILE_VAR_PREFIX}_AR ${CMAKE_AR}) set(${EXPORT_FILE_VAR_PREFIX}_INSTALL_DIR "@CMAKE_INSTALL_PREFIX@") ## List of package include dirs -set(${EXPORT_FILE_VAR_PREFIX}_INCLUDE_DIRS "${FULL_INCLUDE_DIRS_SET}") +set(${EXPORT_FILE_VAR_PREFIX}_INCLUDE_DIRS "") ## List of package library paths -set(${EXPORT_FILE_VAR_PREFIX}_LIBRARY_DIRS "${FULL_LIBRARY_DIRS_SET}") +set(${EXPORT_FILE_VAR_PREFIX}_LIBRARY_DIRS "") ## List of package libraries set(${EXPORT_FILE_VAR_PREFIX}_LIBRARIES "${FULL_LIBRARY_SET}") ## Specification of directories for TPL headers -set(${EXPORT_FILE_VAR_PREFIX}_TPL_INCLUDE_DIRS "${${PACKAGE_NAME}_TPL_INCLUDE_DIRS}") +set(${EXPORT_FILE_VAR_PREFIX}_TPL_INCLUDE_DIRS "") ## Specification of directories for TPL libraries -set(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARY_DIRS "${${PACKAGE_NAME}_TPL_LIBRARY_DIRS}") +set(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARY_DIRS "") ## List of required TPLs set(${EXPORT_FILE_VAR_PREFIX}_TPL_LIBRARIES "${${PACKAGE_NAME}_TPL_LIBRARIES}") diff --git a/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in b/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in index 8cf75679d..38a27dedf 100644 --- a/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in +++ b/tribits/core/installation/TribitsProjectConfigTemplate.cmake.in @@ -113,11 +113,7 @@ foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST}) # Include the package file. include(${PDOLLAR}{INCLUDE_FILE}) # Add variables to lists. - list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_INCLUDE_DIRS}) - list(APPEND ${PROJECT_NAME}_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_LIBRARIES}) - list(APPEND ${PROJECT_NAME}_TPL_INCLUDE_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_INCLUDE_DIRS}) - list(APPEND ${PROJECT_NAME}_TPL_LIBRARY_DIRS ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_TPL_LIBRARIES ${PDOLLAR}{${PDOLLAR}{comp}_TPL_LIBRARIES}) else() set(${PROJECT_NAME}_${PDOLLAR}{comp}_FOUND FALSE) @@ -129,38 +125,21 @@ foreach (comp IN ITEMS ${PDOLLAR}{COMPONENTS_LIST}) endif() endforeach() -# Resolve absolute paths and remove duplicate paths -# for LIBRARY_DIRS and INCLUDE_DIRS -# This reduces stress on regular expressions later -set(short_dirs) -foreach(dir ${PDOLLAR}{${PROJECT_NAME}_INCLUDE_DIRS}) - get_filename_component(dir_abs ${PDOLLAR}{dir} ABSOLUTE) - list(APPEND short_dirs ${PDOLLAR}{dir_abs}) -endforeach() -list(REMOVE_DUPLICATES short_dirs) -set(${PROJECT_NAME}_INCLUDE_DIRS ${PDOLLAR}{short_dirs}) +# Deprecated (see #299)! +set(${PROJECT_NAME}_INCLUDE_DIRS "${TRIBITS_PROJECT_INSTALL_INCLUDE_DIR}") -set(short_dirs) -foreach(dir ${PDOLLAR}{${PROJECT_NAME}_LIBRARY_DIRS}) - get_filename_component(dir_abs ${PDOLLAR}{dir} ABSOLUTE) - list(APPEND short_dirs ${PDOLLAR}{dir_abs}) -endforeach() -list(REMOVE_DUPLICATES short_dirs) -set(${PROJECT_NAME}_LIBRARY_DIRS ${PDOLLAR}{short_dirs}) +# Deprecated (see #299)! +set(${PROJECT_NAME}_LIBRARY_DIRS "") # Remove duplicates in ${PROJECT_NAME}_LIBRARIES list(REVERSE ${PROJECT_NAME}_LIBRARIES) list(REMOVE_DUPLICATES ${PROJECT_NAME}_LIBRARIES) list(REVERSE ${PROJECT_NAME}_LIBRARIES) -# Remove duplicates in ${PROJECT_NAME}_TPL_INCLUDE_DIRS -if (${PROJECT_NAME}_TPL_INCLUDE_DIRS) - list(REMOVE_DUPLICATES ${PROJECT_NAME}_TPL_INCLUDE_DIRS) -endif() - -# NOTE: It is *NOT* safe to try to remove duplicate in -# ${PROJECT_NAME}_TPL_LIBRARIES because these can be specified as -L, -l, etc. -# Actually, we should think about that. +# Remove duplicates in ${PROJECT_NAME}_TPL_LIBRARIES +list(REVERSE ${PROJECT_NAME}_TPL_LIBRARIES) +list(REMOVE_DUPLICATES ${PROJECT_NAME}_TPL_LIBRARIES) +list(REVERSE ${PROJECT_NAME}_TPL_LIBRARIES) ## --------------------------------------------------------------------------- ## MPI specific variables diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index aa0f100de..fa4294769 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -42,19 +42,14 @@ include(TribitsAddExecutableTestHelpers) include(TribitsCommonArgsHelpers) include(TribitsAddTestHelpers) include(TribitsGeneralMacros) +include(TribitsLibIsTestOnly) include(TribitsReportInvalidTribitsUsage) include(PrintVar) include(AppendSet) include(CMakeParseArguments) -### -### WARNING: See "NOTES TO DEVELOPERS" at the bottom of the file -### TribitsPackageMacros.cmake before trying to change anything in this file! -### - -# # @FUNCTION: tribits_add_executable() # # Function used to create an executable (typically for a test or example), @@ -180,19 +175,7 @@ include(CMakeParseArguments) # package or any upstream SE packages can *NOT* be listed! TriBITS # automatically links non ``TESTONLY`` libraries in this package and # upstream packages to the executable. The only libraries that should be -# listed in this argument are either ``TESTONLY`` libraries. The include -# directories for each test-only library will automatically be added -# using:: -# -# include_directories(${_INCLUDE_DIRS}) -# -# where ``_INCLUDE_DIRS`` was set by:: -# -# tribits_add_library( ... TESTONLY ...) -# -# Therefore, to link to a defined ``TESTONLY`` library in any upstream -# enabled package, one just needs to pass in the library name through -# ``TESTONLYLIBS ... ...`` and that is it! +# listed in this argument are either ``TESTONLY`` libraries. # # ``IMPORTEDLIBS ...`` # @@ -334,11 +317,139 @@ function(tribits_add_executable EXE_NAME) message("") message("TRIBITS_ADD_EXECUTABLE: ${EXE_NAME} ${ARGN}") endif() - + + tribits_add_executable_assert_correct_call_context() + + # + # A) Parse the input arguments + # + + cmake_parse_arguments( + #prefix + PARSE + #options + "NOEXEPREFIX;NOEXESUFFIX;ADD_DIR_TO_NAME;INSTALLABLE" + #one_value_keywords + "" + #multi_value_keywords + "SOURCES;CATEGORIES;HOST;XHOST;HOSTTYPE;XHOSTTYPE;EXCLUDE_IF_NOT_TRUE;DIRECTORY;TESTONLYLIBS;IMPORTEDLIBS;DEPLIBS;COMM;LINKER_LANGUAGE;TARGET_DEFINES;DEFINES;ADDED_EXE_TARGET_NAME_OUT" + ${ARGN} + ) + + tribits_check_for_unparsed_arguments() + + # Executable not added by default! + if(PARSE_ADDED_EXE_TARGET_NAME_OUT) + set(${PARSE_ADDED_EXE_TARGET_NAME_OUT} "" PARENT_SCOPE) + endif() + + set(EXE_BINARY_NAME ${EXE_NAME}) + tribits_add_executable_adjust_exe_name(EXE_BINARY_NAME) + + tribits_add_executable_is_skipped(skipAddExecutable) + if (skipAddExecutable) + return() + endif() + + tribits_add_executable_get_adjusted_sources_list(EXE_SOURCES) + + tribits_add_executable_assert_testonlylibs() + + tribits_add_executable_assert_importedlibs() + + tribits_add_executable_convert_from_deplibs() + + # + # B) Add the executable and set its properties + # + + if(${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("TRIBITS_ADD_EXECUTABLE: add_executable(${EXE_BINARY_NAME} ${EXE_SOURCES})") + endif() + add_executable(${EXE_BINARY_NAME} ${EXE_SOURCES}) + append_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${EXE_BINARY_NAME}) + + if(PARSE_ADDED_EXE_TARGET_NAME_OUT) + set(${PARSE_ADDED_EXE_TARGET_NAME_OUT} ${EXE_BINARY_NAME} PARENT_SCOPE) + endif() + + if (PARSE_DEFINES) + message(WARNING "WARNING: Passing extra defines through 'DEFINES' ${PARSE_DEFINES}" + " is deprecated. Instead, pass them through 'TARGET_DEFINES'. The 'DEFINES'" + " argument was incorrectly implemented by calling add_definitions() which has" + " directory scope and not function scope as was documented. This resulted in" + " confusing behavior. If one wishes to set defines at the directly level," + " just call add_definitions() directly.") + add_definitions(${PARSE_DEFINES}) + endif() + + if (PARSE_TARGET_DEFINES) + target_compile_definitions(${EXE_BINARY_NAME} PUBLIC ${PARSE_TARGET_DEFINES}) + endif() + + if(PARSE_NOEXESUFFIX AND NOT WIN32) + set_target_properties(${EXE_BINARY_NAME} PROPERTIES SUFFIX "") + else() + set_target_properties(${EXE_BINARY_NAME} PROPERTIES SUFFIX + ${${PROJECT_NAME}_CMAKE_EXECUTABLE_SUFFIX}) + endif() + + tribits_set_linker_language_from_arg( ${EXE_BINARY_NAME} + "${PARSE_LINKER_LANGUAGE}" ) + + assert_defined(${PROJECT_NAME}_LINK_SEARCH_START_STATIC) + if (${PROJECT_NAME}_LINK_SEARCH_START_STATIC) + #message("${EXE_BINARY_NAME}: Adding property LINK_SEARCH_START_STATIC") + set_property(TARGET ${EXE_BINARY_NAME} PROPERTY LINK_SEARCH_START_STATIC 1) + endif() + + if(PARSE_DIRECTORY) + set_target_properties( ${EXE_BINARY_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${PARSE_DIRECTORY} ) + endif() + + set_property(TARGET ${EXE_BINARY_NAME} APPEND PROPERTY + LABELS ${PACKAGE_NAME}Exes ${PARENT_PACKAGE_NAME}Exes) + # - # Confirm that package and subpackage macros/functions have been called inteh correct order + # C) Link ${EXE_BINARY_NAME} to direct upstream libraries # - + + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) + foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) + endforeach() + foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${depPkg}::all_libs) + endforeach() + foreach(testOnlyLib ${PARSE_TESTONLYLIBS}) + target_link_libraries(${EXE_BINARY_NAME} PUBLIC + "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${testOnlyLib}") + endforeach() + + # + # D) Install if asked + # + + if(${PROJECT_NAME}_INSTALL_EXECUTABLES AND PARSE_INSTALLABLE) + install( + TARGETS ${EXE_BINARY_NAME} + EXPORT ${PROJECT_NAME} + DESTINATION ${${PROJECT_NAME}_INSTALL_RUNTIME_DIR} + COMPONENT ${PACKAGE_NAME} + ) + endif() + +endfunction() + + +# Assert tribits_add_executable() is called in the correct context +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_assert_correct_call_context) + if (CURRENTLY_PROCESSING_SUBPACKAGE) # This is a subpackage being processed @@ -373,143 +484,155 @@ function(tribits_add_executable EXE_NAME) endif() +endfunction() - # - # A) Parse the input arguments - # - cmake_parse_arguments( - #prefix - PARSE - #options - "NOEXEPREFIX;NOEXESUFFIX;ADD_DIR_TO_NAME;INSTALLABLE" - #one_value_keywords - "" - #multi_value_keywords - "SOURCES;CATEGORIES;HOST;XHOST;HOSTTYPE;XHOSTTYPE;EXCLUDE_IF_NOT_TRUE;DIRECTORY;TESTONLYLIBS;IMPORTEDLIBS;DEPLIBS;COMM;LINKER_LANGUAGE;TARGET_DEFINES;DEFINES;ADDED_EXE_TARGET_NAME_OUT" - ${ARGN} - ) +# Modify EXE_BINARY_NAME based in passed-in args +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_adjust_exe_name exeBinaryNameInOut) - tribits_check_for_unparsed_arguments() + set(exeBinaryName ${${exeBinaryNameInOut}}) + if (PARSE_ADD_DIR_TO_NAME) + set(dirName "") + tribits_create_name_from_current_source_directory(dirName) + set(exeBinaryName ${dirName}_${exeBinaryName}) + endif() - if(PARSE_ADDED_EXE_TARGET_NAME_OUT) - set(${PARSE_ADDED_EXE_TARGET_NAME_OUT} PARENT_SCOPE) + if (DEFINED PACKAGE_NAME AND NOT PARSE_NOEXEPREFIX) + set(exeBinaryName ${PACKAGE_NAME}_${exeBinaryName}) endif() + set(${exeBinaryNameInOut} ${exeBinaryName} PARENT_SCOPE) - # - # B) Exclude building the test executable based on some criteria - # +endfunction() + + +# Check if to skip adding the executable based on different criteria +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_is_skipped skipAddExecutableOut) + + set(skipAddExecutable FALSE) set(ADD_THE_TEST FALSE) set(TEST_NAME ${EXE_NAME}) # For error message tribits_add_test_process_categories(ADD_THE_TEST) if (NOT ADD_THE_TEST) - return() + set(skipAddExecutable TRUE) endif() - set(TEST_NAME) + set(TEST_NAME "") set(ADD_THE_TEST FALSE) tribits_add_test_process_host_hosttype(ADD_THE_TEST) if (NOT ADD_THE_TEST) - return() + set(skipAddExecutable TRUE) endif() tribits_process_comm_args(ADD_SERIAL_EXE ADD_MPI_EXE ${PARSE_COMM}) if (NOT ADD_SERIAL_EXE AND NOT ADD_MPI_EXE) - return() - endif() - - # - # C) Add the executable - # - - set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") - - if (NOT TRIBITS_ADD_EXECUTABLE_UNIT_TESTING) - tribits_include_directories(REQUIRED_DURING_INSTALLATION_TESTING - ${${PACKAGE_NAME}_INCLUDE_DIRS}) -# set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS -# ${${PACKAGE_NAME}_LIBRARY_DIRS}) - endif() - - set (EXE_SOURCES) - set(EXE_BINARY_NAME ${EXE_NAME}) - - # If requested create a modifier for the name that will be inserted between - # the package name and the given name or exe_name for the test - if(PARSE_ADD_DIR_TO_NAME) - set(DIRECTORY_NAME "") - tribits_create_name_from_current_source_directory(DIRECTORY_NAME) - set(EXE_BINARY_NAME ${DIRECTORY_NAME}_${EXE_BINARY_NAME}) + set(skipAddExecutable TRUE) endif() - if(DEFINED PACKAGE_NAME AND NOT PARSE_NOEXEPREFIX) - set(EXE_BINARY_NAME ${PACKAGE_NAME}_${EXE_BINARY_NAME}) - endif() - - # Exclude the build if requested if (${EXE_BINARY_NAME}_EXE_DISABLE) message("-- " "${EXE_BINARY_NAME} EXE NOT being built due to ${EXE_BINARY_NAME}_EXE_DISABLE=" "'${${EXE_BINARY_NAME}_EXE_DISABLE}'") - return() + set(skipAddExecutable TRUE) endif() - # If exe is in subdirectory prepend that dir name to the source files + set(${skipAddExecutableOut} ${skipAddExecutable} PARENT_SCOPE) + +endfunction() + + +# Get adjusted list of source files +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_get_adjusted_sources_list exeSourcesOut) + + set(exeSources "") if(PARSE_DIRECTORY ) - foreach( SOURCE_FILE ${PARSE_SOURCES} ) - if(IS_ABSOLUTE ${SOURCE_FILE}) - set (EXE_SOURCES ${EXE_SOURCES} ${SOURCE_FILE}) + foreach( srcFile ${PARSE_SOURCES} ) + if(IS_ABSOLUTE ${srcFile}) + list(APPEND exeSources "${srcFile}") else() - set (EXE_SOURCES ${EXE_SOURCES} ${PARSE_DIRECTORY}/${SOURCE_FILE}) + list(APPEND exeSources "${PARSE_DIRECTORY}/${srcFile}") endif() endforeach( ) else() - foreach( SOURCE_FILE ${PARSE_SOURCES} ) - set (EXE_SOURCES ${EXE_SOURCES} ${SOURCE_FILE}) + foreach( srcFile ${PARSE_SOURCES} ) + list(APPEND exeSources "${srcFile}") endforeach( ) endif() + set(${exeSourcesOut} ${exeSources} PARENT_SCOPE) + +endfunction() + + +# Assert tribits_add_executable() TESTONLYLIBS +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_assert_testonlylibs) # Assert that TESTONLYLIBS only contains TESTONLY libs! - foreach(TESTONLYLIB ${PARSE_TESTONLYLIBS}) - set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${TESTONLYLIB}") - if (NOT ${PREFIXED_LIB}_INCLUDE_DIRS) - message(FATAL_ERROR "ERROR: '${TESTONLYLIB}' in TESTONLYLIBS not a TESTONLY lib!" + foreach(testOnlyLib ${PARSE_TESTONLYLIBS}) + set(prefixedTestOnlyLib "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${testOnlyLib}") + tribits_lib_is_testonly(${prefixedTestOnlyLib} libIsTestOnlyLib) + if (NOT libIsTestOnlyLib) + message(FATAL_ERROR "ERROR: '${testOnlyLib}' in TESTONLYLIBS not a TESTONLY lib!" " If this a regular library in this SE package or in an dependent upstream SE" " package then TriBITS will link automatically to it. If you remove this and it" " does not link, then you need to add a new SE package dependency to" " this SE package's dependencies file" " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") elseif(PARSE_INSTALLABLE) - message(FATAL_ERROR "ERROR: TESTONLY lib '${TESTONLYLIB}' not allowed with" + message(FATAL_ERROR "ERROR: TESTONLY lib '${testOnlyLib}' not allowed with" " INSTALLABLE executable! An INSTALLABLE executable can only depend on" " non-TESTONLY libraries! Otherwise, when shared libs are used, and" " TESTONLY library would not be installed and the installed executable" " would be unusable!" ) endif() endforeach() +endfunction() + + +# Assert tribits_add_executable() IMPORTEDLIBS +# +# NOTE: This read the variables from the enclosing tribits_add_executable() +# function call scope. +# +function(tribits_add_executable_assert_importedlibs) # Assert that IMPORTEDLIBS are not TESTONLY libs are not regular package # libs! - foreach(IMPORTEDLIB ${PARSE_IMPORTEDLIBS}) - set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") - if (${PREFIXED_LIB}_INCLUDE_DIRS) + foreach(importedLib ${PARSE_IMPORTEDLIBS}) + set(prefixedImportedLib "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${importedLib}") + tribits_lib_is_testonly(${prefixedImportedLib} importedLibIsTestOnlyLib) + if (libIsTestOnly) message(FATAL_ERROR - "ERROR: Lib '${IMPORTEDLIB}' being passed through" + "ERROR: Lib '${importedLib}' being passed through" " IMPORTEDLIBS is not allowed to be a TESTONLY lib!" " Use TESTONLYLIBS instead!" ) endif() - list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" - FOUND_PREFIXED_LIB_IN_PKG_LIBRARIES_IDX) - if (NOT FOUND_PREFIXED_LIB_IN_PKG_LIBRARIES_IDX EQUAL -1) + list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${prefixedImportedLib}" + foundPrefixedImportedLibInPkgLibs_idx) + if (NOT foundPrefixedImportedLibInPkgLibs_idx EQUAL -1) message(FATAL_ERROR - "ERROR: Lib '${IMPORTEDLIB}' in IMPORTEDLIBS is in" + "ERROR: Lib '${importedLib}' in IMPORTEDLIBS is in" " this SE package and is *not* an external lib!" " TriBITS takes care of linking against libs the current" - " SE package automatically. Please remove '${IMPORTEDLIB}' from IMPORTEDLIBS!") - elseif (TARGET ${PREFIXED_LIB}) + " SE package automatically. Please remove '${importedLib}' from IMPORTEDLIBS!") + elseif (TARGET ${prefixedImportedLib}) message(FATAL_ERROR - "ERROR: Lib '${IMPORTEDLIB}' being passed through" + "ERROR: Lib '${importedLib}' being passed through" " IMPORTEDLIBS is *not* an external library but instead is a library" " defined in this CMake project!" " TriBITS takes care of linking against libraries in dependent upstream" @@ -520,173 +643,44 @@ function(tribits_add_executable EXE_NAME) endif() endforeach() +endfunction() + + +# Convert from tribits_add_executable() DEPLIBS to IMPORTEDLIBS and TESTONLYLIBS +# +# NOTE: This is a macro as it updates local variables in the +# tribits_add_executable() scope! +# +macro(tribits_add_executable_convert_from_deplibs) + # Convert from old DEPLIBS to TESTONLYLIBS and IMPORTEDLIBS - foreach(DEPLIB ${PARSE_DEPLIBS}) - set(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${DEPLIB}") - if (${PREFIXED_LIB}_INCLUDE_DIRS) - message(WARNING "WARNING: Passing TESTONLY lib '${DEPLIB}' through DEPLIBS" + foreach(depLib ${PARSE_DEPLIBS}) + set(prefixedDepLib "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${depLib}") + tribits_lib_is_testonly(${prefixedDepLib} depLibIsTestOnlyLib) + if (depLibIsTestOnlyLib) + message(WARNING "WARNING: Passing TESTONLY lib '${depLib}' through DEPLIBS" " is deprecated! Instead, please pass through TESTONLYLIBS instead!" " DEPLIBS is deprecated!") - list(APPEND PARSE_TESTONLYLIBS ${DEPLIB}) - elseif (TARGET ${PREFIXED_LIB}) - message(WARNING "WARNING: Passing non-TESTONLY lib '${DEPLIB}' through DEPLIBS" - " is deprecated! The library '${DEPLIB}' appears to be a" + list(APPEND PARSE_TESTONLYLIBS ${depLib}) + elseif (TARGET ${prefixedDepLib}) + message(WARNING "WARNING: Passing non-TESTONLY lib '${depLib}' through DEPLIBS" + " is deprecated! The library '${depLib}' appears to be a" " library defined in this CMake project." " TriBITS takes care of linking against libraries in dependent upstream" - " SE packages. Therefore, please remove '${DEPLIB}' from this list." + " SE packages. Therefore, please remove '${depLib}' from this list." " If you want to link to a library from an upstream SE" " package, then add the SE package name to the appropriate category" " in this SE package's dependencies file: " " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") + # ToDo: Convert the above 'WARNING' to 'SEND_ERROR' else() - message(WARNING "WARNING: Passing external lib '${DEPLIB}' through" + message(WARNING "WARNING: Passing external lib '${depLib}' through" " DEPLIBS is deprecated! Instead, pass through IMPORTEDLIBS!" " DEPLIBS is deprecated!" " Please note that only external libs are allowed to be passed through" " IMPORTEDLIBS.") - list(APPEND PARSE_IMPORTEDLIBS ${DEPLIB}) - endif() - endforeach() - - foreach(TESTONLYLIB_IN ${PARSE_TESTONLYLIBS}) - set(TESTONLYLIB "${LIBRARY_NAME_PREFIX}${TESTONLYLIB_IN}") - if (${TESTONLYLIB}_INCLUDE_DIRS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message(STATUS "Adding include directories ${TESTONLYLIB}_INCLUDE_DIRS ...") - endif() - include_directories(${${TESTONLYLIB}_INCLUDE_DIRS}) + list(APPEND PARSE_IMPORTEDLIBS ${depLib}) endif() endforeach() - if (PARSE_DEFINES) - message(WARNING "WARNING: Passing extra defines through 'DEFINES' ${PARSE_DEFINES}" - " is deprecated. Instead, pass them through 'TARGET_DEFINES'. The 'DEFINES'" - " argument was incorrectly implemented by calling add_definitions() which has" - " directory scope and not function scope as was documented. This resulted in" - " confusing behavior. If one wishes to set defines at the directly level," - " just call add_definitions() directly.") - add_definitions(${PARSE_DEFINES}) - endif() - - if(${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("TRIBITS_ADD_EXECUTABLE: add_executable(${EXE_BINARY_NAME} ${EXE_SOURCES})") - endif() - add_executable(${EXE_BINARY_NAME} ${EXE_SOURCES}) - append_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${EXE_BINARY_NAME}) - - if(PARSE_ADDED_EXE_TARGET_NAME_OUT) - set(${PARSE_ADDED_EXE_TARGET_NAME_OUT} ${EXE_BINARY_NAME} PARENT_SCOPE) - endif() - - if (PARSE_TARGET_DEFINES) - target_compile_definitions(${EXE_BINARY_NAME} PUBLIC ${PARSE_TARGET_DEFINES}) - endif() - - if(PARSE_NOEXESUFFIX AND NOT WIN32) - set_target_properties(${EXE_BINARY_NAME} PROPERTIES SUFFIX "") - else() - set_target_properties(${EXE_BINARY_NAME} PROPERTIES SUFFIX - ${${PROJECT_NAME}_CMAKE_EXECUTABLE_SUFFIX}) - endif() - - tribits_set_linker_language_from_arg( ${EXE_BINARY_NAME} - "${PARSE_LINKER_LANGUAGE}" ) - - set(LINK_LIBS) - - # First, add in the passed in TESTONLY dependent libraries - if (PARSE_TESTONLYLIBS) - foreach(LIB ${PARSE_TESTONLYLIBS}) - list(APPEND LINK_LIBS "${LIBRARY_NAME_PREFIX}${LIB}") - endforeach() - endif() - - # Second, add the package's own regular libraries - if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - list(APPEND LINK_LIBS ${${PACKAGE_NAME}_LIBRARIES}) - else() - list(APPEND LINK_LIBS ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) - endif() - - # Third, add the IMPORTEDLIBS - if (PARSE_IMPORTEDLIBS) - list(APPEND LINK_LIBS ${PARSE_IMPORTEDLIBS}) - endif() - - # Call include_directories() and link_directories(...) for upstream - # dependent Packages and TPLs and accumulate the list of libraries that will - # need to be linked to. - - if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING - AND NOT ${PACKAGE_NAME}_INCLUDE_DIRS - ) - # No libraries have been added for this package so - # add the upstream package and TPL includes and libraries - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - endif() - - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} TEST LINK_LIBS) - - if(NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} TEST LINK_LIBS) - else() - list(APPEND LINK_LIBS ${${PACKAGE_NAME}_INSTALLATION_TPL_LIBRARIES}) - endif() - - # Last, add last_lib to get extra link options on the link line - if (${PROJECT_NAME}_EXTRA_LINK_FLAGS) - list(APPEND LINK_LIBS last_lib) - endif() - - if (${PROJECT_NAME}_DUMP_LINK_LIBS) - message("-- ${EXE_NAME}:LINK_LIBS='${LINK_LIBS}'") - endif() - - target_link_libraries(${EXE_BINARY_NAME} PUBLIC ${LINK_LIBS}) - - assert_defined(${PROJECT_NAME}_LINK_SEARCH_START_STATIC) - if (${PROJECT_NAME}_LINK_SEARCH_START_STATIC) - #message("${EXE_BINARY_NAME}: Adding property LINK_SEARCH_START_STATIC") - set_property(TARGET ${EXE_BINARY_NAME} PROPERTY LINK_SEARCH_START_STATIC 1) - endif() - - if(PARSE_DIRECTORY) - set_target_properties( ${EXE_BINARY_NAME} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${PARSE_DIRECTORY} ) - endif() - - set_property(TARGET ${EXE_BINARY_NAME} APPEND PROPERTY - LABELS ${PACKAGE_NAME}Exes ${PARENT_PACKAGE_NAME}Exes) - - if(${PROJECT_NAME}_INSTALL_EXECUTABLES AND PARSE_INSTALLABLE) - install( - TARGETS ${EXE_BINARY_NAME} - EXPORT ${PROJECT_NAME} - DESTINATION ${${PROJECT_NAME}_INSTALL_RUNTIME_DIR} - COMPONENT ${PACKAGE_NAME} - ) - endif() -endfunction() - - -# -# Setup include directories and library dependencies -# - -#if (${PROJECT_NAME}_VERBOSE_CONFIGURE) -# message("TribitsAddExecutable.cmake") -# print_var(${PACKAGE_NAME}_INCLUDE_DIRS) -# print_var(${PACKAGE_NAME}_LIBRARY_DIRS) -#endif() -# -#if (NOT TRIBITS_ADD_EXECUTABLE_UNIT_TESTING) -# include_directories(REQUIRED_DURING_INSTALLATION_TESTING -# ${${PACKAGE_NAME}_INCLUDE_DIRS}) -# set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS -# ${${PACKAGE_NAME}_LIBRARY_DIRS}) -#endif() +endmacro() diff --git a/tribits/core/package_arch/TribitsAddExecutableTestHelpers.cmake b/tribits/core/package_arch/TribitsAddExecutableTestHelpers.cmake index 1121de2f3..81cfec436 100644 --- a/tribits/core/package_arch/TribitsAddExecutableTestHelpers.cmake +++ b/tribits/core/package_arch/TribitsAddExecutableTestHelpers.cmake @@ -96,8 +96,9 @@ function( tribits_process_comm_args ADD_SERIAL_FEATURE_OUT ADD_MPI_FEATURE_OUT endfunction() -function( tribits_create_name_from_current_source_directory DIRECTORY_NAME ) - set(DIRECTORY_NAME "") +function(tribits_create_name_from_current_source_directory directoryNameOut) + set(directoryName "") + #Get the unique part of the path for this test directory string(REGEX REPLACE ${PACKAGE_SOURCE_DIR} "" unique_dir_path ${CMAKE_CURRENT_SOURCE_DIR}) @@ -111,8 +112,7 @@ function( tribits_create_name_from_current_source_directory DIRECTORY_NAME ) # compatible with windows since they use a "\" instead of a "/" for # directory delimiters. I'm not sure how this will react if we encounter a # directory name with a space in it. - string(REGEX REPLACE "/" "_" DIRECTORY_NAME ${unique_dir_path}) + string(REGEX REPLACE "/" "_" directoryName "${unique_dir_path}") - #print_var(DIRECTORY_NAME) - set(DIRECTORY_NAME ${DIRECTORY_NAME} PARENT_SCOPE) + set(${directoryNameOut} "${directoryName}" PARENT_SCOPE) endfunction() diff --git a/tribits/core/package_arch/TribitsAddLibrary.cmake b/tribits/core/package_arch/TribitsAddLibrary.cmake new file mode 100644 index 000000000..2d5b742c9 --- /dev/null +++ b/tribits/core/package_arch/TribitsAddLibrary.cmake @@ -0,0 +1,800 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2013 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + +include(TribitsLibIsTestOnly) +include(CMakeParseArguments) +include(GlobalSet) +include(AppendSet) +include(AppendGlob) +include(AppendGlobalSet) +include(AppendStringVar) +include(PrependGlobalSet) +include(RemoveGlobalDuplicates) +include(TribitsGeneralMacros) +include(TribitsReportInvalidTribitsUsage) +include(SetAndIncDirs) + + +# @FUNCTION: tribits_add_library() +# +# Function used to add a CMake library and target using ``add_library()`` and +# also the ALIAS target ``${PACKAGE_NAME}::`` (where ```` is +# the full CMake target name as returned from ``${}``). +# +# Usage:: +# +# tribits_add_library( +# +# [HEADERS

...] +# [HEADERS_INSTALL_SUBDIR ] +# [NOINSTALLHEADERS ...] +# [SOURCES ...] +# [DEPLIBS ...] +# [IMPORTEDLIBS ...] +# [STATIC|SHARED] +# [TESTONLY] +# [NO_INSTALL_LIB_OR_HEADERS] +# [CUDALIBRARY] +# [ADDED_LIB_TARGET_NAME_OUT ] +# ) +# +# *Sections:* +# +# * `Formal Arguments (tribits_add_library())`_ +# * `Include Directories (tribits_add_library())`_ +# * `Install Targets (tribits_add_library())`_ +# * `Additional Library and Source File Properties (tribits_add_library())`_ +# * `Miscellaneous Notes (tribits_add_library())`_ +# +# .. _Formal Arguments (tribits_add_library()): +# +# **Formal Arguments (tribits_add_library())** +# +# ```` +# +# Required base name of the library. The name of the actual library name +# will be prefixed by ``${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}`` to +# produce:: +# +# = ${${PROJECT_NAME}_LIBRARY_NAME_PREFIX} +# +# This is the name passed to ``add_library( ...)``. The +# name is *not* prefixed by the package name. CMake will of course add +# any standard prefix or post-fix to the library file name appropriate for +# the platform and if this is a static or shared library build (e.g. on +# Linux prefix = ``'lib'``, postfix = ``'.so'`` for shared lib and postfix +# = ``'.a'`` static lib) (see documentation for the built-in CMake command +# ``add_library()``. +# +# ``HEADERS

...`` +# +# List of public header files for using this library. By default, these +# header files are assumed to be in the current source directory. They +# can also contain the relative path or absolute path to the files if they +# are not in the current source directory. This list of headers is passed +# into ``add_library(...)`` as well (which is not strictly needed but is +# helpful for some build tools, like MS Visual Studio). By default, these +# headers will be installed (see `Install Targets +# (tribits_add_library())`_). +# +# ``HEADERS_INSTALL_SUBDIR `` +# +# Optional subdirectory that the headers will be installed under the +# standard installation directory. If ``!=""``, then the +# headers will be installed under +# ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``. Otherwise, +# they will be installed under ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``. +# `Install Targets (tribits_add_library())`_. +# +# ``NOINSTALLHEADERS ...`` +# +# List of private header files which are used by this library. These +# headers are not installed and do not needed to be passed in for any +# purpose other than to pass them into ``add_library()`` as some build +# tools like to have these listed (e.g. MS Visual Studio). +# +# ``SOURCES ...`` +# +# List of source files passed into ``add_library()`` that are compiled +# into header files and included in the library. The compiler used to +# compile the files is determined automatically based on the file +# extension (see CMake documentation for ``add_library()``). +# +# ``DEPLIBS ...`` +# +# List of dependent libraries that are built in the current SE package +# that this library is dependent on. These libraries are passed into +# ``target_link_libraries( ...)`` so that CMake knows about +# the dependency structure of the libraries within this SE package. +# **NOTE:** One must **not** list libraries in other upstream `TriBITS SE +# Packages`_ or libraries built externally from this TriBITS CMake project +# in ``DEPLIBS``. The TriBITS system automatically handles linking to +# libraries in upstream TriBITS SE packages. External libraries need to +# be listed in the ``IMPORTEDLIBS`` argument instead if they are not +# already specified automatically using a `TriBITS TPL`_. +# +# ``IMPORTEDLIBS ...`` +# +# List of dependent libraries built externally from this TriBITS CMake +# project. These libraries are passed into +# ``target_link_libraries( ...)`` so that CMake knows about +# the dependency. However, note that external libraries are often better +# handled as `TriBITS TPLs`_. A well constructed TriBITS package and +# library should never have to use this option! So far, the only case +# where ``IMPORTEDLIBS`` has been shown to be necessary is to pass in the +# standard C math library ``m``. In every other case, a TriBITS TPL +# should be used instead. +# +# ``STATIC`` or ``SHARED`` +# +# If ``STATIC`` is passed in, then a static library will be created +# independent of the value of ``BUILD_SHARED_LIBS``. If ``SHARED`` is +# passed in, then a shared library will be created independent of the +# value of ``BUILD_SHARED_LIBS``. If neither ``STATIC`` or ``SHARED`` are +# passed in, then a shared library will be created if +# ``BUILD_SHARED_LIBS`` evaluates to true, otherwise and a static library +# will be created. If both ``STATIC`` and ``SHARED`` are passed in (which +# is obviously a mistake), then a shared library will be created. +# WARNING: Once you mark a library with ``STATIC``, then all of the +# downstream libraries in the current SE package and all downstream SE +# packages must also be also be marked with ``STATIC``. That is because, +# generally, one can not link a link a static lib against a downstream +# shared lib since that is not portable (but can be done on some platforms +# if, for example, ``-fPIC`` is specified). So be careful to use +# ``STATIC`` in all downstream libraries! +# +# ``TESTONLY`` +# +# If passed in, then ```` will **not** be added to +# ``${PACKAGE_NAME}_LIBRARIES`` and an install target for the library will +# not be added. In this case, the current include directories will be set +# in the global variable ``_INCLUDE_DIR`` which will be +# used in `tribits_add_executable()`_ when a test-only library is linked +# in through its ``DEPLIBS`` argument. Also, the custom property +# ``TRIBITS_TESTONLY_LIB`` will be set to ``TRUE`` which will ensure that +# this library will not be added to the ``${PACKAGE_NAME}::all_libs`` +# target. +# +# ``NO_INSTALL_LIB_OR_HEADERS`` +# +# If specified, then no install targets will be added for the library +# ```` or the header files listed in ``HEADERS``. +# +# ``CUDALIBRARY`` +# +# If specified then ``cuda_add_library()`` is used instead of +# ``add_library()`` where ``cuda_add_library()`` is assumed to be defined +# by the standard ``FindCUDA.cmake`` module as processed using the +# standard TriBITS ``FindTPLCUDA.cmake`` file (see `Standard TriBITS +# TPLs`_). For this option to work, this SE package must have an enabled +# direct or indirect dependency on the TriBITS CUDA TPL or a +# configure-time error may occur about not knowing about +# ``cuda_all_library()``. +# +# ``ADDED_LIB_TARGET_NAME_OUT `` +# +# If specified, then on output the variable ```` will be +# set with the name of the library passed to ``add_library()``. Having +# this name allows the calling ``CMakeLists.txt`` file access and set +# additional target properties (see `Additional Library and Source File +# Properties (tribits_add_library())`_). +# +# .. _Include Directories (tribits_add_library()): +# +# **Include Directories (tribits_add_library())** +# +# Any base directories for the header files listed in the arguments +# ``HEADERS`` or ``NOINSTALLHEADERS`` should be passed into the standard CMake +# command ``include_directories()`` **before** calling this function. For +# example, a CMakeLists.txt file will look like:: +# +# ... +# +# tribits_configure_file(${PACKAGE_NAME}_config.h) +# configure_file(...) +# +# ... +# +# include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +# include_directories(${CMAKE_CURRENT_BINARY_DIR}) +# +# ... +# +# tribits_add_library( +# SOURCES +# .c +# /.cpp +# /.F90 +# ... +# HEADERS +# .h +# /.hpp +# ... +# NONINSTALLHEADERS .hpp .hpp ... +# ... +# ) +# +# The include of ``${CMAKE_CURRENT_BINARY_DIR}`` is needed for any generated +# header files (e.g. using raw ``configure_file()`` or +# `tribits_configure_file()`_) or any generated Fortran ``*.mod`` module files +# generated as a byproduct of compiling F90+ source files (that contain one or +# more Fortran module declarations). +# +# The function ``tribits_add_library()`` will grab the list of all of the +# include directories in scope from prior calls to ``include_directories()`` +# and will add this to the generated library target using +# ``target_link_libraries()`` so that they get propagated downstream as well. +# +# .. _Install Targets (tribits_add_library()): +# +# **Install Targets (tribits_add_library())** +# +# By default, an install target for the library is created using +# ``install(TARGETS ...)`` to install into the directory +# ``${CMAKE_INSTALL_PREFIX}/lib/`` (actual install directory is given by +# ``${PROJECT}_INSTALL_LIB_DIR``, see `Setting the install prefix`_). +# However, this install target will not get created if +# `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE`` and +# ``BUILD_SHARD_LIBS=OFF``. But when ``BUILD_SHARD_LIBS=ON``, the install +# target will get added. Also, this install target will *not* get added if +# ``TESTONLY`` or ``NO_INSTALL_LIB_OR_HEADERS`` are passed in. +# +# By default, an install target for the headers listed in ``HEADERS`` will get +# added using ``install(FILES

...)``, but only if ``TESTONLY`` and +# ``NO_INSTALL_LIB_OR_HEADERS`` are not passed in as well. Also, the install +# target for the headers will not get added if +# `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE``. If this +# install target is added, then the headers get installed into the flat +# directory ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/`` (default is +# ``${CMAKE_INSTALL_PREFIX}/include/``, see `Setting the install prefix`_). +# If ``HEADERS_INSTALL_SUBDIR`` is set, then the headers will be installed +# under ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}//``. +# +# Note that an install target will *not* get created for the headers listed in +# ``NOINSTALLHEADERS``. +# +# .. _Additional Library and Source File Properties (tribits_add_library()): +# +# **Additional Library and Source File Properties (tribits_add_library())** +# +# Once ``add_library( ... ...)`` is called, one +# can set and change properties on the ```` library target +# using the built-in CMake command ``set_target_properties()`` as well as set +# and change properties on any of the source files listed in ``SOURCES`` using +# the built-in CMake command ``set_source_file_properties()`` just like in any +# CMake project. For example:: +# +# tribits_add_library( somelib ... +# ADDED_LIB_TARGET_NAME_OUT somelib_TARGET_NAME ) +# +# set_target_properties( ${somelib_TARGET_NAME} +# PROPERTIES LINKER_LANGUAGE CXX ) +# +# .. _Miscellaneous Notes (tribits_add_library()): +# +# **Miscellaneous Notes (tribits_add_library())** +# +# When the file ``Version.cmake`` exists and the CMake variables +# ``${PROJECT_NAME}_VERSION`` and ``${PROJECT_NAME}_MAJOR_VERSION`` are +# defined, then produced shared libraries will be given the standard SOVERSION +# symlinks (see `/Version.cmake`_). +# +# **WARNING:** Do **NOT** use the built-in CMake command ``add_definitions()`` +# to add defines ``-D`` to the compile command line that will +# affect any of the header files in the package! These CMake-added defines +# are only set locally in this directory and child directories. These defines +# will **NOT** be set when code in peer directories (e.g. a downstream TriBITS +# packages) compiles that may include these header files. To add defines that +# affect header files, please use a configured header file (see +# `tribits_configure_file()`_). +# +function(tribits_add_library LIBRARY_NAME_IN) + + tribits_add_library_assert_correct_call_context() + + # Set library prefix and name + + set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") + set(LIBRARY_NAME ${LIBRARY_NAME_PREFIX}${LIBRARY_NAME_IN}) + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("\nTRIBITS_ADD_LIBRARY: ${LIBRARY_NAME}") + if(${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) + message("\n${PACKAGE_NAME}_LIBRARIES In installation testing mode," + " libraries will be found instead of created.") + endif() + print_var(${PACKAGE_NAME}_LIBRARIES) + endif() + + # Parse input args + + cmake_parse_arguments( + #prefix + PARSE + #Options + "STATIC;SHARED;TESTONLY;NO_INSTALL_LIB_OR_HEADERS;CUDALIBRARY" + #one_value_keywords + "" + #mulit_value_keywords + "HEADERS;HEADERS_INSTALL_SUBDIR;NOINSTALLHEADERS;SOURCES;DEPLIBS;IMPORTEDLIBS;DEFINES;ADDED_LIB_TARGET_NAME_OUT" + ${ARGN} + ) + + tribits_check_for_unparsed_arguments() + + # ToDo: Assert that HEADERS_INSTALL_SUBDIR has 0 or 1 entries! + # ToDo: Assert that ADDED_LIB_TARGET_NAME_OUT as 0 or 1 entries! + + if(PARSE_HEADERS) + list(REMOVE_DUPLICATES PARSE_HEADERS) + endif() + if(PARSE_SOURCES) + list(REMOVE_DUPLICATES PARSE_SOURCES) + endif() + + # Library not added by default + if(PARSE_ADDED_LIB_TARGET_NAME_OUT) + set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} "" PARENT_SCOPE) + endif() + + # + # Create library target if not doing installation testing or if this is a + # TESTONLY library. + # + + if (NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING OR PARSE_TESTONLY) + + if (PARSE_DEPLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "DEPLIBS = ${PARSE_DEPLIBS}") + endif() + if (PARSE_IMPORTEDLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "IMPORTEDLIBS = ${PARSE_IMPORTEDLIBS}") + endif() + + # Assert DEPLIBS and IMPORTEDLIBS + + tribits_add_library_assert_deplibs() + tribits_add_library_assert_importedlibs() + + # Add the library and all the dependencies + + if (PARSE_DEFINES) + add_definitions(${PARSE_DEFINES}) + endif() + + if (PARSE_STATIC) + set(STATIC_KEYWORD "STATIC") + else() + set(STATIC_KEYWORD "") + endif() + + if (PARSE_SHARED) + set(SHARED_KEYWORD "SHARED") + else() + set(SHARED_KEYWORD "") + endif() + + if (NOT PARSE_CUDALIBRARY) + add_library( + ${LIBRARY_NAME} + ${STATIC_KEYWORD} + ${SHARED_KEYWORD} + ${PARSE_HEADERS} + ${PARSE_NOINSTALLHEADERS} + ${PARSE_SOURCES} + ) + else() + cuda_add_library( + ${LIBRARY_NAME} + ${PARSE_HEADERS} + ${PARSE_NOINSTALLHEADERS} + ${PARSE_SOURCES} + ) + endif() + + if(PARSE_ADDED_LIB_TARGET_NAME_OUT) + set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} ${LIBRARY_NAME} PARENT_SCOPE) + endif() + + if (PARSE_TESTONLY) + tribits_set_lib_is_testonly(${LIBRARY_NAME}) + endif() + + set_property( + TARGET ${LIBRARY_NAME} + APPEND PROPERTY + LABELS ${PACKAGE_NAME}Libs ${PARENT_PACKAGE_NAME}Libs + ) + + if (NOT "${${PROJECT_NAME}_VERSION}" STREQUAL "" AND + NOT "${${PROJECT_NAME}_MAJOR_VERSION}" STREQUAL "" + ) + set_target_properties( + ${LIBRARY_NAME} + PROPERTIES + VERSION ${${PROJECT_NAME}_VERSION} + SOVERSION ${${PROJECT_NAME}_MAJOR_VERSION} + ) + endif() + + prepend_global_set(${PARENT_PACKAGE_NAME}_LIB_TARGETS ${LIBRARY_NAME}) + prepend_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${LIBRARY_NAME}) + + # + # Link ${LIBRARY_NAME} to direct upstream libraries + # + + # DEPLIBS + foreach(depLib ${PARSE_DEPLIBS}) + target_link_libraries(${LIBRARY_NAME} PUBLIC "${LIBRARY_NAME_PREFIX}${depLib}") + endforeach() + # ${PACKAGE_NAME}_LIBRARIES + target_link_libraries(${LIBRARY_NAME} PUBLIC ${${PACKAGE_NAME}_LIBRARIES}) + # ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES + foreach(depPkg IN LISTS ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES) + target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) + endforeach() + # ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES + foreach(depPkg IN LISTS ${PACKAGE_NAME}_TEST_ENABLED_DEPENDENCIES) + target_link_libraries(${LIBRARY_NAME} PUBLIC ${depPkg}::all_libs) + endforeach() + # IMPORTEDLIBS + foreach(importedLib ${PARSE_IMPORTEDLIBS}) + target_link_libraries(${LIBRARY_NAME} PUBLIC "${importedLib}") + endforeach() + + # ToDo: #63: Above, allow for other link visibilities other than 'PUBLIC'! + + if (${PROJECT_NAME}_CXX_STANDARD_FEATURE) + target_compile_features(${LIBRARY_NAME} PUBLIC + "${${PROJECT_NAME}_CXX_STANDARD_FEATURE}") + endif() + + # Add to the install target + + tribits_add_library_determine_install_lib_and_or_headers( + installLib installHeaders appendLibAndHeadersToPackageVars) + + if (installLib OR installHeaders) + set_property(GLOBAL PROPERTY ${PROJECT_NAME}_HAS_INSTALL_TARGETS ON) + set_property(GLOBAL PROPERTY ${PACKAGE_NAME}_HAS_INSTALL_TARGETS ON) + endif() + + if (installLib) + install( + TARGETS ${LIBRARY_NAME} + EXPORT ${PACKAGE_NAME} + INCLUDES DESTINATION "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}" + RUNTIME DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_DIR}" + LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}" + ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}" + COMPONENT ${PACKAGE_NAME} + ) + endif() + + if (installHeaders) + tribits_install_headers( + HEADERS ${PARSE_HEADERS} + INSTALL_SUBDIR ${PARSE_HEADERS_INSTALL_SUBDIR} + COMPONENT ${PACKAGE_NAME} + ) + endif() + + # Append the new libraries to this package's lists + + if (appendLibAndHeadersToPackageVars) + prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${PACKAGE_NAME}::${LIBRARY_NAME}) + remove_global_duplicates(${PACKAGE_NAME}_LIBRARIES) + if (installLib) + global_set(${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES_TO_INSTALL TRUE) + endif() + else() + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping augmentation of package's lists of libraries! ...") + endif() + endif() + + # Set INTERFACE_INCLUDE_DIRECTORIES property for added library and must + # only do for the build interface (not the install interface). + get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) + set(buildInterfaceIncludeDirs) + foreach (includeDir IN LISTS INCLUDE_DIRS_CURRENT) + list(APPEND buildInterfaceIncludeDirs "$") + endforeach() + target_include_directories( ${LIBRARY_NAME} PUBLIC ${buildInterfaceIncludeDirs} ) + + # Add ALIAS library :: + add_library(${PACKAGE_NAME}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME}) + + # Optionally Set IMPORTED_NO_SYSTEM + if (${PROJECT_NAME}_IMPORTED_NO_SYSTEM) + set_target_properties(${LIBRARY_NAME} PROPERTIES IMPORTED_NO_SYSTEM TRUE) + endif() + + endif() #if not in installation testing mode + + # Adjust for installation testing + + if (${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) + list(FIND ${PROJECT_NAME}_INSTALLATION_PACKAGE_LIST ${PACKAGE_NAME} + ${PACKAGE_NAME}_WAS_INSTALLED) + if(${${PACKAGE_NAME}_WAS_INSTALLED} EQUAL -1) + message(FATAL_ERROR + "The package ${PACKAGE_NAME} was not installed with ${PROJECT_NAME}!" + " Please disable package ${PACKAGE_NAME} or install it.") + endif() + global_set(${PACKAGE_NAME}_LIBRARIES ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) + endif() + + # Print the updates to the linkage variables + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + print_var(${PACKAGE_NAME}_LIBRARIES) + endif() + +endfunction() +# +# ToDo:, above Deprecate and remove the usage of DEFINES! People should be +# putting defines into configured header files, not adding -D to +# the compile lines! + + +# Function that asserts that tribits_add_library() is called in the correct +# context +# +function(tribits_add_library_assert_correct_call_context) + + if (CURRENTLY_PROCESSING_SUBPACKAGE) + + # This is a subpackage being processed + + if(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_subpackage() before tribits_add_library()" + " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + endif() + + if(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_add_library() before " + " tribits_subpackage_postprocess() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + endif() + + else() + + # This is a package being processed + + if(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_package() or tribits_package_decl() before" + " tribits_add_library() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") + endif() + + if(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) + tribits_report_invalid_tribits_usage( + "Must call tribits_add_library() before " + " tribits_package_postprocess() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") + endif() + + endif() + +endfunction() + + +# Assert correct DEPSLIB passed to tribits_add_library() +# +# NOTE: This accesses vars from the enclosed calling function +# tribits_add_library() but does not set any variables in that scope! +# +# We also need to make special considerations for test libraries since +# things need to be handled a little bit differently (but not much). In the +# case of test libraries, we need to also pull the test-only dependencies. +# In this case, we will always assume that we will add in the test +# libraries. +# +# ToDo: Turn the below deprecated WARNING messages to FATAL_ERROR once we +# give enough time for people to clean up their codes. +# +function(tribits_add_library_assert_deplibs) + + foreach(depLib ${PARSE_DEPLIBS}) + + set(prefixedDepLib "${LIBRARY_NAME_PREFIX}${depLib}") + + # Is this lib already listed in ${PACKAGE_NAME}_LIBS? + list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${prefixedDepLib}" FOUND_IDX) + if (FOUND_IDX GREATER -1) + set(depLibAlreadyInPkgLibs TRUE) + else() + set(depLibAlreadyInPkgLibs FALSE) + endif() + + # ${PREFIXED_LIB" is TESTONLY? + tribits_lib_is_testonly(${prefixedDepLib} depLibIsTestOnlyLib) + + # Check for valid usage (sorted by most common to least common) + if (depLibAlreadyInPkgLibs AND NOT depLibIsTestOnlyLib) # PARSE_TESTONLY=any + # The library being created here is a (regular or testonly) library + # dependent on a regular (non-TESTONLY) lib in this package. This is + # valid usage of DEPLIBS. There is no need to link this new lib to + # the package's upstream dependent package and TPL libraries because + # these are already linked into one of the of the package's own + # upstream libs. + elseif (PARSE_TESTONLY AND depLibAlreadyInPkgLibs AND NOT depLibIsTestOnlyLib) + # The library being created here is TESTONLY library and is + # dependent on a regular (non-TESTONLY) lib. This is valid usage of + # DEPLIBS. In the case of test-only libraries, we always link in + # the upstream libs. + elseif (PARSE_TESTONLY AND depLibIsTestOnlyLib) # any depLibAlreadyInPkgLibs + # The library being created here is TESTONLY library and is dependent + # on another TESTONLY library. This is valid usage of DEPLIBS. In + # this case we just hope that this package correctly specified a TEST + # dependency on the upstream package that owns this upstream TESTONLY + # library if it comes from an upstream package. + elseif (NOT PARSE_TESTONLY AND depLibIsTestOnlyLib) # any depLibAlreadyInPkgLibs + message(WARNING "WARNING: '${depLib}' in DEPLIBS is a TESTONLY lib" + " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." + " Such usage is deprecated (and this warning will soon become an error)!" + " If this is a regular library in this package or in an dependent upstream" + " package then TriBITS will link automatically to it. If you remove this and it" + " does not link, then you need to add a new package dependency to" + " this package's dependencies file" + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") + # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code + elseif (NOT depLibAlreadyInPkgLibs AND TARGET ${prefixedDepLib}) # any PARSE_TESTONLY + message(WARNING "WARNING: '${depLib}' in DEPLIBS is not" + " a lib in this package but is a library defined in the current" + " cmake project! Such usage is deprecated (and" + " will result in a configure error soon). If this is a library in" + " a dependent upstream package, then simply remove '${depLib}' from this list." + " TriBITS automatically links in libraries in upstream packages." + " If you remove '${depLib}' from DEPLIBS and your code does" + " not link, then you need to add a new package dependency to" + " this package's dependencies file" + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake.") + elseif (NOT depLibAlreadyInPkgLibs AND NOT TARGET ${prefixedDepLib} ) + message(WARNING "WARNING: '${depLib}' in DEPLIBS is not" + " a lib defined in the current cmake project! Such usage is deprecated (and" + " will result in a configure error soon). If this is an external" + " lib you are trying to link in, it should likely be handled as a TriBITS" + " TPL. Otherwise, it should be passed in through IMPORTEDLIBS. However," + " the only case we have found where IMPORTEDLIBS had to be used instead of" + " through a proper TriBITS TPL is the C math library 'm'.") + else() + message(WARNING "WARNING: The case PARSE_TESTONLY=${PARSE_TESTONLY}," + " depLibAlreadyInPkgLibs=${depLibAlreadyInPkgLibs}," + " depLibIsTestOnlyLib=${depLibIsTestOnlyLib}, has" + " not yet been handled!") + endif() + + endforeach() + +endfunction() + + +# Assert correct IMPORTEDLIBS passed to tribits_add_library() +# +# NOTE: This accesses vars from the enclosed calling function +# tribits_add_library() but does not set any variables in that scope! +# +# ToDo: Turn the below deprecated WARNING messages to FATAL_ERROR once we +# give enough time for people to clean up their codes. +# +function(tribits_add_library_assert_importedlibs) + foreach(importedLib ${PARSE_IMPORTEDLIBS}) + set(prefixedImportedLib "${LIBRARY_NAME_PREFIX}${importedLib}") + list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${prefixedImportedLib}" + FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX) + tribits_lib_is_testonly(${prefixedImportedLib} importedLibIsTestOnlyLib) + if (importedLibIsTestOnlyLib) + message(WARNING "WARNING: '${importedLib}' in IMPORTEDLIBS is a TESTONLY lib" + " and it is illegal to pass in through IMPORTEDLIBS!" + " Such usage is deprecated (and this warning will soon become an error)!" + " Should '${importedLib}' instead be passed through DEPLIBS?") + # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code + elseif (FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX GREATER -1) + message(WARNING "WARNING: Lib '${importedLib}' in IMPORTEDLIBS is in" + " this package and is *not* an external lib!" + " Please move '${importedLib}' from the list IMPORTEDLIBS to DEPLIBS.") + elseif (TARGET ${prefixedImportedLib}) + message(WARNING "WARNING: Lib '${importedLib}' being passed through" + " IMPORTEDLIBS is *not* an external library but instead is a library" + " defined in this CMake project!" + " TriBITS takes care of linking against libraries in dependent upstream" + " packages. If you want to link to a library in an upstream" + " package then add the package name to the appropriate category" + " in this package's dependencies file: " + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake.") + endif() + endforeach() +endfunction() + + +# Determine lib and/or headers should be installed and if the package vars +# should be updated +# +# NOTE: This reads the parsed arguments (prefixed with ``PARSE_``) from the +# calling tribits_add_library() function from the enclosing scope. +# +function(tribits_add_library_determine_install_lib_and_or_headers + installLibOut installHeadersOut appendLibAndHeadersToPackageVarsOut + ) + + set(installLib ON) + set(installHeaders ON) + set(appendLibAndHeadersToPackageVars ON) + + if (PARSE_TESTONLY) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation hooks for this library" + " because 'TESTONLY' was passed in ...") + endif() + set(installLib OFF) + set(installHeaders OFF) + set(appendLibAndHeadersToPackageVars OFF) + elseif (PARSE_NO_INSTALL_LIB_OR_HEADERS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation hooks for this library" + " because 'NO_INSTALL_LIB_OR_HEADERS' was passed in ...") + endif() + set(installLib OFF) + set(installHeaders OFF) + elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND NOT BUILD_SHARED_LIBS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation of headers and libraries" + " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and" + " BUILD_SHARED_LIBS=FALSE ...") + endif() + set(installLib OFF) + set(installHeaders OFF) + elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND BUILD_SHARED_LIBS) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Skipping installation of headers but installing libraries" + " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and" + " BUILD_SHARED_LIBS=TRUE ...") + endif() + set(installHeaders OFF) + endif() + + set(${installLibOut} ${installLib} PARENT_SCOPE) + set(${installHeadersOut} ${installHeaders} PARENT_SCOPE) + set(${appendLibAndHeadersToPackageVarsOut} ${appendLibAndHeadersToPackageVars} + PARENT_SCOPE) + +endfunction() diff --git a/tribits/core/package_arch/TribitsAddTest.cmake b/tribits/core/package_arch/TribitsAddTest.cmake index df5f25daf..1c355e30c 100644 --- a/tribits/core/package_arch/TribitsAddTest.cmake +++ b/tribits/core/package_arch/TribitsAddTest.cmake @@ -877,20 +877,20 @@ function(tribits_add_test EXE_NAME) # If requested create a modifier for the name that will be inserted between # the package name and the given name or exe_name for the test - set(DIRECTORY_NAME "") - if(PARSE_ADD_DIR_TO_NAME) - tribits_create_name_from_current_source_directory(DIRECTORY_NAME) - set(DIRECTORY_NAME "${DIRECTORY_NAME}_") + set(directoryName "") + if (PARSE_ADD_DIR_TO_NAME) + tribits_create_name_from_current_source_directory(directoryName) + set(directoryName "${directoryName}_") endif() #message("TRIBITS_ADD_TEST: ${EXE_NAME}: EXE_BINARY_NAME = ${EXE_BINARY_NAME}") if (PARSE_NAME) - set(TEST_NAME "${DIRECTORY_NAME}${PARSE_NAME}") + set(TEST_NAME "${directoryName}${PARSE_NAME}") elseif (PARSE_NAME_POSTFIX) - set(TEST_NAME "${DIRECTORY_NAME}${EXE_NAME}_${PARSE_NAME_POSTFIX}") + set(TEST_NAME "${directoryName}${EXE_NAME}_${PARSE_NAME_POSTFIX}") else() - set(TEST_NAME "${DIRECTORY_NAME}${EXE_NAME}") + set(TEST_NAME "${directoryName}${EXE_NAME}") endif() set(TEST_NAME "${PACKAGE_NAME}_${TEST_NAME}") diff --git a/tribits/core/package_arch/TribitsCommonArgsHelpers.cmake b/tribits/core/package_arch/TribitsCommonArgsHelpers.cmake index a6370f153..9aaffca98 100644 --- a/tribits/core/package_arch/TribitsCommonArgsHelpers.cmake +++ b/tribits/core/package_arch/TribitsCommonArgsHelpers.cmake @@ -55,7 +55,9 @@ function(tribits_set_linker_language_from_arg TARGET_NAME_IN LINKER_LANGUAGE_I if (LINKER_LANGUAGE) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE OR TRIBITS_SET_LINKER_LANGUAGE_FROM_ARG_DEBUG_DUMP) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE + OR TRIBITS_SET_LINKER_LANGUAGE_FROM_ARG_DEBUG_DUMP + ) message("-- Setting linker language for target '${TARGET_NAME_IN}' to '${LINKER_LANGUAGE}'") endif() @@ -63,6 +65,7 @@ function(tribits_set_linker_language_from_arg TARGET_NAME_IN LINKER_LANGUAGE_I TARGET ${TARGET_NAME_IN} APPEND PROPERTY LINKER_LANGUAGE ${LINKER_LANGUAGE} ) + endif() endfunction() diff --git a/tribits/core/package_arch/TribitsConfigureFile.cmake b/tribits/core/package_arch/TribitsConfigureFile.cmake new file mode 100644 index 000000000..55ac9123c --- /dev/null +++ b/tribits/core/package_arch/TribitsConfigureFile.cmake @@ -0,0 +1,180 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2013 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + + + +# Macro that configures the package's main config.h file +# +function(tribits_add_config_define DEFINE) + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- " "Package ${PARENT_PACKAGE_NAME}: adding compiler" + " define to config file: ${DEFINE}") + endif() + global_set(${PARENT_PACKAGE_NAME}_CONFIG_DEFINES + "${${PARENT_PACKAGE_NAME}_CONFIG_DEFINES}\n#define ${DEFINE}") + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("-- ${${PARENT_PACKAGE_NAME}_CONFIG_DEFINES}") + endif() +endfunction() + + +# @FUNCTION: tribits_configure_file() +# +# Macro that configures the package's main configured header file (typically +# called ``${PACKAGE_NAME}_config.h`` but any name can be used). +# +# Usage:: +# +# tribits_configure_file() +# +# This function requires the file:: +# +# ${PACKAGE_SOURCE_DIR}/cmake/.in +# +# exists and it creates the file:: +# +# ${CMAKE_CURRENT_BINARY_DIR}/ +# +# by calling the built-in ``configure_file()`` command:: +# +# configure_file( +# ${PACKAGE_SOURCE_DIR}/cmake/.in +# ${CMAKE_CURRENT_BINARY_DIR}/ +# ) +# +# which does basic substitution of CMake variables (see documentation for +# built-in CMake `configure_file()`_ command for rules on how it performs +# substitutions). This command is typically used to configure the package's +# main `/cmake/_config.h.in`_ file. +# +# In addition to just calling ``configure_file()``, this function also aids in +# creating configured header files adding macros for deprecating code as +# described below. +# +# **Deprecated Code Macros** +# +# If ``${PARENT_PACKAGE_NAME}_SHOW_DEPRECATED_WARNINGS`` is ``TRUE`` (see +# `tribits_add_show_deprecated_warnings_option()`_), then the local CMake +# variable ``${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS`` is set which +# adds a define ``_DEPRECATED`` (where +# ```` is the package name in all upper-case letters) +# which adds a compiler-specific deprecated warning for an entity. To take +# advantage of this, just add the line:: +# +# @_DEPRECATED_DECLARATIONS@ +# +# to the ``.in`` file and it will be expanded at configure +# time. +# +# Then C/C++ code can use this macro to deprecate functions, variables, +# classes, etc., for example, using:: +# +# _DEPRECATED class SomeDepreatedClass { ... }. +# +# If the particular compiler does not support deprecated warnings, then this +# macro is defined to be empty. See `Regulated Backward Compatibility and +# Deprecated Code`_ for more details. +# +function(tribits_configure_file PACKAGE_NAME_CONFIG_FILE) + + if (${PROJECT_NAME}_VERBOSE_CONFIGURE) + message("\nPACKAGE_CONFIGURE_FILE: ${PACKAGE_NAME_CONFIG_FILE}") + endif() + + # Set up the deprecated attribute if showing deprecated warnings + if (${PARENT_PACKAGE_NAME}_SHOW_DEPRECATED_WARNINGS) + multiline_set(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS + "#ifndef ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" + "# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED __attribute__((__deprecated__))\n" + "# else\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" + "# endif\n" + "#endif\n" + "\n" + "#ifndef ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG\n" + "# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG) __attribute__((__deprecated__ (#MSG) ))\n" + "# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG) __attribute__((__deprecated__))\n" + "# else\n" + "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG)\n" + "# endif\n" + "#endif\n" + ) + else() + multiline_set(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS + "#define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" + "#define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG)\n" + ) + endif() + + if (${PARENT_PACKAGE_NAME}_HIDE_DEPRECATED_CODE) + string(APPEND ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS + "\n#define ${PARENT_PACKAGE_NAME_UC}_HIDE_DEPRECATED_CODE") + endif() + + # Set up the macro to create the define for time monitor + set(TIME_MONITOR_DEFINE_NAME ${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR) + set(FUNC_TIME_MONITOR_MACRO_NAME ${PARENT_PACKAGE_NAME_UC}_FUNC_TIME_MONITOR) + set(FUNC_TIME_MONITOR_DIFF_MACRO_NAME ${PARENT_PACKAGE_NAME_UC}_FUNC_TIME_MONITOR_DIFF) + if (${PARENT_PACKAGE_NAME}_ENABLE_TEUCHOS_TIME_MONITOR) + multiline_set(${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR_DECLARATIONS + "#ifndef ${FUNC_TIME_MONITOR_MACRO_NAME}\n" + "# define ${TIME_MONITOR_DEFINE_NAME}\n" + "# define ${FUNC_TIME_MONITOR_MACRO_NAME}(FUNCNAME) \\\n" + " TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, ${PARENT_PACKAGE_NAME_UC})\n" + "# define ${FUNC_TIME_MONITOR_DIFF_MACRO_NAME}(FUNCNAME, DIFF) \\\n" + " TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, DIFF)\n" + "#endif\n" + ) + else() + multiline_set(${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR_DECLARATIONS + "#define ${FUNC_TIME_MONITOR_MACRO_NAME}(FUNCNAME)\n" + "#define ${FUNC_TIME_MONITOR_DIFF_MACRO_NAME}(FUNCNAME, DIFF)\n" + ) + endif() + + # Configure the file + configure_file( + ${PACKAGE_SOURCE_DIR}/cmake/${PACKAGE_NAME_CONFIG_FILE}.in + ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_CONFIG_FILE} + ) + +endfunction() diff --git a/tribits/core/package_arch/TribitsGeneralMacros.cmake b/tribits/core/package_arch/TribitsGeneralMacros.cmake index 16471366e..bd05810ae 100644 --- a/tribits/core/package_arch/TribitsGeneralMacros.cmake +++ b/tribits/core/package_arch/TribitsGeneralMacros.cmake @@ -40,6 +40,7 @@ include(AppendSet) include(AssertDefined) include(MessageWrapper) +include(TribitsParseArgumentsHelpers) include(TribitsSortListAccordingToMasterList) @@ -372,150 +373,6 @@ function( tribits_gather_enabled_items PACKAGE_NAME LISTTYPE_PREFIX endfunction() -# Function that appends the Package/TPL include and library paths for given -# list of enabled Packages/TPLs -# -# As a side effect of calling this function, include_directories(...) to set -# all of the include directories for a given set of enabled Packages/TPLs. -# -# NOTE: The Packages/TPLs should be sorted in descending dependency order -# before calling this function. -# -# NOTE: Because this function may be called in cases where a package's -# required subpackages are not actually enabled (e.g. SEACAS subpackages) -# -function( tribits_append_include_and_link_dirs TPL_OR_PACKAGE PREFIX - LIST EXTRA_DEP_LIBS_INOUT - ) - if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) - message("\nTRIBITS_APPEND_INCLUDE_AND_LINK_DIRS: '${TPL_OR_PACKAGE}'" - " '${PREFIX}' '${LIST}' '${EXTRA_DEP_LIBS_INOUT}'") - endif() - set(EXTRA_DEP_LIBS_INOUT_TMP ${${EXTRA_DEP_LIBS_INOUT}}) - cmake_policy(SET CMP0054 NEW) - if ( - "${TPL_OR_PACKAGE}" STREQUAL "TPL" - AND - ( - ${PROJECT_NAME}_TPL_SYSTEM_INCLUDE_DIRS - AND NOT - (${PARENT_PACKAGE_NAME}_SKIP_TPL_SYSTEM_INCLUDE_DIRS - OR ${PACKAGE_NAME}_SKIP_TPL_SYSTEM_INCLUDE_DIRS) - ) - ) - set(SYSTEM_ARG "SYSTEM") - else() - set(SYSTEM_ARG) - endif() - foreach(ITEM ${LIST}) - if (${PREFIX}${ITEM}_LIBRARIES) - append_set(EXTRA_DEP_LIBS_ARG_TMP ${${PREFIX}${ITEM}_LIBRARIES}) - endif() - if (${PREFIX}${ITEM}_INCLUDE_DIRS) - if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) - message("-- " "include_directories(${SYSTEM_ARG} ${${PREFIX}${ITEM}_INCLUDE_DIRS})") - endif() - include_directories(${SYSTEM_ARG} ${${PREFIX}${ITEM}_INCLUDE_DIRS}) - endif() - if (${PREFIX}${ITEM}_LIBRARY_DIRS) - if (PREFIX) - # TODO: Is there a better way to know if we need this? - # We want LINK_DIRECTORIES for TPLs but not packages. - link_directories(${${PREFIX}${ITEM}_LIBRARY_DIRS}) - endif() - set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - ${${PREFIX}${ITEM}_LIBRARY_DIRS}) - endif() - if (TRIBITS_APPEND_INCLUDE_AND_LINK_DIRS_DEBUG_DUMP) - print_var(${PREFIX}${ITEM}_LIBRARIES) - print_var(${PREFIX}${ITEM}_INCLUDE_DIRS) - print_var(${PREFIX}${ITEM}_LIBRARY_DIRS) - endif() - endforeach() - set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_ARG_TMP} PARENT_SCOPE) -endfunction() - - -# Function that sorts and appends all the items in a dependency list for -# packages or TPLs. -# -function( tribits_sort_and_append_include_and_link_dirs_and_libs - TPL_OR_PACKAGE MASTER_SORT_LIST LIST PREFIX - EXTRA_DEP_LIBS_INOUT - ) - - if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) - message("TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS:") - print_var(MASTER_SORT_LIST) - print_var(LIST) - print_var(PREFIX) - print_var(EXTRA_DEP_LIBS_INOUT) - endif() - - set(LOCAL_LIST ${LIST}) - if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) - print_var(LOCAL_LIST) - endif() - - if (LOCAL_LIST) - - tribits_sort_list_according_to_master_list("${MASTER_SORT_LIST}" LOCAL_LIST) - if (TRIBITS_SORT_AND_APPEND_INCLUDE_AND_LINK_DIRS_AND_LIBS_DEBUG_DUMP) - print_var(LOCAL_LIST) - endif() - - set(EXTRA_DEP_LIBS_ARG_TMP ${${EXTRA_DEP_LIBS_INOUT}}) - tribits_append_include_and_link_dirs("${TPL_OR_PACKAGE}" "${PREFIX}" - "${LOCAL_LIST}" EXTRA_DEP_LIBS_ARG_TMP) - set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_ARG_TMP} PARENT_SCOPE) - - endif() - -endfunction() - - -# Fully process the include and link directories and list of libraries for a -# package's list of dependent packages for use in creating a library or an -# executable -# -function( tribits_sort_and_append_package_include_and_link_dirs_and_libs - PACKAGE_NAME LIB_OR_TEST_ARG EXTRA_DEP_LIBS_INOUT - ) - - tribits_gather_enabled_items(${PACKAGE_NAME} ${LIB_OR_TEST_ARG} - PACKAGES ALL_DEP_PACKAGES) - - set(EXTRA_DEP_LIBS_TMP ${${EXTRA_DEP_LIBS_INOUT}}) - tribits_sort_and_append_include_and_link_dirs_and_libs( - "PACKAGE" - "${${PROJECT_NAME}_REVERSE_ENABLED_SE_PACKAGES}" - "${ALL_DEP_PACKAGES}" "" EXTRA_DEP_LIBS_TMP) - set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_TMP} PARENT_SCOPE) - -endfunction() - - -# Fully process the include and link directories and list of libraries for a -# package's list of dependent TPLs for use in creating a library or an -# executable -# -function( tribits_sort_and_append_tpl_include_and_link_dirs_and_libs - PACKAGE_NAME LIB_OR_TEST_ARG EXTRA_DEP_LIBS_INOUT - ) - - tribits_gather_enabled_items(${PACKAGE_NAME} ${LIB_OR_TEST_ARG} - TPLS ALL_TPLS) - - set(EXTRA_DEP_LIBS_TMP ${${EXTRA_DEP_LIBS_INOUT}}) - tribits_sort_and_append_include_and_link_dirs_and_libs( - "TPL" - "${${PROJECT_NAME}_REVERSE_ENABLED_TPLS}" - "${ALL_TPLS}" TPL_ EXTRA_DEP_LIBS_TMP) - set(${EXTRA_DEP_LIBS_INOUT} ${EXTRA_DEP_LIBS_TMP} PARENT_SCOPE) - -endfunction() - - # Print trace of file processing # function(tribits_trace_file_processing TYPE_IN PROCESSING_TYPE_IN FILE_PATH) @@ -555,62 +412,3 @@ function(tribits_trace_file_processing TYPE_IN PROCESSING_TYPE_IN FILE_PATH) endfunction() -# Check to see if there are unparsed arguments after calling -# cmake_parse_arguments() or tribits_parse_arguments_from_lsit() -# -# Usage:: -# -# tribits_check_for_unparsed_arguments([]) -# -# If `` is not given, it is assumed to be `PARSE`. -# -function(tribits_check_for_unparsed_arguments) - - if ("${ARGC}" GREATER 1) - MESSAGE(FATAL_ERROR - "ERROR tribits_check_for_unparsed_arguments() passed arguments '${ARGV}' but only accepts 0 or 1 arguments (for the )") - endif() - - set(prefix "PARSE") - foreach(arg ${ARGV}) - set(prefix "${arg}") - endforeach() - - if( NOT "${${prefix}_UNPARSED_ARGUMENTS}" STREQUAL "") - message_wrapper( - ${${PROJECT_NAME}_CHECK_FOR_UNPARSED_ARGUMENTS} - "Arguments passed in unrecognized. ${prefix}_UNPARSED_ARGUMENTS = '${${prefix}_UNPARSED_ARGUMENTS}'" - ) - endif() - -endfunction() - - -# Check that a parase argument has at least one value -# -macro(tribits_assert_parse_arg_one_or_more_values PREFIX ARGNAME) - set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") - list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) - if (ARG_NUM_VALS LESS 1) - message_wrapper(FATAL_ERROR - "ERROR: ${ARGNAME} must have at least one value!" ) - return() - # NOTE: The return is needed in unit testing mode - endif() -endmacro() - - -# Check that a parase argument has zero or one value -# -macro(tribits_assert_parse_arg_zero_or_one_value PREFIX ARGNAME) - set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") - if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") - list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) - if (ARG_NUM_VALS GREATER 1) - message_wrapper(FATAL_ERROR - "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' can not have more than one value!" ) - return() - # NOTE: The return is needed in unit testing mode - endif() - endif() -endmacro() diff --git a/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake b/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake new file mode 100644 index 000000000..9d4943dc8 --- /dev/null +++ b/tribits/core/package_arch/TribitsGitRepoVersionInfo.cmake @@ -0,0 +1,187 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2013 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + +################################################################################ +# +# Module containing functions for getting Git repo information +# +################################################################################ + + +# @FUNCTION: tribits_git_repo_sha1() +# +# Get the Git repo version SHA1. +# +# Usage:: +# +# tribits_git_repo_sha1( +# FAILURE_MESSAGE_OUT ) +# +# If ```` is non-empty on input, then the variable +# ```` will be set to a non-empty value on output with the +# error message if an error occurs and the SHA1 for ```` can not +# be computed. If ```` is empty in input, and there is an +# error, a ``FATAL_ERROR`` will be raised. +# +# NOTE: To get the SHA1 for the Git repo ````, it must contain the +# ``.git/`` directory and the ``git`` executable var ``GIT_EXECUTABLE`` must +# be set. Otherwise, it is an error. +# +function(tribits_git_repo_sha1 gitRepoDir gitRepoSha1Out) + + cmake_parse_arguments( PARSE_ARGV 2 + PARSE "" "" # prefix, options, one_value_keywords + "FAILURE_MESSAGE_OUT" # multi_value_keywords + ) + tribits_check_for_unparsed_arguments() + tribits_assert_parse_arg_zero_or_one_value(PARSE FAILURE_MESSAGE_OUT) + + set(failureMsg "") + + if (NOT GIT_EXECUTABLE) + set(failureMsg "ERROR: The program '${GIT_NAME}' could not be found!") + elseif (NOT IS_DIRECTORY "${gitRepoDir}/.git") + set(failureMsg "ERROR: The directory ${gitRepoDir}/.git does not exist!") + endif() + + set(gitRepoSha1 "") + if (failureMsg STREQUAL "") + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%H" + WORKING_DIRECTORY ${gitRepoDir} + RESULT_VARIABLE gitCmndRtn OUTPUT_VARIABLE gitCmndOutput + ) + # NOTE: Above we have to add quotes '"' or CMake will not accept the + # command. However, git will put those quotes in the output so we have to + # strip them out below! + + if (NOT gitCmndRtn STREQUAL 0) + set(failureMsg "ERROR: ${GIT_EXECUTABLE} command returned ${gitCmndRtn}!=0 for repo ${gitRepoDir}!") + else() + # Strip the quotes off :-( + string(LENGTH "${gitCmndOutput}" gitCmndOutputLen) + math(EXPR outputNumCharsToKeep "${gitCmndOutputLen}-2") + string(SUBSTRING "${gitCmndOutput}" 1 ${outputNumCharsToKeep} gitRepoSha1) + endif() + endif() + # ToDo: Factor above out into its own function! + + if (NOT failureMsg STREQUAL "" AND PARSE_FAILURE_MESSAGE_OUT STREQUAL "") + message(FATAL_ERROR "${failureMsg}") + elseif (PARSE_FAILURE_MESSAGE_OUT) + set(${PARSE_FAILURE_MESSAGE_OUT} "${failureMsg}" PARENT_SCOPE) + endif() + set(${gitRepoSha1Out} "${gitRepoSha1}" PARENT_SCOPE) + +endfunction() + + +# Run the git log command to get the version info for a git repo +# +function(tribits_generate_single_repo_version_string gitRepoDir + repoVersionStringOut + ) + + tribits_assert_git_executable() + + # A) Get the basic version info. + + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%h [%ad] <%ae>" + WORKING_DIRECTORY ${gitRepoDir} + RESULT_VARIABLE gitCmndRtn + OUTPUT_VARIABLE gitCmndOutput + ) + # NOTE: Above we have to add quotes '"' or CMake will not accept the + # command. However, git will put those quotes in the output so we have to + # strip them out later :-( + + if (NOT gitCmndRtn STREQUAL 0) + message(FATAL_ERROR "ERROR, ${GIT_EXECUTABLE} command returned ${gitCmndRtn}!=0" + " for repo ${gitRepoDir}!") + set(gitVersionLine "Error, could not get version info!") + else() + # Strip the quotes off :-( + string(LENGTH "${gitCmndOutput}" gitCmndOutputLen) + math(EXPR outputNumCharsToKeep "${gitCmndOutputLen}-2") + string(SUBSTRING "${gitCmndOutput}" 1 ${outputNumCharsToKeep} + gitVersionLine) + endif() + + # B) Get the first 80 chars of the summary message for more info + + execute_process( + COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%s" + WORKING_DIRECTORY ${gitRepoDir} + RESULT_VARIABLE gitCmndRtn + OUTPUT_VARIABLE gitCmndOutput + ) + + if (NOT gitCmndRtn STREQUAL 0) + message(FATAL_ERROR "ERROR, ${GIT_EXECUTABLE} command returned ${gitCmndRtn}!=0" + " for extra repo ${gitRepoDir}!") + set(gitSummaryStr "Error, could not get version summary!") + else() + # Strip off quotes and quote the 80 char string + set(maxSummaryLen 80) + math(EXPR maxSummaryLen_PLUS_2 "${maxSummaryLen}+2") + string(LENGTH "${gitCmndOutput}" gitCmndOutputLen) + math(EXPR outputNumCharsToKeep "${gitCmndOutputLen}-2") + string(SUBSTRING "${gitCmndOutput}" 1 ${outputNumCharsToKeep} + gitCmndOutputStripped) + if (gitCmndOutputLen GREATER ${maxSummaryLen_PLUS_2}) + string(SUBSTRING "${gitCmndOutputStripped}" 0 ${maxSummaryLen} + gitSummaryStr) + else() + set(gitSummaryStr "${gitCmndOutputStripped}") + endif() + endif() + + set(${repoVersionStringOut} + "${gitVersionLine}\n${gitSummaryStr}" PARENT_SCOPE) + +endfunction() + + +function(tribits_assert_git_executable) + if (NOT GIT_EXECUTABLE) + message(SEND_ERROR "ERROR, the program '${GIT_NAME}' could not be found!" + " We can not generate the repo version file!") + endif() +endfunction() diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index 741b4f489..50340fb5a 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -50,6 +50,7 @@ include(TribitsGetVersionDate) include(TribitsReportInvalidTribitsUsage) include(TribitsReadAllProjectDepsFilesCreateDepsGraph) include(TribitsAdjustPackageEnables) +include(TribitsGitRepoVersionInfo) # Standard TriBITS utilities includes include(TribitsAddOptionAndDefine) @@ -1251,75 +1252,6 @@ macro(tribits_copy_installer_resource _varname _source _destination) COPYONLY) endmacro() -# Run the git log command to get the version info for a git repo -# -function(tribits_generate_single_repo_version_string GIT_REPO_DIR - SINGLE_REPO_VERSION_STRING_OUT - ) - - if (NOT GIT_EXECUTABLE) - message(SEND_ERROR "ERROR, the program '${GIT_NAME}' could not be found!" - " We can not generate the repo version file!") - endif() - - # A) Get the basic version info. - - execute_process( - COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%h [%ad] <%ae>" - WORKING_DIRECTORY ${GIT_REPO_DIR} - RESULT_VARIABLE GIT_RETURN - OUTPUT_VARIABLE GIT_OUTPUT - ) - # NOTE: Above we have to add quotes '"' or CMake will not accept the - # command. However, git will put those quotes in the output so we have to - # strip them out later :-( - - if (NOT GIT_RETURN STREQUAL 0) - message(FATAL_ERROR "ERROR, ${GIT_EXECUTABLE} command returned ${GIT_RETURN}!=0" - " for extra repo ${GIT_REPO_DIR}!") - set(GIT_VERSION_INFO "Error, could not get version info!") - else() - # Strip the quotes off :-( - string(LENGTH "${GIT_OUTPUT}" GIT_OUTPUT_LEN) - math(EXPR OUTPUT_NUM_CHARS_TO_KEEP "${GIT_OUTPUT_LEN}-2") - string(SUBSTRING "${GIT_OUTPUT}" 1 ${OUTPUT_NUM_CHARS_TO_KEEP} - GIT_VERSION_INFO) - endif() - - # B) Get the first 80 chars of the summary message for more info - - execute_process( - COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:"%s" - WORKING_DIRECTORY ${GIT_REPO_DIR} - RESULT_VARIABLE GIT_RETURN - OUTPUT_VARIABLE GIT_OUTPUT - ) - - if (NOT GIT_RETURN STREQUAL 0) - message(FATAL_ERROR "ERROR, ${GIT_EXECUTABLE} command returned ${GIT_RETURN}!=0" - " for extra repo ${GIT_REPO_DIR}!") - set(GIT_VERSION_SUMMARY "Error, could not get version summary!") - else() - # Strip ouf quotes and quote the 80 char string - set(MAX_SUMMARY_LEN 80) - math(EXPR MAX_SUMMARY_LEN_PLUS_2 "${MAX_SUMMARY_LEN}+2") - string(LENGTH "${GIT_OUTPUT}" GIT_OUTPUT_LEN) - math(EXPR OUTPUT_NUM_CHARS_TO_KEEP "${GIT_OUTPUT_LEN}-2") - string(SUBSTRING "${GIT_OUTPUT}" 1 ${OUTPUT_NUM_CHARS_TO_KEEP} - GIT_OUTPUT_STRIPPED) - if (GIT_OUTPUT_LEN GREATER ${MAX_SUMMARY_LEN_PLUS_2}) - string(SUBSTRING "${GIT_OUTPUT_STRIPPED}" 0 ${MAX_SUMMARY_LEN} - GIT_SUMMARY_STR) - else() - set(GIT_SUMMARY_STR "${GIT_OUTPUT_STRIPPED}") - endif() - endif() - - set(${SINGLE_REPO_VERSION_STRING_OUT} - "${GIT_VERSION_INFO}\n${GIT_SUMMARY_STR}" PARENT_SCOPE) - -endfunction() - # Get the versions of all the git repos # @@ -1454,12 +1386,54 @@ macro(tribits_adjust_and_print_package_dependencies) tribits_print_enables_before_adjust_package_enables() tribits_adjust_package_enables() tribits_print_enables_after_adjust_package_enables() + tribits_handle_project_extra_link_flags_as_a_tpl() tribits_set_up_enabled_only_dependencies() tribits_config_code_stop_timer(ADJUST_PACKAGE_DEPS_TIME_START_SECONDS "\nTotal time to adjust package and TPL enables") endmacro() +# Tack on ${PROJECT_NAME}_EXTRA_LINK_LIBS as a TPL that every downstream +# external and internal package depends on +# +macro(tribits_handle_project_extra_link_flags_as_a_tpl) + + if (${PROJECT_NAME}_EXTRA_LINK_FLAGS) + + set(lastLibTplName ${PROJECT_NAME}TribitsLastLib) + + # Define the TPL ${PROJECT_NAME}TribitsLastLib and its find module + set(${lastLibTplName}_FINDMOD + "${${PROJECT_NAME}_TRIBITS_DIR}/common_tpls/FindTPLProjectLastLib.cmake") + + # Tack on ${PROJECT_NAME}TribitsLastLib as a dependency to all enabled + # external packages/TPLs + foreach(TPL_NAME ${${PROJECT_NAME}_TPLS}) + list(APPEND ${TPL_NAME}_LIB_ALL_DEPENDENCIES ${lastLibTplName}) + if (TPL_ENABLE_${TPL_NAME}) + list(APPEND ${TPL_NAME}_LIB_ENABLED_DEPENDENCIES ${lastLibTplName}) + endif() + endforeach() + + # Prepend ${PROJECT_NAME}TribitsLastLib to the list of external packages/TPLs + list(PREPEND ${PROJECT_NAME}_TPLS ${lastLibTplName}) + set(TPL_ENABLE_${lastLibTplName} ON) + set(${lastLibTplName}_PACKAGE_BUILD_STATUS EXTERNAL) + + # Tack on ${PROJECT_NAME}TribitsLastLib as a dependency to all enabled + # internal packages + foreach(PACKAGE_NAME ${${PROJECT_NAME}_PACKAGES}) + list(APPEND ${PACKAGE_NAME}_LIB_ALL_DEPENDENCIES ${lastLibTplName}) + if (${PROJECT_NAME}_ENABLE_${PACKAGE_NAME}) + list(APPEND ${PACKAGE_NAME}_LIB_ENABLED_DEPENDENCIES ${lastLibTplName}) + endif() + endforeach() + + endif() + +endmacro() + + # Gather information from enabled TPLs # macro(tribits_process_enabled_tpls) @@ -1739,21 +1713,6 @@ macro(tribits_setup_env) # enable/disable the graphical dependency graphs in doxygen Doxyfiles. include(FindDoxygen) - # Set the hack library to get link options on - - if (${PROJECT_NAME}_EXTRA_LINK_FLAGS) - if (TRIBITS_SETUP_ENV_DEBUG) - message(STATUS "Creating dummy last_lib for appending the link flags: " - "${${PROJECT_NAME}_EXTRA_LINK_FLAGS}") - endif() - if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/last_lib_dummy.c) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/last_lib_dummy.c - "typedef int last_lib_dummy_t;\n") - endif() - add_library(last_lib STATIC ${CMAKE_CURRENT_BINARY_DIR}/last_lib_dummy.c) - target_link_libraries(last_lib ${${PROJECT_NAME}_EXTRA_LINK_FLAGS}) - endif() - # You have to override the configuration types for MSVS after the compiler # checks! set(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPE} @@ -2087,10 +2046,8 @@ macro(tribits_configure_enabled_packages) # A) Global variable initialization # - global_null_set(${PROJECT_NAME}_INCLUDE_DIRS) - global_null_set(${PROJECT_NAME}_LIBRARY_DIRS) - global_null_set(${PROJECT_NAME}_LIBRARIES) - global_null_set(${PROJECT_NAME}_ETI_PACKAGES) + global_null_set(${PROJECT_NAME}_LIBRARIES "") + global_null_set(${PROJECT_NAME}_ETI_PACKAGES "") # # B) Define the source and binary directories for all of the packages that @@ -2192,8 +2149,6 @@ macro(tribits_configure_enabled_packages) endif() list(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}_libs) - list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) - list(APPEND ${PROJECT_NAME}_LIBRARY_DIRS ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) list(APPEND ${PROJECT_NAME}_LIBRARIES ${${TRIBITS_PACKAGE}_LIBRARIES}) tribits_package_config_code_stop_timer(PROCESS_THIS_PACKAGE_TIME_START_SECONDS @@ -2272,18 +2227,12 @@ macro(tribits_configure_enabled_packages) if (NOT ${PROJECT_NAME}_TRACE_DEPENDENCY_HANDLING_ONLY) - remove_global_duplicates(${PROJECT_NAME}_INCLUDE_DIRS) - remove_global_duplicates(${PROJECT_NAME}_LIBRARY_DIRS) remove_global_duplicates(${PROJECT_NAME}_LIBRARIES) # Add global 'libs' target if(ENABLED_PACKAGE_LIBS_TARGETS) list(REVERSE ENABLED_PACKAGE_LIBS_TARGETS) # Make it so when no packages are enabled it is not a cmake error - if (${PROJECT_NAME}_EXTRA_LINK_FLAGS) - append_set(ENABLED_PACKAGE_LIBS_TARGETS last_lib) - endif() - #print_var(ENABLED_PACKAGE_LIBS_TARGETS) if (NOT TARGET ${PROJECT_NAME}_libs) add_custom_target(${PROJECT_NAME}_libs) add_dependencies(${PROJECT_NAME}_libs ${ENABLED_PACKAGE_LIBS_TARGETS}) diff --git a/tribits/core/package_arch/TribitsLibIsTestOnly.cmake b/tribits/core/package_arch/TribitsLibIsTestOnly.cmake new file mode 100644 index 000000000..1120b2704 --- /dev/null +++ b/tribits/core/package_arch/TribitsLibIsTestOnly.cmake @@ -0,0 +1,77 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2013 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + +include_guard() + + +# @FUNCTION: tribits_set_lib_is_testonly() +# +# See if a library is a TESTONLY library +# +# Usage:: +# +# tribits_set_lib_is_testonly() +# +# This sets the ``TRIBITS_TESTONLY_LIB`` on the library target ````. +# +function(tribits_set_lib_is_testonly libName) + set_target_properties(${libName} PROPERTIES TRIBITS_TESTONLY_LIB TRUE) +endfunction() + + +# @FUNCTION: tribits_lib_is_testonly() +# +# See if a library is a TESTONLY library +# +# Usage:: +# +# tribits_lib_is_testonly( ) +# +# This will only return ``TRUE`` in `` `` if ```` +# is a target and the target property ``TRIBITS_TESTONLY_LIB`` is set to +# ``TRUE``. +# +function(tribits_lib_is_testonly libName libIsTestOnlyOut) + if (TARGET ${libName}) + get_target_property(libIsTestOnly ${libName} TRIBITS_TESTONLY_LIB) + else() + set(libIsTestOnly FALSE) + endif() + set(${libIsTestOnlyOut} ${libIsTestOnly} PARENT_SCOPE) +endfunction() diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index 360c879b0..27fdfc952 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -38,1003 +38,5 @@ # @HEADER include(TribitsCreateClientTemplateHeaders) -include(CMakeParseArguments) -include(GlobalSet) -include(AppendSet) -include(AppendGlob) -include(AppendGlobalSet) -include(AppendStringVar) -include(PrependGlobalSet) -include(RemoveGlobalDuplicates) -include(TribitsGeneralMacros) -include(TribitsReportInvalidTribitsUsage) -include(SetAndIncDirs) - -### -### WARNING: See "NOTES TO DEVELOPERS" at the bottom of the file -### TribitsPackageMacros.cmake! -### - - -# -# Macro that configures the package's main config.h file -# -function(tribits_add_config_define DEFINE) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Package ${PARENT_PACKAGE_NAME}: adding compiler" - " define to config file: ${DEFINE}") - endif() - global_set(${PARENT_PACKAGE_NAME}_CONFIG_DEFINES - "${${PARENT_PACKAGE_NAME}_CONFIG_DEFINES}\n#define ${DEFINE}") - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- ${${PARENT_PACKAGE_NAME}_CONFIG_DEFINES}") - endif() -endfunction() - - -# -# @FUNCTION: tribits_configure_file() -# -# Macro that configures the package's main configured header file (typically -# called ``${PACKAGE_NAME}_config.h`` but any name can be used). -# -# Usage:: -# -# tribits_configure_file() -# -# This function requires the file:: -# -# ${PACKAGE_SOURCE_DIR}/cmake/.in -# -# exists and it creates the file:: -# -# ${CMAKE_CURRENT_BINARY_DIR}/ -# -# by calling the built-in ``configure_file()`` command:: -# -# configure_file( -# ${PACKAGE_SOURCE_DIR}/cmake/.in -# ${CMAKE_CURRENT_BINARY_DIR}/ -# ) -# -# which does basic substitution of CMake variables (see documentation for -# built-in CMake `configure_file()`_ command for rules on how it performs -# substitutions). This command is typically used to configure the package's -# main `/cmake/_config.h.in`_ file. -# -# In addition to just calling ``configure_file()``, this function also aids in -# creating configured header files adding macros for deprecating code as -# described below. -# -# **Deprecated Code Macros** -# -# If ``${PARENT_PACKAGE_NAME}_SHOW_DEPRECATED_WARNINGS`` is ``TRUE`` (see -# `tribits_add_show_deprecated_warnings_option()`_), then the local CMake -# variable ``${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS`` is set which -# adds a define ``_DEPRECATED`` (where -# ```` is the package name in all upper-case letters) -# which adds a compiler-specific deprecated warning for an entity. To take -# advantage of this, just add the line:: -# -# @_DEPRECATED_DECLARATIONS@ -# -# to the ``.in`` file and it will be expanded at configure -# time. -# -# Then C/C++ code can use this macro to deprecate functions, variables, -# classes, etc., for example, using:: -# -# _DEPRECATED class SomeDepreatedClass { ... }. -# -# If the particular compiler does not support deprecated warnings, then this -# macro is defined to be empty. See `Regulated Backward Compatibility and -# Deprecated Code`_ for more details. -# -function(tribits_configure_file PACKAGE_NAME_CONFIG_FILE) - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("\nPACKAGE_CONFIGURE_FILE: ${PACKAGE_NAME_CONFIG_FILE}") - endif() - - # Set up the deprecated attribute if showing deprecated warnings - if (${PARENT_PACKAGE_NAME}_SHOW_DEPRECATED_WARNINGS) - multiline_set(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS - "#ifndef ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" - "# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED __attribute__((__deprecated__))\n" - "# else\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" - "# endif\n" - "#endif\n" - "\n" - "#ifndef ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG\n" - "# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG) __attribute__((__deprecated__ (#MSG) ))\n" - "# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG) __attribute__((__deprecated__))\n" - "# else\n" - "# define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG)\n" - "# endif\n" - "#endif\n" - ) - else() - multiline_set(${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS - "#define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED\n" - "#define ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_MSG(MSG)\n" - ) - endif() - - if (${PARENT_PACKAGE_NAME}_HIDE_DEPRECATED_CODE) - string(APPEND ${PARENT_PACKAGE_NAME_UC}_DEPRECATED_DECLARATIONS - "\n#define ${PARENT_PACKAGE_NAME_UC}_HIDE_DEPRECATED_CODE") - endif() - - # Set up the macro to create the define for time monitor - set(TIME_MONITOR_DEFINE_NAME ${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR) - set(FUNC_TIME_MONITOR_MACRO_NAME ${PARENT_PACKAGE_NAME_UC}_FUNC_TIME_MONITOR) - set(FUNC_TIME_MONITOR_DIFF_MACRO_NAME ${PARENT_PACKAGE_NAME_UC}_FUNC_TIME_MONITOR_DIFF) - if (${PARENT_PACKAGE_NAME}_ENABLE_TEUCHOS_TIME_MONITOR) - multiline_set(${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR_DECLARATIONS - "#ifndef ${FUNC_TIME_MONITOR_MACRO_NAME}\n" - "# define ${TIME_MONITOR_DEFINE_NAME}\n" - "# define ${FUNC_TIME_MONITOR_MACRO_NAME}(FUNCNAME) \\\n" - " TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, ${PARENT_PACKAGE_NAME_UC})\n" - "# define ${FUNC_TIME_MONITOR_DIFF_MACRO_NAME}(FUNCNAME, DIFF) \\\n" - " TEUCHOS_FUNC_TIME_MONITOR_DIFF(FUNCNAME, DIFF)\n" - "#endif\n" - ) - else() - multiline_set(${PARENT_PACKAGE_NAME_UC}_TEUCHOS_TIME_MONITOR_DECLARATIONS - "#define ${FUNC_TIME_MONITOR_MACRO_NAME}(FUNCNAME)\n" - "#define ${FUNC_TIME_MONITOR_DIFF_MACRO_NAME}(FUNCNAME, DIFF)\n" - ) - endif() - - # Configure the file - configure_file( - ${PACKAGE_SOURCE_DIR}/cmake/${PACKAGE_NAME_CONFIG_FILE}.in - ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_CONFIG_FILE} - ) - -endfunction() - - -# -# @FUNCTION: tribits_add_library() -# -# Function used to add a CMake library and target using ``add_library()`` and -# also the ALIAS target ``${PACKAGE_NAME}::`` (where ```` is -# the full CMake target name as returned from ``${}``). -# -# Usage:: -# -# tribits_add_library( -# -# [HEADERS

...] -# [HEADERS_INSTALL_SUBDIR ] -# [NOINSTALLHEADERS ...] -# [SOURCES ...] -# [DEPLIBS ...] -# [IMPORTEDLIBS ...] -# [STATIC|SHARED] -# [TESTONLY] -# [NO_INSTALL_LIB_OR_HEADERS] -# [CUDALIBRARY] -# [ADDED_LIB_TARGET_NAME_OUT ] -# ) -# -# *Sections:* -# -# * `Formal Arguments (tribits_add_library())`_ -# * `Include Directories (tribits_add_library())`_ -# * `Install Targets (tribits_add_library())`_ -# * `Additional Library and Source File Properties (tribits_add_library())`_ -# * `Miscellaneous Notes (tribits_add_library())`_ -# -# .. _Formal Arguments (tribits_add_library()): -# -# **Formal Arguments (tribits_add_library())** -# -# ```` -# -# Required base name of the library. The name of the actual library name -# will be prefixed by ``${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}`` to -# produce:: -# -# = ${${PROJECT_NAME}_LIBRARY_NAME_PREFIX} -# -# This is the name passed to ``add_library( ...)``. The -# name is *not* prefixed by the package name. CMake will of course add -# any standard prefix or post-fix to the library file name appropriate for -# the platform and if this is a static or shared library build (e.g. on -# Linux prefix = ``'lib'``, postfix = ``'.so'`` for shared lib and postfix -# = ``'.a'`` static lib) (see documentation for the built-in CMake command -# ``add_library()``. -# -# ``HEADERS

...`` -# -# List of public header files for using this library. By default, these -# header files are assumed to be in the current source directory. They -# can also contain the relative path or absolute path to the files if they -# are not in the current source directory. This list of headers is passed -# into ``add_library(...)`` as well (which is not strictly needed but is -# helpful for some build tools, like MS Visual Studio). By default, these -# headers will be installed (see `Install Targets -# (tribits_add_library())`_). -# -# ``HEADERS_INSTALL_SUBDIR `` -# -# Optional subdirectory that the headers will be installed under the -# standard installation directory. If ``!=""``, then the -# headers will be installed under -# ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``. Otherwise, -# they will be installed under ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``. -# `Install Targets (tribits_add_library())`_. -# -# ``NOINSTALLHEADERS ...`` -# -# List of private header files which are used by this library. These -# headers are not installed and do not needed to be passed in for any -# purpose other than to pass them into ``add_library()`` as some build -# tools like to have these listed (e.g. MS Visual Studio). -# -# ``SOURCES ...`` -# -# List of source files passed into ``add_library()`` that are compiled -# into header files and included in the library. The compiler used to -# compile the files is determined automatically based on the file -# extension (see CMake documentation for ``add_library()``). -# -# ``DEPLIBS ...`` -# -# List of dependent libraries that are built in the current SE package -# that this library is dependent on. These libraries are passed into -# ``target_link_libraries( ...)`` so that CMake knows about -# the dependency structure of the libraries within this SE package. -# **NOTE:** One must **not** list libraries in other upstream `TriBITS SE -# Packages`_ or libraries built externally from this TriBITS CMake project -# in ``DEPLIBS``. The TriBITS system automatically handles linking to -# libraries in upstream TriBITS SE packages. External libraries need to -# be listed in the ``IMPORTEDLIBS`` argument instead if they are not -# already specified automatically using a `TriBITS TPL`_. -# -# ``IMPORTEDLIBS ...`` -# -# List of dependent libraries built externally from this TriBITS CMake -# project. These libraries are passed into -# ``target_link_libraries( ...)`` so that CMake knows about -# the dependency. However, note that external libraries are often better -# handled as `TriBITS TPLs`_. A well constructed TriBITS package and -# library should never have to use this option! So far, the only case -# where ``IMPORTEDLIBS`` has been shown to be necessary is to pass in the -# standard C math library ``m``. In every other case, a TriBITS TPL -# should be used instead. -# -# ``STATIC`` or ``SHARED`` -# -# If ``STATIC`` is passed in, then a static library will be created -# independent of the value of ``BUILD_SHARED_LIBS``. If ``SHARED`` is -# passed in, then a shared library will be created independent of the -# value of ``BUILD_SHARED_LIBS``. If neither ``STATIC`` or ``SHARED`` are -# passed in, then a shared library will be created if -# ``BUILD_SHARED_LIBS`` evaluates to true, otherwise and a static library -# will be created. If both ``STATIC`` and ``SHARED`` are passed in (which -# is obviously a mistake), then a shared library will be created. -# WARNING: Once you mark a library with ``STATIC``, then all of the -# downstream libraries in the current SE package and all downstream SE -# packages must also be also be marked with ``STATIC``. That is because, -# generally, one can not link a link a static lib against a downstream -# shared lib since that is not portable (but can be done on some platforms -# if, for example, ``-fPIC`` is specified). So be careful to use -# ``STATIC`` in all downstream libraries! -# -# ``TESTONLY`` -# -# If passed in, then ```` will **not** be added to -# ``${PACKAGE_NAME}_LIBRARIES`` and an install target for the library will -# not be added. In this case, the current include directories will be set -# in the global variable ``_INCLUDE_DIR`` which will be -# used in `tribits_add_executable()`_ when a test-only library is linked -# in through its ``DEPLIBS`` argument. Also, the custom property -# ``TRIBITS_TESTONLY_LIB`` will be set to ``TRUE`` which will ensure that -# this library will not be added to the ``${PACKAGE_NAME}::all_libs`` -# target. -# -# ``NO_INSTALL_LIB_OR_HEADERS`` -# -# If specified, then no install targets will be added for the library -# ```` or the header files listed in ``HEADERS``. -# -# ``CUDALIBRARY`` -# -# If specified then ``cuda_add_library()`` is used instead of -# ``add_library()`` where ``cuda_add_library()`` is assumed to be defined -# by the standard ``FindCUDA.cmake`` module as processed using the -# standard TriBITS ``FindTPLCUDA.cmake`` file (see `Standard TriBITS -# TPLs`_). For this option to work, this SE package must have an enabled -# direct or indirect dependency on the TriBITS CUDA TPL or a -# configure-time error may occur about not knowing about -# ``cuda_all_library()``. -# -# ``ADDED_LIB_TARGET_NAME_OUT `` -# -# If specified, then on output the variable ```` will be -# set with the name of the library passed to ``add_library()``. Having -# this name allows the calling ``CMakeLists.txt`` file access and set -# additional target properties (see `Additional Library and Source File -# Properties (tribits_add_library())`_). -# -# .. _Include Directories (tribits_add_library()): -# -# **Include Directories (tribits_add_library())** -# -# Any base directories for the header files listed in the arguments -# ``HEADERS`` or ``NOINSTALLHEADERS`` should be passed into the standard CMake -# command ``include_directories()`` **before** calling this function. For -# example, a CMakeLists.txt file will look like:: -# -# ... -# -# tribits_configure_file(${PACKAGE_NAME}_config.h) -# configure_file(...) -# -# ... -# -# include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -# include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# -# ... -# -# tribits_add_library( -# SOURCES -# .c -# /.cpp -# /.F90 -# ... -# HEADERS -# .h -# /.hpp -# ... -# NONINSTALLHEADERS .hpp .hpp ... -# ... -# ) -# -# The include of ``${CMAKE_CURRENT_BINARY_DIR}`` is needed for any generated -# header files (e.g. using raw ``configure_file()`` or -# `tribits_configure_file()`_) or any generated Fortran ``*.mod`` module files -# generated as a byproduct of compiling F90+ source files (that contain one or -# more Fortran module declarations). -# -# The function ``tribits_add_library()`` will grab the list of all of the -# include directories in scope from prior calls to ``include_directories()`` -# and will append these to the variable ``${PACKAGE_NAME}_INCLUDE_DIRS``. -# This list of include directories is exported to downstream SE packages so -# they appear on the compile lines of all downstream object file compiles. -# This is a critical part of the "glue" that allows TriBITS packages to link -# up automatically (just by clearing dependencies in -# `/cmake/Dependencies.cmake`_ files). -# -# .. _Install Targets (tribits_add_library()): -# -# **Install Targets (tribits_add_library())** -# -# By default, an install target for the library is created using -# ``install(TARGETS ...)`` to install into the directory -# ``${CMAKE_INSTALL_PREFIX}/lib/`` (actual install directory is given by -# ``${PROJECT}_INSTALL_LIB_DIR``, see `Setting the install prefix`_). -# However, this install target will not get created if -# `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE`` and -# ``BUILD_SHARD_LIBS=OFF``. But when ``BUILD_SHARD_LIBS=ON``, the install -# target will get added. Also, this install target will *not* get added if -# ``TESTONLY`` or ``NO_INSTALL_LIB_OR_HEADERS`` are passed in. -# -# By default, an install target for the headers listed in ``HEADERS`` will get -# added using ``install(FILES

...)``, but only if ``TESTONLY`` and -# ``NO_INSTALL_LIB_OR_HEADERS`` are not passed in as well. Also, the install -# target for the headers will not get added if -# `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FASLE``. If this -# install target is added, then the headers get installed into the flat -# directory ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/`` (default is -# ``${CMAKE_INSTALL_PREFIX}/include/``, see `Setting the install prefix`_). -# If ``HEADERS_INSTALL_SUBDIR`` is set, then the headers will be installed -# under ``${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}//``. -# -# Note that an install target will *not* get created for the headers listed in -# ``NOINSTALLHEADERS``. -# -# .. _Additional Library and Source File Properties (tribits_add_library()): -# -# **Additional Library and Source File Properties (tribits_add_library())** -# -# Once ``add_library( ... ...)`` is called, one -# can set and change properties on the ```` library target -# using the built-in CMake command ``set_target_properties()`` as well as set -# and change properties on any of the source files listed in ``SOURCES`` using -# the built-in CMake command ``set_source_file_properties()`` just like in any -# CMake project. For example:: -# -# tribits_add_library( somelib ... -# ADDED_LIB_TARGET_NAME_OUT somelib_TARGET_NAME ) -# -# set_target_properties( ${somelib_TARGET_NAME} -# PROPERTIES LINKER_LANGUAGE CXX ) -# -# .. _Miscellaneous Notes (tribits_add_library()): -# -# **Miscellaneous Notes (tribits_add_library())** -# -# When the file ``Version.cmake`` exists and the CMake variables -# ``${PROJECT_NAME}_VERSION`` and ``${PROJECT_NAME}_MAJOR_VERSION`` are -# defined, then produced shared libraries will be given the standard SOVERSION -# symlinks (see `/Version.cmake`_). -# -# **WARNING:** Do **NOT** use the built-in CMake command ``add_definitions()`` -# to add defines ``-D`` to the compile command line that will -# affect any of the header files in the package! These CMake-added defines -# are only set locally in this directory and child directories. These defines -# will **NOT** be set when code in peer directories (e.g. a downstream TriBITS -# packages) compiles that may include these header files. To add defines that -# affect header files, please use a configured header file (see -# `tribits_configure_file()`_). -# -function(tribits_add_library LIBRARY_NAME_IN) - - # - # Confirm that package and subpackage macros/functions have been called in the correct order - # - - if (CURRENTLY_PROCESSING_SUBPACKAGE) - - # This is a subpackage being processed - - if(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_subpackage() before tribits_add_library()" - " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") - endif() - - if(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_add_library() before " - " tribits_subpackage_postprocess() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") - endif() - - else() - - # This is a package being processed - - if(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_package() or tribits_package_decl() before" - " tribits_add_library() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") - endif() - - if(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) - tribits_report_invalid_tribits_usage( - "Must call tribits_add_library() before " - " tribits_package_postprocess() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") - endif() - - endif() - - set(LIBRARY_NAME_PREFIX "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}") - set(LIBRARY_NAME ${LIBRARY_NAME_PREFIX}${LIBRARY_NAME_IN}) - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("\nTRIBITS_ADD_LIBRARY: ${LIBRARY_NAME}") - if(${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - message("\n${PACKAGE_NAME}_LIBRARIES In installation testing mode," - " libraries will be found instead of created.") - endif() - endif() - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - print_var(${PACKAGE_NAME}_LIBRARY_DIRS) - print_var(${PACKAGE_NAME}_LIBRARIES) - endif() - - cmake_parse_arguments( - #prefix - PARSE - #Options - "STATIC;SHARED;TESTONLY;NO_INSTALL_LIB_OR_HEADERS;CUDALIBRARY" - #one_value_keywords - "" - #mulit_value_keywords - "HEADERS;HEADERS_INSTALL_SUBDIR;NOINSTALLHEADERS;SOURCES;DEPLIBS;IMPORTEDLIBS;DEFINES;ADDED_LIB_TARGET_NAME_OUT" - ${ARGN} - ) - - tribits_check_for_unparsed_arguments() - - # ToDo: Assert that HEADERS_INSTALL_SUBDIR has 0 or 1 entries! - # ToDo: Assert that ADDED_LIB_TARGET_NAME_OUT as 0 or 1 entries! - - if(PARSE_HEADERS) - list(REMOVE_DUPLICATES PARSE_HEADERS) - endif() - if(PARSE_SOURCES) - list(REMOVE_DUPLICATES PARSE_SOURCES) - endif() - - if(PARSE_ADDED_LIB_TARGET_NAME_OUT) - set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} PARENT_SCOPE) - endif() - - # ToDo: Deprecate and remove the usage of DEFINES! People should be putting - # defines into configured header files, not adding -D to the - # compile lines! - - if (NOT ${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING OR PARSE_TESTONLY) - - # Add the link directory for this library. - - set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - ${CMAKE_CURRENT_BINARY_DIR}) - - # NOTE: Above, this link path not really used here for anything. - # Instead it is just added to the other set link library directories - # that are already set. These link directories are then extracted - # and stored into stored in ${PACKAGE_NAME}_LIBRARY_DIRS. - - # Add whatever include directories have been defined so far - - #include_directories(AFTER ${${PACKAGE_NAME}_INCLUDE_DIRS}) - # ToDo: #299: Remove the above once final cleanup is performed for #299. - - # Add whatever link directories have been added so far - - set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - ${${PACKAGE_NAME}_LIBRARY_DIRS}) - - # Local variable to hold all of the libraries that will be directly linked - # to this library. - set(LINK_LIBS) - - # Add dependent libraries passed directly in - - if (PARSE_DEPLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "DEPLIBS = ${PARSE_DEPLIBS}") - endif() - if (PARSE_IMPORTEDLIBS AND ${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "IMPORTEDLIBS = ${PARSE_IMPORTEDLIBS}") - endif() - - # - # Add the DEPLIBS to the LINK_LIBS, assert correct usage of DEPLIBS, and - # see if we need to link in the upstream SE package and TPL libs. - # - # We only want to link to the upstream dependent SE package and TPL - # libraries if needed. We only need to link to these upstream dependent - # libraries when this is the first library being created for this SE - # package or if this library does not depend on other libraries created - # for this package. Otherwise, we don't need to add the include - # directories or link libraries because a dependent lib specified in - # PARSE_DEPLIBS already has everything that we need. - # - # We also need to make special considerations for test libraries since - # things need to be handled a little bit differently (but not much). In the - # case of test libraries, we need to also pull the test-only dependencies. - # In this case, we will always assume that we will add in the test - # libraries. - # - # ToDo: Turn the below deprecated WARNING messages to FATAL_ERROR once we - # give enough time for people to clean up their codes. - # - - set(ADD_DEP_PACKAGE_AND_TPL_LIBS TRUE) - - set(PREFIXED_DEPLIBS) - - foreach(LIB ${PARSE_DEPLIBS}) - - set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${LIB}") - - # LIB_IN_SE_PKG? - list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" FOUND_IDX) - if (FOUND_IDX GREATER -1) - set(LIB_IN_SE_PKG TRUE) - else() - set(LIB_IN_SE_PKG FALSE) - endif() - - # PREFIXED_LIB_IS_TESTONLY? - if (${PREFIXED_LIB}_INCLUDE_DIRS) - set(LIB_TESTONLY TRUE) - else() - set(LIB_TESTONLY FALSE) - endif() - - # Check for valid usage (sorted by most common to least common) - if (LIB_IN_SE_PKG AND NOT LIB_TESTONLY) #PARSE_TESTONLY=TRUE/FASLE - # The library being created here is a library dependent on a regular - # (non-TESTONLY) lib in this SE package. This is valid usage of - # DEPLIBS. There is no need to link this new lib to the SE package's - # upstream dependent SE package and TPL libraries because thse are - # already linked into the lib ${LIB}. - set(ADD_DEP_PACKAGE_AND_TPL_LIBS FALSE) - elseif (PARSE_TESTONLY AND LIB_IN_SE_PKG AND NOT LIB_TESTONLY) - # The library being created here is TESTONLY library and is - # dependent on a regular (non-TESTONLY) lib. This is valid usage of - # DEPLIBS. In the case of test-only libraries, we always link in - # the upstream libs. - elseif (PARSE_TESTONLY AND LIB_TESTONLY) # LIB_IN_SE_PKG=TRUE/FASLE - # The library being created here is TESTONLY library and is dependent - # on another TESTONLY library. This is valid usage of DEPLIBS. In - # this case we just hope that this SE package correctly specified a - # TEST dependency on the upstream SE package that owns this upstream - # TESTONLY library. - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " - "Adding include directories for TESTONLY ${PREFIXED_LIB}_INCLUDE_DIRS ...") - endif() - include_directories(${${PREFIXED_LIB}_INCLUDE_DIRS}) - elseif (NOT PARSE_TESTONLY AND LIB_TESTONLY) # LIB_IN_SE_PKG=TRUE/FASLE - message(WARNING "WARNING: '${LIB}' in DEPLIBS is a TESTONLY lib" - " and it is illegal to link to this non-TESTONLY library '${LIBRARY_NAME}'." - " Such usage is deprecated (and this warning will soon become an error)!" - " If this is a regular library in this SE package or in an dependent upstream SE" - " package then TriBITS will link automatically to it. If you remove this and it" - " does not link, then you need to add a new SE package dependency to" - " this SE package's dependencies file" - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code - elseif (NOT LIB_IN_SE_PKG AND TARGET ${PREFIXED_LIB} ) # PARSE_TESTONLY=TRUE/FALSE - message(WARNING "WARNING: '${LIB}' in DEPLIBS is not" - " a lib in this SE package but is a library defined in the current" - " cmake project! Such usage is deprecated (and" - " will result in a configure error soon). If this is a library in" - " a dependent upstream SE package, then simply remove it from this list." - " TriBITS automatically links in libraries in upstream SE packages." - " If you remove '${LIB}' from DEPLIBS and your code does" - " not link, then you need to add a new SE package dependency to" - " this SE package's dependencies file" - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - elseif (NOT LIB_IN_SE_PKG AND NOT TARGET ${PREFIXED_LIB} ) - message(WARNING "WARNING: '${LIB}' in DEPLIBS is not" - " a lib defined in the current cmake project! Such usage is deprecated (and" - " will result in a configure error soon). If this is an external" - " lib you are trying to link in, it should likely be handled as a TriBITS" - " TPL. Otherwise, it should be passed in through IMPORTEDLIBS. However," - " the only case we have found where IMPORTEDLIBS had to be used instead of" - " through a proper TriBITS TPL is the C math library 'm'.") - else() - message(WARNING "WARNING: The case PARSE_TESTONLY=${PARSE_TESTONLY}," - " LIB_IN_SE_PKG=${LIB_IN_SE_PKG}, LIB_TESTONLY=${LIB_TESTONLY}, has" - " not yet been handled!") - endif() - - list(APPEND PREFIXED_DEPLIBS "${LIBRARY_NAME_PREFIX}${LIB}") - - endforeach() - - append_set(LINK_LIBS ${PREFIXED_DEPLIBS}) - - # - # Check IMPORTEDLIBS - # - - foreach(IMPORTEDLIB ${PARSE_IMPORTEDLIBS}) - set(PREFIXED_LIB "${LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") - list(FIND ${PACKAGE_NAME}_LIBRARIES "${PACKAGE_NAME}::${PREFIXED_LIB}" - FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX) - if (${PREFIXED_LIB}_INCLUDE_DIRS) - message(WARNING "WARNING: '${IMPORTEDLIB}' in IMPORTEDLIBS is a TESTONLY lib" - " and it is illegal to pass in through IMPORTEDLIBS!" - " Such usage is deprecated (and this warning will soon become an error)!" - " Should '${IMPORTEDLIB}' instead be passed through DEPLIBS?") - # ToDo: Turn the above to FATAL_ERROR after dropping deprecated code - elseif (FOUND_IMPORTEDLIB_IN_LIBRARIES_IDX GREATER -1) - message(WARNING "WARNING: Lib '${IMPORTEDLIB}' in IMPORTEDLIBS is in" - " this SE package and is *not* an external lib!" - " TriBITS takes care of linking against libs the current" - " SE package automatically. Please remove it from IMPORTEDLIBS!") - elseif (TARGET ${PREFIXED_LIB}) - message(WARNING "WARNING: Lib '${IMPORTEDLIB}' being passed through" - " IMPORTEDLIBS is *not* an external library but instead is a library" - " defined in this CMake project!" - " TriBITS takes care of linking against libraries in dependent upstream" - " SE packages. If you want to link to a library in an upstream SE" - " package then add the SE package name to the appropriate category" - " in this SE package's dependencies file: " - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") - endif() - # ToDo: Assert that this is not a test-only lib - list(APPEND LINK_LIBS ${IMPORTEDLIB}) - endforeach() - - # - # Link in the upstream TEST SE package and TPL libs - # - # We link these before those in the LIB SE package and TPL libs because - # the TEST dependencies tend to be higher in the dependency tree. It - # should not really matter but it looks better on the link line. - # - - if (PARSE_TESTONLY) - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Pulling in header and libraries dependencies" - " for TEST dependencies ...") - endif() - - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} TEST LINK_LIBS) - - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} TEST LINK_LIBS) - - endif() - - # - # Add the dependent LIB SE package and TPL libs - # - - if (ADD_DEP_PACKAGE_AND_TPL_LIBS) - - # If there are no dependent libs passed in, then this library can not - # possibly depend on the package's other libraries so we must link to - # the dependent libraries in dependent libraries and TPLs. - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Pulling in header and libraries dependencies" - " for LIB dependencies ...") - endif() - - # - # Call include_directories() and link_directories(...) for all upstream - # dependent Packages and TPLs and accumulate the libraries to link against. - # - # NOTE: Adding these directories serves two purposes. First, so that the includes - # get added the the sources that get built for this library. Second, so - # that list full list of include directories can be extracted as a - # property and set on ${PACKAGE_NAME}_INCLUDE_DIRS - # - - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - - endif() - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(LINK_LIBS) - endif() - - # Add the library and all the dependencies - - if (PARSE_DEFINES) - add_definitions(${PARSE_DEFINES}) - endif() - - if (PARSE_STATIC) - set(STATIC_KEYWORD "STATIC") - else() - set(STATIC_KEYWORD) - endif() - - if (PARSE_SHARED) - set(SHARED_KEYWORD "SHARED") - else() - set(SHARED_KEYWORD) - endif() - - if (NOT PARSE_CUDALIBRARY) - add_library( - ${LIBRARY_NAME} - ${STATIC_KEYWORD} - ${SHARED_KEYWORD} - ${PARSE_HEADERS} - ${PARSE_NOINSTALLHEADERS} - ${PARSE_SOURCES} - ) - else() - cuda_add_library( - ${LIBRARY_NAME} - ${PARSE_HEADERS} - ${PARSE_NOINSTALLHEADERS} - ${PARSE_SOURCES} - ) - endif() - - if(PARSE_ADDED_LIB_TARGET_NAME_OUT) - set(${PARSE_ADDED_LIB_TARGET_NAME_OUT} ${LIBRARY_NAME} PARENT_SCOPE) - endif() - - if (PARSE_TESTONLY) - set_target_properties(${LIBRARY_NAME} PROPERTIES - TRIBITS_TESTONLY_LIB TRUE) - endif() - - set_property( - TARGET ${LIBRARY_NAME} - APPEND PROPERTY - LABELS ${PACKAGE_NAME}Libs ${PARENT_PACKAGE_NAME}Libs - ) - - if (NOT "${${PROJECT_NAME}_VERSION}" STREQUAL "" AND - NOT "${${PROJECT_NAME}_MAJOR_VERSION}" STREQUAL "" - ) - set_target_properties( - ${LIBRARY_NAME} - PROPERTIES - VERSION ${${PROJECT_NAME}_VERSION} - SOVERSION ${${PROJECT_NAME}_MAJOR_VERSION} - ) - endif() - - prepend_global_set(${PARENT_PACKAGE_NAME}_LIB_TARGETS ${LIBRARY_NAME}) - prepend_global_set(${PARENT_PACKAGE_NAME}_ALL_TARGETS ${LIBRARY_NAME}) - - if (${PROJECT_NAME}_DUMP_LINK_LIBS) - message("-- ${LIBRARY_NAME_IN}:LINK_LIBS='${LINK_LIBS}'") - endif() - - target_link_libraries(${LIBRARY_NAME} PUBLIC ${LINK_LIBS}) - - if (${PROJECT_NAME}_CXX_STANDARD_FEATURE) - target_compile_features(${LIBRARY_NAME} PUBLIC "${${PROJECT_NAME}_CXX_STANDARD_FEATURE}") - ENDIF () - - # Add to the install target - - set(INSTALL_LIB ON) - set(INSTALL_HEADERS ON) - set(APPEND_LIB_AND_HEADERS_TO_PACKAGE ON) - - if (PARSE_TESTONLY) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation hooks for this library" - " because 'TESTONLY' was passed in ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - set(APPEND_LIB_AND_HEADERS_TO_PACKAGE OFF) - elseif (PARSE_NO_INSTALL_LIB_OR_HEADERS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation hooks for this library" - " because 'NO_INSTALL_LIB_OR_HEADERS' was passed in ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND NOT BUILD_SHARED_LIBS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation of headers and libraries" - " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and BUILD_SHARED_LIBS=FALSE ...") - endif() - set(INSTALL_LIB OFF) - set(INSTALL_HEADERS OFF) - elseif (NOT ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS AND BUILD_SHARED_LIBS) - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping installation of headers but installing libraries" - " because ${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS=FALSE and BUILD_SHARED_LIBS=TRUE ...") - endif() - set(INSTALL_HEADERS OFF) - endif() - - if (INSTALL_LIB OR INSTALL_HEADERS) - set_property(GLOBAL PROPERTY ${PROJECT_NAME}_HAS_INSTALL_TARGETS ON) - set_property(GLOBAL PROPERTY ${PACKAGE_NAME}_HAS_INSTALL_TARGETS ON) - endif() - - if (INSTALL_LIB) - install( - TARGETS ${LIBRARY_NAME} - EXPORT ${PACKAGE_NAME} - INCLUDES DESTINATION "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}" - RUNTIME DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_DIR}" - LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}" - ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIB_DIR}" - COMPONENT ${PACKAGE_NAME} - ) - endif() - - if (INSTALL_HEADERS) - tribits_install_headers( - HEADERS ${PARSE_HEADERS} - INSTALL_SUBDIR ${PARSE_HEADERS_INSTALL_SUBDIR} - COMPONENT ${PACKAGE_NAME} - ) - endif() - - # Append the new include dirs, library dirs, and libraries to this package's lists - - get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) - - if (APPEND_LIB_AND_HEADERS_TO_PACKAGE) - - prepend_global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - prepend_global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) - prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${PACKAGE_NAME}::${LIBRARY_NAME}) - - remove_global_duplicates(${PACKAGE_NAME}_INCLUDE_DIRS) - remove_global_duplicates(${PACKAGE_NAME}_LIBRARY_DIRS) - remove_global_duplicates(${PACKAGE_NAME}_LIBRARIES) - - if (INSTALL_LIB) - global_set(${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES_TO_INSTALL TRUE) - endif() - - else() - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - message("-- " "Skipping augmentation of package's lists of include" - " directories and libraries! ...") - endif() - - list(REMOVE_DUPLICATES INCLUDE_DIRS_CURRENT) - global_set(${LIBRARY_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${LIBRARY_NAME}_INCLUDE_DIRS) - endif() - - endif() - - # Set INTERFACE_INCLUDE_DIRECTOIRES property for added library and must - # only do for the build interface (not the install interface). - set(buildInterfaceIncludeDirs) - foreach (includeDir IN LISTS ${PACKAGE_NAME}_INCLUDE_DIRS) - list(APPEND buildInterfaceIncludeDirs "$") - endforeach() - target_include_directories( ${LIBRARY_NAME} PUBLIC ${buildInterfaceIncludeDirs} ) - # ToDo: #299: In the final refactoring, the list of include directories - # for this library should be extracted from the directory property - # INCLUDE_DIRECTORIES and then set INTERFACE instead of PUBLIC above. The - # rest of the include directories from upstream packages should come from - # the targets that have their INTERFACE_INCLUDE_DIRECTORIES property set. - - # Add ALIAS library :: - add_library(${PACKAGE_NAME}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME}) - - # Optionally Set IMPORTED_NO_SYSTEM - if (${PROJECT_NAME}_IMPORTED_NO_SYSTEM) - set_target_properties(${LIBRARY_NAME} PROPERTIES IMPORTED_NO_SYSTEM TRUE) - endif() - - endif() #if not in installation testing mode - - # - # Adjust for installation testing - # - - if (${PROJECT_NAME}_ENABLE_INSTALLATION_TESTING) - - list(FIND ${PROJECT_NAME}_INSTALLATION_PACKAGE_LIST ${PACKAGE_NAME} - ${PACKAGE_NAME}_WAS_INSTALLED) - if(${${PACKAGE_NAME}_WAS_INSTALLED} EQUAL -1) - message(FATAL_ERROR - "The package ${PACKAGE_NAME} was not installed with ${PROJECT_NAME}!" - " Please disable package ${PACKAGE_NAME} or install it.") - endif() - - include_directories(REQUIRED_DURING_INSTALLATION_TESTING BEFORE - ${${PACKAGE_NAME}_INSTALLATION_INCLUDE_DIRS} - ${${TRIBITS_PACKAGE}_INSTALLATION_TPL_INCLUDE_DIRS}) - set_property(DIRECTORY APPEND PROPERTY PACKAGE_LIBRARY_DIRS - ${${PACKAGE_NAME}_INSTALLATION_LIBRARY_DIRS}) - - get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) - - global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) - global_set(${PACKAGE_NAME}_LIBRARIES ${${PACKAGE_NAME}_INSTALLATION_LIBRARIES}) - - endif() #installation testing mode - - # - # Print the updates to the linkage variables - # - - if (${PROJECT_NAME}_VERBOSE_CONFIGURE) - print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - print_var(${PACKAGE_NAME}_LIBRARY_DIRS) - print_var(${PACKAGE_NAME}_LIBRARIES) - endif() - -endfunction() +include(TribitsConfigureFile) +include(TribitsAddLibrary) diff --git a/tribits/core/package_arch/TribitsPackageMacros.cmake b/tribits/core/package_arch/TribitsPackageMacros.cmake index 48a30c91f..cee06a2d8 100644 --- a/tribits/core/package_arch/TribitsPackageMacros.cmake +++ b/tribits/core/package_arch/TribitsPackageMacros.cmake @@ -40,6 +40,7 @@ include(TribitsPackageSetupCompilerFlags) include(TribitsWriteClientExportFiles) include(TribitsGeneralMacros) +include(TribitsLibIsTestOnly) include(CMakeParseArguments) include(GlobalNullSet) @@ -60,11 +61,6 @@ include(TribitsCopyFilesToBinaryDir) include(TribitsReportInvalidTribitsUsage) -### -### WARNING: See "NOTES TO DEVELOPERS" at the bottom of file! -### - - # # Utility macros # @@ -77,9 +73,7 @@ include(TribitsReportInvalidTribitsUsage) # they are used. # macro(tribits_define_linkage_vars PACKAGE_NAME_IN) - global_null_set(${PACKAGE_NAME_IN}_INCLUDE_DIRS) - global_null_set(${PACKAGE_NAME_IN}_LIBRARY_DIRS) - global_null_set(${PACKAGE_NAME_IN}_LIBRARIES) + global_null_set(${PACKAGE_NAME_IN}_LIBRARIES "") global_set(${PACKAGE_NAME_IN}_HAS_NATIVE_LIBRARIES_TO_INSTALL FALSE) endmacro() @@ -622,9 +616,7 @@ function(tribits_package_finalize_dependency_vars) # A package with subpackages should get all of its dependency vars from # its enabled subpackages. - set(PARENT_PACKAGE_INCLUDE_DIRS) - set(PARENT_PACKAGE_LIBRARY_DIRS) - set(PARENT_PACKAGE_LIBRARIES) + set(PARENT_PACKAGE_LIBRARIES "") set(SUBPACKAGE_IDX 0) foreach(TRIBITS_SUBPACKAGE ${${PARENT_PACKAGE_NAME}_SUBPACKAGES}) @@ -633,10 +625,6 @@ function(tribits_package_finalize_dependency_vars) set(SUBPACKAGE_FULLNAME ${PARENT_PACKAGE_NAME}${TRIBITS_SUBPACKAGE}) if (${PROJECT_NAME}_ENABLE_${SUBPACKAGE_FULLNAME}) - prepend_set(PARENT_PACKAGE_INCLUDE_DIRS - ${${SUBPACKAGE_FULLNAME}_INCLUDE_DIRS}) - prepend_set(PARENT_PACKAGE_LIBRARY_DIRS - ${${SUBPACKAGE_FULLNAME}_LIBRARY_DIRS}) prepend_set(PARENT_PACKAGE_LIBRARIES ${${SUBPACKAGE_FULLNAME}_LIBRARIES}) endif() @@ -645,41 +633,10 @@ function(tribits_package_finalize_dependency_vars) endforeach() - if (PARENT_PACKAGE_INCLUDE_DIRS) - list(REMOVE_DUPLICATES PARENT_PACKAGE_INCLUDE_DIRS) - endif() - if (PARENT_PACKAGE_LIBRARY_DIRS) - list(REMOVE_DUPLICATES PARENT_PACKAGE_LIBRARY_DIRS) - endif() - # NOTE: Above, in the rare case that none of the subpackages contain any - # libraries or any include directories, we need to not call - # list(REMOVE_DUPLICATES ...). - # NOTE: There can't be any duplicate libraries in PARENT_PACKAGE_LIBRARIES # so no need to remove them. - - global_set(${PACKAGE_NAME}_INCLUDE_DIRS "${PARENT_PACKAGE_INCLUDE_DIRS}") - global_set(${PACKAGE_NAME}_LIBRARY_DIRS "${PARENT_PACKAGE_LIBRARY_DIRS}") global_set(${PACKAGE_NAME}_LIBRARIES "${PARENT_PACKAGE_LIBRARIES}") - elseif(NOT ${PACKAGE_NAME}_INCLUDE_DIRS) - - # No libraries have been defined for this package so we are going to set - # them based on this package's dependencies. - - tribits_sort_and_append_package_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - - tribits_sort_and_append_tpl_include_and_link_dirs_and_libs( - ${PACKAGE_NAME} LIB LINK_LIBS) - - get_directory_property(INCLUDE_DIRS_CURRENT INCLUDE_DIRECTORIES) - get_directory_property(LIBRARY_DIRS_CURRENT PACKAGE_LIBRARY_DIRS) - - prepend_global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${INCLUDE_DIRS_CURRENT}) - prepend_global_set(${PACKAGE_NAME}_LIBRARY_DIRS ${LIBRARY_DIRS_CURRENT}) - prepend_global_set(${PACKAGE_NAME}_LIBRARIES ${LINK_LIBS}) - endif() endfunction() @@ -691,8 +648,6 @@ macro(tribits_package_postprocess_common) if (${PROJECT_NAME}_VERBOSE_CONFIGURE) message("\nTRIBITS_PACKAGE_POSTPROCESS_COMMON: ${PACKAGE_NAME}") - print_var(${PACKAGE_NAME}_INCLUDE_DIRS) - print_var(${PACKAGE_NAME}_LIBRARY_DIRS) print_var(${PACKAGE_NAME}_LIBRARIES) endif() @@ -723,7 +678,7 @@ macro(tribits_package_create_all_libs_interface_library) #print_var(allPackageBuildableLibTargetsList) set(packageLibsInAllLibsList) foreach (libTarget IN LISTS allPackageBuildableLibTargetsList) - get_target_property(isTestOnlyLib ${libTarget} TRIBITS_TESTONLY_LIB) + tribits_lib_is_testonly(${libTarget} isTestOnlyLib) #print_var(isTestOnlyLib) if (NOT isTestOnlyLib) list(APPEND packageLibsInAllLibsList ${libTarget}) @@ -966,25 +921,3 @@ macro(tribits_process_subpackages) set(${PACKAGE_NAME}_TRIBITS_PROCESS_SUBPACKAGES_CALLED TRUE) endmacro() - - -################################################################## -# -# NOTES TO DEVELOPERS -# -# Don't even attempt to touch the logic that goes into setting up and -# modifying the variables: -# -# ${PACKAGE_NAME}_INCLUDE_DIRS -# ${PACKAGE_NAME}_LIBRARY_DIRS -# ${PACKAGE_NAME}_LIBRARIES -# ${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES_TO_INSTALL -# ${PACKAGE_NAME}_FULL_ENABLED_DEP_PACKAGES -# ${PARENT_PACKAGE_NAME}_LIB_TARGETS -# ${PARENT_PACKAGE_NAME}_ALL_TARGETS -# -# without carefully studying the documentation in README.DEPENDENCIES and then -# carefully studying all of the code and issues that modify these variables! -# -# ToDo: Write some good unit tests that pin down the behavior of all of this! -# diff --git a/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake b/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake index 71429910b..b1e4f1614 100644 --- a/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake +++ b/tribits/core/package_arch/TribitsProcessEnabledTpl.cmake @@ -76,22 +76,14 @@ function(tribits_process_enabled_tpl TPL_NAME) if (${PROJECT_NAME}_VERBOSE_CONFIGURE) print_var(${TPL_NAME}_FINDMOD) endif() - #print_var(${TPL_NAME}_FINDMOD) if (${TPL_NAME}_FINDMOD STREQUAL "TRIBITS_PKG") 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) - #print_var(${TPL_NAME}_INCLUDE_DIRS) - #print_var(${TPL_NAME}_LIBRARIES) - tribits_standardize_abs_paths(THIS_TPL_INCLUDE_DIRS - ${${TPL_NAME}_INCLUDE_DIRS} ${${TPL_NAME}_TPL_INCLUDE_DIRS}) - global_set(TPL_${TPL_NAME}_INCLUDE_DIRS ${THIS_TPL_INCLUDE_DIRS}) global_set(TPL_${TPL_NAME}_LIBRARIES "${${TPL_NAME}_LIBRARIES}" "${${TPL_NAME}_TPL_LIBRARIES}") global_set(TPL_${TPL_NAME}_PARTS_ALREADY_SET TRUE) endif() - #print_var(TPL_${TPL_NAME}_INCLUDE_DIRS) - #print_var(TPL_${TPL_NAME}_LIBRARIES) return() elseif (IS_ABSOLUTE ${${TPL_NAME}_FINDMOD}) #message("${${TPL_NAME}_FINDMOD} is absolute!") @@ -158,27 +150,21 @@ function(tribits_process_enabled_tpl TPL_NAME) endif() # Assert that the TPL correctly defined all of these variables - assert_defined(TPL_${TPL_NAME}_INCLUDE_DIRS) assert_defined(TPL_${TPL_NAME}_LIBRARIES) - assert_defined(TPL_${TPL_NAME}_LIBRARY_DIRS) - # ToDo: Make TPL_${TPL_NAME}_LIBRARY_DIRS go away. It is not needed for - # anything. # Generate the ConfigVersion.cmake file if it has not been # created yet and add install targets for Config[Version].cmake - if (TARGET ${TPL_NAME}::all_libs) - set(buildDirExternalPkgsDir - "${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}") - set(tplConfigFile - "${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}Config.cmake") - set(tplConfigVersionFile - "${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}ConfigVersion.cmake") - tribits_external_package_write_config_version_file(${TPL_NAME} - "${tplConfigVersionFile}") - tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}") - tribits_external_package_install_config_version_file(${TPL_NAME} - "${tplConfigVersionFile}") - endif() + set(buildDirExternalPkgsDir + "${${PROJECT_NAME}_BINARY_DIR}/${${PROJECT_NAME}_BUILD_DIR_EXTERNAL_PKGS_DIR}") + set(tplConfigFile + "${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}Config.cmake") + set(tplConfigVersionFile + "${buildDirExternalPkgsDir}/${TPL_NAME}/${TPL_NAME}ConfigVersion.cmake") + tribits_external_package_write_config_version_file(${TPL_NAME} + "${tplConfigVersionFile}") + tribits_external_package_install_config_file(${TPL_NAME} "${tplConfigFile}") + tribits_external_package_install_config_version_file(${TPL_NAME} + "${tplConfigVersionFile}") endif() diff --git a/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst b/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst index f553f0e6e..e3183fd22 100644 --- a/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst +++ b/tribits/core/package_arch/TribitsSystemDataStructuresMacrosFunctions.rst @@ -389,29 +389,6 @@ targets as part of #299. The following global internal cache variables are used to communicate the required header directory paths and libraries needed to build and link against a given package's capabilities: - - ``${PACKAGE_NAME}_INCLUDE_DIRS`` - - Defines a list of include paths needed to find all of the headers needed - to compile client code against this (sub)packages sources and it's - upstream packages and TPL sources. This variable is used whenever - building downstream code including downstream libraries or executables in - the same package, or libraries or executables in downstream packages. It - is also used to list out in ${PACKAGE_NAME}Config.cmake files. - - ToDo: Look to eliminate this variable and just add it to the package's - library targets with target_include_directories(). - - ToDo: Split off ${PACKAGE_NAME}_TPL_INCLUDE_DIRS - - ``${PACKAGE_NAME}_LIBRARY_DIRS`` - - Defines as list of the link directories needed to find all of the - libraries for this packages and it's upstream packages and TPLs. Adding - these library directories to the CMake link line is unnecessary and would - cause link-line too long errors on some systems. Instead, this list of - library directories is used when creating ${PACKAGE_NAME}Config.cmake - files. ``${PACKAGE_NAME}_LIBRARIES`` diff --git a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake index 44cfd8a00..6a9154552 100644 --- a/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake +++ b/tribits/core/package_arch/TribitsWriteClientExportFiles.cmake @@ -185,15 +185,6 @@ function(tribits_write_flexible_package_client_export_files) set(FULL_PACKAGE_SET "") set(FULL_LIBRARY_SET "") - set(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM TRUE) - if (${PACKAGE_NAME}_INCLUDE_DIRS) - set(FULL_INCLUDE_DIRS_SET ${${PACKAGE_NAME}_INCLUDE_DIRS}) - set(FULL_LIBRARY_DIRS_SET ${${PACKAGE_NAME}_LIBRARY_DIRS}) - set(SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM FALSE) - else() - set(FULL_INCLUDE_DIRS_SET "") - set(FULL_LIBRARY_DIRS_SET "") - endif() if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) print_var(${PACKAGE_NAME}_FULL_ENABLED_DEP_PACKAGES) @@ -219,10 +210,6 @@ function(tribits_write_flexible_package_client_export_files) list(APPEND FULL_PACKAGE_SET ${TRIBITS_PACKAGE}) if (APPEND_THE_PACKAGE_LIBS) append_set(FULL_LIBRARY_SET ${${TRIBITS_PACKAGE}_LIBRARIES}) - if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) - append_set(FULL_INCLUDE_DIRS_SET ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) - append_set(FULL_LIBRARY_DIRS_SET ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) - endif() else() if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) message("-- " "Skipping adding the package libs!") @@ -237,10 +224,6 @@ function(tribits_write_flexible_package_client_export_files) if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) print_var(FULL_PACKAGE_SET) print_var(FULL_LIBRARY_SET) - if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) - print_var(FULL_INCLUDE_DIRS_SET) - print_var(FULL_LIBRARY_DIRS_SET) - endif() endif() endforeach() @@ -256,21 +239,10 @@ function(tribits_write_flexible_package_client_export_files) prepend_set(FULL_LIBRARY_SET ${${PACKAGE_NAME}_LIBRARIES}) endif() - if (SET_INCLUDE_LIBRARY_DIRS_FROM_UPSTREAM) - if (FULL_INCLUDE_DIRS_SET) - list(REMOVE_DUPLICATES FULL_INCLUDE_DIRS_SET) - endif() - if (FULL_LIBRARY_DIRS_SET) - list(REMOVE_DUPLICATES FULL_LIBRARY_DIRS_SET) - endif() - endif() - if (TRIBITS_WRITE_FLEXIBLE_PACKAGE_CLIENT_EXPORT_FILES_DEBUG_DUMP) message("-- " "*** Final sets of packages, libs, include dirs, and lib dirs:") print_var(FULL_PACKAGE_SET) print_var(FULL_LIBRARY_SET) - print_var(FULL_INCLUDE_DIRS_SET) - print_var(FULL_LIBRARY_DIRS_SET) endif() # @@ -315,12 +287,8 @@ function(tribits_write_flexible_package_client_export_files) # set(${PACKAGE_NAME}_TPL_LIBRARIES "") - set(${PACKAGE_NAME}_TPL_INCLUDE_DIRS "") - set(${PACKAGE_NAME}_TPL_LIBRARY_DIRS "") foreach(TPL ${ORDERED_FULL_TPL_SET}) - list(APPEND ${PACKAGE_NAME}_TPL_LIBRARIES ${TPL_${TPL}_LIBRARIES}) - list(APPEND ${PACKAGE_NAME}_TPL_INCLUDE_DIRS ${TPL_${TPL}_INCLUDE_DIRS}) - list(APPEND ${PACKAGE_NAME}_TPL_LIBRARY_DIRS ${TPL_${TPL}_LIBRARY_DIRS}) + list(APPEND ${PACKAGE_NAME}_TPL_LIBRARIES ${TPL}::all_libs) endforeach() # Generate a note discouraging editing of the Config.cmake file @@ -512,10 +480,6 @@ function(tribits_generate_package_config_file_for_install_tree packageName) foreach(PATH ${PATH_LIST}) set(RELATIVE_PATH "${RELATIVE_PATH}/..") endforeach() - set(FULL_LIBRARY_DIRS_SET - "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_LIB_DIR}") - set(FULL_INCLUDE_DIRS_SET - "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") # Custom code in configuration file. set(PACKAGE_CONFIG_CODE "") @@ -621,9 +585,7 @@ function(tribits_append_dependent_package_config_file_includes_and_enables packa if (${depPkg}_PACKAGE_BUILD_STATUS STREQUAL "INTERNAL") set(packageConfigBaseDir "${pkgConfigFileBaseDir}/${depPkg}") elseif (${depPkg}_PACKAGE_BUILD_STATUS STREQUAL "EXTERNAL") - if (TARGET ${depPkg}::all_libs) # See below NOTE for this if() statement - set(packageConfigBaseDir "${extPkgConfigFileBaseDir}/${depPkg}") - endif() + set(packageConfigBaseDir "${extPkgConfigFileBaseDir}/${depPkg}") else() message(FATAL_ERROR "ERROR: ${depPkg}_PACKAGE_BUILD_STATUS='${${depPkg}_PACKAGE_BUILD_STATUS}' invalid!") endif() @@ -632,15 +594,6 @@ function(tribits_append_dependent_package_config_file_includes_and_enables packa "include(\"${packageConfigBaseDir}/${depPkg}Config.cmake\")\n") endif() endforeach() - # NOTE: Above, every external package/TPL does not have a - # Config.cmake file written for it. For example, special TPLs like - # "MPI" don't have this file created or have an MPI::all_libs target - # created. Therefore, we check for the definition of the target - # ::all_libs before we include the file above. Also, note that in - # the future, compliant external packages that don't need a wrapper - # Config.cmake file created for them will not have a wrapper - # located under "${extPkgConfigFileBaseDir}/". In that case, we will need - # to refactor the code to set _DIR and then run find_dependency(). # Set the output set(${PARSE_CONFIG_FILE_STR_INOUT} "${configFileStr}" PARENT_SCOPE) @@ -778,14 +731,10 @@ function(tribits_write_project_client_export_files) # of all their libraries/includes in the proper order for linking set(FULL_PACKAGE_SET "") set(FULL_LIBRARY_SET "") - set(FULL_INCLUDE_DIRS_SET "") - set(FULL_LIBRARY_DIRS_SET "") foreach(TRIBITS_PACKAGE ${PACKAGE_LIST}) if(${PROJECT_NAME}_ENABLE_${TRIBITS_PACKAGE}) list(APPEND FULL_PACKAGE_SET ${TRIBITS_PACKAGE}) list(APPEND FULL_LIBRARY_SET ${${TRIBITS_PACKAGE}_LIBRARIES}) - list(APPEND FULL_INCLUDE_DIRS_SET ${${TRIBITS_PACKAGE}_INCLUDE_DIRS}) - list(APPEND FULL_LIBRARY_DIRS_SET ${${TRIBITS_PACKAGE}_LIBRARY_DIRS}) endif() endforeach() @@ -802,27 +751,13 @@ function(tribits_write_project_client_export_files) # of all their libraries/includes in the proper order for linking set(FULL_TPL_SET "") set(FULL_TPL_LIBRARY_SET "") - set(FULL_TPL_INCLUDE_DIRS_SET "") - set(FULL_TPL_LIBRARY_DIRS_SET "") foreach(TPL ${TPL_LIST}) if(TPL_ENABLE_${TPL}) list(APPEND FULL_TPL_SET ${TPL}) list(APPEND FULL_TPL_LIBRARY_SET ${TPL_${TPL}_LIBRARIES}) - list(APPEND FULL_TPL_INCLUDE_DIRS_SET ${TPL_${TPL}_INCLUDE_DIRS}) - list(APPEND FULL_TPL_LIBRARY_DIRS_SET ${TPL_${TPL}_LIBRARY_DIRS}) endif() endforeach() - # it is possible that tpls are in the same directory, to keep from - # having a very long include path or library path we will strip out - # any duplicates. This shouldn't affect which include or library is - # found since the first instance of any path will be the one that is - # kept. - list(REMOVE_DUPLICATES FULL_TPL_INCLUDE_DIRS_SET) - list(REMOVE_DUPLICATES FULL_TPL_LIBRARY_DIRS_SET) - - set(${PROJECT_NAME}_CONFIG_TPL_INCLUDE_DIRS ${FULL_TPL_INCLUDE_DIRS_SET}) - set(${PROJECT_NAME}_CONFIG_TPL_LIBRARY_DIRS ${FULL_TPL_LIBRARY_DIRS_SET}) set(${PROJECT_NAME}_CONFIG_TPL_LIBRARIES ${FULL_TPL_LIBRARY_SET}) # @@ -833,11 +768,6 @@ function(tribits_write_project_client_export_files) # Generate a note discouraging editing of the Config.cmake file set(DISCOURAGE_EDITING "Do not edit: This file was generated automatically by CMake.") - # Config file for setting variables and finding include/library paths from - # the build directory - set(${PROJECT_NAME}_CONFIG_INCLUDE_DIRS ${FULL_INCLUDE_DIRS_SET}) - set(${PROJECT_NAME}_CONFIG_LIBRARY_DIRS ${FULL_LIBRARY_DIRS_SET}) - # Write the specification of the rpath if necessary. This is only needed if # we're building shared libraries. if(BUILD_SHARED_LIBS) @@ -890,6 +820,7 @@ include(\"${${TRIBITS_PACKAGE}_BINARY_DIR}/${TRIBITS_PACKAGE}Config.cmake\")") set(PDOLLAR "$") set(tribitsInstallationDir "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}") + set(TRIBITS_PROJECT_INSTALL_INCLUDE_DIR "") configure_file( "${tribitsInstallationDir}/TribitsProjectConfigTemplate.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" ) @@ -920,10 +851,6 @@ include(\"${${TRIBITS_PACKAGE}_BINARY_DIR}/${TRIBITS_PACKAGE}Config.cmake\")") foreach(PATH ${PATH_LIST}) set(RELATIVE_PATH "${RELATIVE_PATH}/..") endforeach() - set(${PROJECT_NAME}_CONFIG_INCLUDE_DIRS - "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") - set(${PROJECT_NAME}_CONFIG_LIBRARY_DIRS - "\${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_PATH}/${${PROJECT_NAME}_INSTALL_LIB_DIR}") # Write the specification of the rpath if necessary. This is only needed if # we're building shared libraries. @@ -942,6 +869,13 @@ include(\"${${TRIBITS_PACKAGE}_BINARY_DIR}/${TRIBITS_PACKAGE}Config.cmake\")") set(PDOLLAR "$") # Hack used in configure file below + if (IS_ABSOLUTE "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") + set(TRIBITS_PROJECT_INSTALL_INCLUDE_DIR "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") + else() + set(TRIBITS_PROJECT_INSTALL_INCLUDE_DIR + "${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}") + endif() + configure_file( "${${PROJECT_NAME}_TRIBITS_DIR}/${TRIBITS_CMAKE_INSTALLATION_FILES_DIR}/TribitsProjectConfigTemplate.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake" diff --git a/tribits/core/std_tpls/FindTPLMPI.cmake b/tribits/core/std_tpls/FindTPLMPI.cmake index b3a5bf464..f4917fd6a 100644 --- a/tribits/core/std_tpls/FindTPLMPI.cmake +++ b/tribits/core/std_tpls/FindTPLMPI.cmake @@ -50,3 +50,7 @@ if(WIN32 AND TPL_ENABLE_MPI) global_set(TPL_MPI_LIBRARIES ${MPI_LIBRARIES}) endif() +tribits_tpl_find_include_dirs_and_libraries(MPI) + +# NOTE: Above, we need to generate the MPI::all_libs target and the +# MPIConfig.cmake file that will also provide the MPI::all_libs target. diff --git a/tribits/core/utils/MessageWrapper.cmake b/tribits/core/utils/MessageWrapper.cmake index cf7a0723d..bdcd9e5e2 100644 --- a/tribits/core/utils/MessageWrapper.cmake +++ b/tribits/core/utils/MessageWrapper.cmake @@ -68,11 +68,13 @@ include(GlobalSet) # verify that they say the right thing. # function(message_wrapper) - #message("MESSAGE_WRAPPER: ${ARGN}") + cmake_parse_arguments(PARSE_ARGV 0 FWD "" "" "") + #message("MESSAGE_WRAPPER: ${FWD_UNPARSED_ARGUMENTS}") if (MESSAGE_WRAPPER_UNIT_TEST_MODE) - global_set(MESSAGE_WRAPPER_INPUT "${MESSAGE_WRAPPER_INPUT}" ${ARGN}) + global_set(MESSAGE_WRAPPER_INPUT "${MESSAGE_WRAPPER_INPUT}" + ${FWD_UNPARSED_ARGUMENTS}) else() - message(${ARGN}) + message(${FWD_UNPARSED_ARGUMENTS}) endif() endfunction() diff --git a/tribits/core/utils/TribitsParseArgumentsHelpers.cmake b/tribits/core/utils/TribitsParseArgumentsHelpers.cmake new file mode 100644 index 000000000..c4cd79fdf --- /dev/null +++ b/tribits/core/utils/TribitsParseArgumentsHelpers.cmake @@ -0,0 +1,156 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2013 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + + +################################################################################ +# +# This module contains function to aid with the usage of +# cmake_parse_arguments(). +# +################################################################################ + + +include(MessageWrapper) + + +# @FUNCTION: tribits_check_for_unparsed_arguments() +# +# Check to see if there are unparsed arguments after calling +# ``cmake_parse_arguments()`` or ``tribits_parse_arguments_from_list()`` +# +# Usage:: +# +# tribits_check_for_unparsed_arguments([]) +# +# If `` is not given, it is assumed to be `PARSE`. +# +function(tribits_check_for_unparsed_arguments) + + if ("${ARGC}" GREATER 1) + message(FATAL_ERROR + "ERROR tribits_check_for_unparsed_arguments() passed arguments '${ARGV}' but only accepts 0 or 1 arguments (for )") + endif() + + set(prefix "PARSE") + foreach(arg ${ARGV}) + set(prefix "${arg}") + endforeach() + + if( NOT "${${prefix}_UNPARSED_ARGUMENTS}" STREQUAL "") + message_wrapper( + ${${PROJECT_NAME}_CHECK_FOR_UNPARSED_ARGUMENTS} + "Arguments passed in unrecognized. ${prefix}_UNPARSED_ARGUMENTS = '${${prefix}_UNPARSED_ARGUMENTS}'" + ) + endif() + +endfunction() + + +# @MACRO: tribits_assert_parse_arg_one_or_more_values() +# +# Assert that a set of parse argument have at least one value +# +# Usage:: +# +# tribits_assert_parse_arg_one_or_more_values( ...) +# +macro(tribits_assert_parse_arg_one_or_more_values PREFIX) + foreach(ARGNAME ${ARGN}) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (ARG_NUM_VALS LESS 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME} must have at least one value!" ) + return() + # NOTE: The return() is needed in unit testing mode + endif() + endforeach() +endmacro() + + +# @MACRO: tribits_assert_parse_arg_zero_or_one_value() +# +# Assert a set of parse arguments have zero or one value +# +# Usage:: +# +# tribits_assert_parse_arg_zero_or_one_value( ...) +# +macro(tribits_assert_parse_arg_zero_or_one_value PREFIX) + foreach(ARGNAME ${ARGN}) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (ARG_NUM_VALS GREATER 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' can not have more than one value!" ) + return() + # NOTE: The macro return() is needed in unit testing mode + endif() + endif() + endforeach() +endmacro() + + +# @MACRO: tribits_assert_parse_arg_one_value() +# +# Assert that a set of parse arguments have exactly one value +# +# Usage:: +# +# tribits_assert_parse_arg_one_value( ...) +# +macro(tribits_assert_parse_arg_one_value PREFIX) + foreach(ARGNAME ${ARGN}) + set(PREFIX_ARGNAME "${PREFIX}_${ARGNAME}") + if (NOT "${${PREFIX_ARGNAME}}" STREQUAL "") + list( LENGTH ${PREFIX_ARGNAME} ARG_NUM_VALS ) + if (NOT ARG_NUM_VALS EQUAL 1) + message_wrapper(FATAL_ERROR + "ERROR: ${ARGNAME}='${${PREFIX_ARGNAME}}' Must have exactly one value!" ) + return() + # NOTE: The macro return() is needed in unit testing mode + endif() + endif() + endforeach() +endmacro() + + +# NOTE: Above, we use macros for the assert functions with returns in unit +# test mode so that it will abort the calling function these are called from! diff --git a/tribits/core/utils/UnitTestHelpers.cmake b/tribits/core/utils/UnitTestHelpers.cmake index 0345f07e8..912efb0a5 100644 --- a/tribits/core/utils/UnitTestHelpers.cmake +++ b/tribits/core/utils/UnitTestHelpers.cmake @@ -240,12 +240,13 @@ endfunction() # @FUNCTION: unittest_string_regex() # -# Perform a series regexes of given strings and update overall test statistics. +# Perform a series of regexes on a given string and update overall test +# statistics. # # Usage:: # # unittest_string_regex( -# +# "" # REGEX_STRINGS "" "" ... # ) # @@ -279,12 +280,65 @@ function(unittest_string_regex INPUT_STRING) string(REGEX MATCH "${REGEX}" REGEX_MATCH_RESULT "${INPUT_STRING}") + message(" Searching string:") + message(" '${INPUT_STRING}'") + if (REGEX_MATCH_RESULT) + message(" for REGEX {${REGEX}}: [PASSED]\n") + math( EXPR NUMPASSED ${UNITTEST_OVERALL_NUMPASSED}+1 ) + global_set(UNITTEST_OVERALL_NUMPASSED ${NUMPASSED}) + else() + message(" for REGEX {${REGEX}}: [FAILED]\n") + global_set(UNITTEST_OVERALL_PASS FALSE) + message(WARNING "Stack trace for failed unit test") + endif() + + endforeach() + +endfunction() + + +# @FUNCTION: unittest_string_var_regex() +# +# Perform a series of regexes on a given string variable and update overall +# test statistics. +# +# Usage:: +# +# unittest_string_var_regex( +# +# REGEX_STRINGS "" "" ... +# ) +# +# If the ``"${}"`` matches all of the of the regexs +# ``""``, ``""``, ..., then the test passes. Otherwise it fails. +# +# This updates the global variables ``UNITTEST_OVERALL_NUMRUN``, +# ``UNITTEST_OVERALL_NUMPASSED``, and ``UNITTEST_OVERALL_PASS`` which are used +# by the unit test harness system to assess overall pass/fail. +# +function(unittest_string_var_regex inputStringVar) + + cmake_parse_arguments(PARSE_ARGV 1 + PARSE "" "" # prefix, options, one_value_keywords + "REGEX_STRINGS" #multi_value_keywords + ) + tribits_check_for_unparsed_arguments(PARSE) + + foreach(REGEX ${PARSE_REGEX_STRINGS}) + + math( EXPR NUMRUN ${UNITTEST_OVERALL_NUMRUN}+1 ) + global_set(UNITTEST_OVERALL_NUMRUN ${NUMRUN}) + + string(REGEX MATCH "${REGEX}" REGEX_MATCH_RESULT "${${inputStringVar}}") + + message("Searching string variable value '${inputStringVar}':") + message(" '${${inputStringVar}}'") if (REGEX_MATCH_RESULT) - message(" Searching for REGEX {${REGEX}}: [PASSED]\n") + message(" for REGEX {${REGEX}}: [PASSED]\n") math( EXPR NUMPASSED ${UNITTEST_OVERALL_NUMPASSED}+1 ) global_set(UNITTEST_OVERALL_NUMPASSED ${NUMPASSED}) else() - message(" Searching for REGEX {${REGEX}}: [FAILED]\n") + message(" for REGEX {${REGEX}}: [FAILED]\n") global_set(UNITTEST_OVERALL_PASS FALSE) message(WARNING "Stack trace for failed unit test") endif() diff --git a/tribits/ctest_driver/TribitsAddDashboardTarget.cmake b/tribits/ctest_driver/TribitsAddDashboardTarget.cmake index 3e7b85dcd..a9a8b6992 100644 --- a/tribits/ctest_driver/TribitsAddDashboardTarget.cmake +++ b/tribits/ctest_driver/TribitsAddDashboardTarget.cmake @@ -38,11 +38,14 @@ # @HEADER +################################################################################ # # This file gets included in the main TriBITS framework. It is put here to # reduce the size of the tribits/core/ directory. # +################################################################################ +include(TribitsGitRepoVersionInfo) # # Macro that drives a experimental 'dashboard' target @@ -95,6 +98,13 @@ macro(tribits_add_dashboard_target) append_set(EXPR_CMND_ARGS "${PROJECT_NAME}_WARNINGS_AS_ERRORS_FLAGS='${${PROJECT_NAME}_WARNINGS_AS_ERRORS_FLAGS}'") append_set(EXPR_CMND_ARGS "${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE=${${PROJECT_NAME}_ENABLE_SECONDARY_TESTED_CODE}") + # Determine if base repo is a git repo (by seeing if SHA1 can be extracted) + tribits_git_repo_sha1("${PROJECT_SOURCE_DIR}" projectGitRepoSha1 + FAILURE_MESSAGE_OUT projectGitRepoSha1FailureMsg) + if (projectGitRepoSha1 STREQUAL "") + append_set(EXPR_CMND_ARGS "CTEST_DO_UPDATES=OFF") + endif() + # Conditionally override options used only for the 'dashboard' target. # These options have no use in a a basic build/test so we don't want to # interfere with options users might set on the env. diff --git a/tribits/ctest_driver/TribitsCTestDriverCore.cmake b/tribits/ctest_driver/TribitsCTestDriverCore.cmake index e02d292c4..04deb917a 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCore.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCore.cmake @@ -323,6 +323,7 @@ include(TribitsCTestDriverCoreHelpers) # * `Determining what testing-related actions are performed (tribits_ctest_driver())`_ # * `Determining how the results are displayed on CDash (tribits_ctest_driver())`_ # * `Specifying where the results go to CDash (tribits_ctest_driver())`_ +# * `Links to results on CDash (tribits_ctest_driver())`_ # * `Determining what TriBITS repositories are included (tribits_ctest_driver())`_ # * `All-at-once versus package-by-package mode (tribits_ctest_driver())`_ # * `Multiple ctest -S invocations (tribits_ctest_driver())`_ @@ -1166,6 +1167,63 @@ include(TribitsCTestDriverCoreHelpers) # not be performed. For more details, see `TRIBITS_2ND_CTEST_DROP_SITE`_ and # `TRIBITS_2ND_CTEST_DROP_LOCATION`_. # +# .. _Links to results on CDash (tribits_ctest_driver()): +# +# **Links to results on CDash (tribits_ctest_driver()):** +# +# Links to where the results will be posted on CDash are printed to STDOUT +# before it performs any actions and at end after all of the actions and +# submits have been completed. +# +# The results are printed to STDOUT in a section that looks like:: +# +# Link to this build's results on CDash: +# +# +# +# Link to all builds for this repo version on CDash: +# +# +# +# Link to all nonpassing tests for all builds for this repo version on CDash: +# +# +# +# The URL ```` is created from the buildname, site, and +# buildstartime fields which is known from the TAG file created by CTest. +# This allows access the results for this particular build on CDash by just +# clicking that link. +# +# The URL ```` provides a link to a CDash +# ``index.php`` query that includes all of the builds with the same base Git +# repo SHA1. This allows comparing the results of this build for other builds +# for this same version of the base Git repository. +# +# The URL ```` gives a link to a CDash +# ``queryTests.php`` query for all of the nonpassing tests for all of the +# builds with this same base project Git repo SHA1. This allows comparing +# test failures across all of the builds for the same base project Git repo +# version. +# +# NOTE: The links ```` and +# ```` are only provided if the base +# project Git repo has the ``.git/`` subdirectory and if ``git log`` +# successfully returns the SHA1 for that base Git repo. +# +# NOTE: The links ```` and +# ```` only consider the Git SHA1 of the +# base project Git repo. For multi-repo projects (see `Multi-Repository +# Support`_), you may get results for builds with different subrepo versions +# and therefore may be comparing apples and oranges. (Projects that commit a +# ``SubRepoVersion.txt`` file to their base Git repo or use Git +# Submodules will have unique base project Git repo SHA1s for different +# versions of the project's repos.) +# +# In addition, a text file ``CDashResults.txt`` will be written in the build +# directory that contains this same CDash link information shown above. This +# allows a process to cat the file ``CDashResults.txt`` to get links to the +# results on CDash. +# # .. _Determining what TriBITS repositories are included (tribits_ctest_driver()): # # **Determining what TriBITS repositories are included (tribits_ctest_driver()):** @@ -2093,9 +2151,15 @@ function(tribits_ctest_driver) ctest_start(${CTEST_START_ARGS}) tribits_remember_if_configure_attempted() - tribits_get_build_url_and_write_to_file(CDASH_BUILD_URL - "${CTEST_BINARY_DIRECTORY}/CDashBuildUrl.txt") - tribits_print_build_url("Results will be submitted on CDash at:" "${CDASH_BUILD_URL}") + + tribits_get_cdash_results_string_and_write_to_file( + CDASH_RESULTS_STRING_OUT CDASH_RESULTS_STRING + CDASH_RESULTS_FILE_OUT "${CTEST_BINARY_DIRECTORY}/CDashResults.txt" ) + message("Results will be submitted on CDash at the following links:\n\n" + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" + "${CDASH_RESULTS_STRING}\n" + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + ) message( "\n***" @@ -2369,7 +2433,11 @@ function(tribits_ctest_driver) report_queued_errors() - tribits_print_build_url("See results submitted on CDash at:" "${CDASH_BUILD_URL}") + message("\nSee results submitted on CDash at the following links:\n\n" + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" + "${CDASH_RESULTS_STRING}\n" + "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" + ) if ((NOT UPDATE_FAILED) AND ("${${PROJECT_NAME}_FAILED_PACKAGES}" STREQUAL "")) message( diff --git a/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake b/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake index ed329adf1..58ffc6264 100644 --- a/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake +++ b/tribits/ctest_driver/TribitsCTestDriverCoreHelpers.cmake @@ -38,7 +38,7 @@ # @HEADER -include(TribitsGetCDashUrlFromTagFile) +include(TribitsGetCDashUrlsInsideCTestS) # Wrapper used for unit testing purposes diff --git a/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake b/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake deleted file mode 100644 index 944a598d6..000000000 --- a/tribits/ctest_driver/TribitsGetCDashUrlFromTagFile.cmake +++ /dev/null @@ -1,194 +0,0 @@ -include(TribitsReadTagFile) - - -# @FUNCTION: tribits_get_build_url_and_write_to_file() -# -# Construct the build URL on CDash given the site name, buildname, and -# buildstamp (take from the TAG file) from inside of a running ctest -S -# program and optionally write it to a file as well. -# -# Usage:: -# -# tribits_get_build_url_and_write_to_file( -# [ ] ) -# -# Here, ```` returns the CDash Build URL constructed from -# the following CMake variables already set in a ``ctest -S`` process: -# -# * ``CTEST_DROP_SITE`` -# * ``CTEST_DROP_LOCATION`` (``submit.php`` is replaced with ``index.php``) -# * ``CTEST_PROJECT_NAME`` -# * ``CTEST_SITE`` -# * ``CTEST_BUILD_NAME`` -# -# and the buildstamp read in from the file -# ``${CTEST_BINARY_DIRECTORY}/Testing/TAG``. -# -# Note that ```` will have ``https://`` added to the -# beginning of it so that GitHub Actions and other systems will put in a link -# to them. -# -# If the file name argument ```` is non-empty, then that -# CDash URL will be written to the file as a single line. -# -function(tribits_get_build_url_and_write_to_file cdashBuildUrlOut cdashBuildUrlFile) - tribits_get_cdash_index_php_from_drop_site_and_location( - CTEST_DROP_SITE "${CTEST_DROP_SITE}" - CTEST_DROP_LOCATION "${CTEST_DROP_LOCATION}" - INDEX_PHP_URL_OUT indexPhpUrl - ) - tribits_get_cdash_build_url_from_tag_file( - INDEX_PHP_URL "${indexPhpUrl}" - PROJECT_NAME "${CTEST_PROJECT_NAME}" - SITE_NAME "${CTEST_SITE}" - BUILD_NAME "${CTEST_BUILD_NAME}" - TAG_FILE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" - CDASH_BUILD_URL_OUT cdashBuildUrl - ) - set(cdashBuildUrl "https://${cdashBuildUrl}") - if (cdashBuildUrlFile) - file(WRITE "${cdashBuildUrlFile}" "${cdashBuildUrl}") - endif() - set(${cdashBuildUrlOut} "${cdashBuildUrl}" PARENT_SCOPE) -endfunction() - - -# @FUNCTION: tribits_print_build_url() -# -# Print the URL on CDash where build results can be found. -# -# Usage:: -# -# tribits_print_build_url( ) -# -function(tribits_print_build_url msg cdashBuildUrl) - message("\n${msg}\n") - message(" ${cdashBuildUrl}\n") -endfunction() - - -# @FUNCTION: tribits_get_cdash_build_url_from_tag_file() -# -# Create CDash index.php URL from the build parts. -# -# Usage:: -# -# tribits_get_cdash_build_url_from_tag_file( -# INDEX_PHP_URL -# PROJECT_NAME -# SITE_NAME -# BUILD_NAME -# TAG_FILE -# CDASH_BUILD_URL_OUT -# ) -# -# Note that spaces are allowed ```` or ```` and those -# will be handled correctly to produce a valid URL. -# -function(tribits_get_cdash_build_url_from_tag_file) - # Get arguments - cmake_parse_arguments( - PREFIX #prefix - "" #options - "INDEX_PHP_URL;PROJECT_NAME;SITE_NAME;BUILD_NAME;TAG_FILE;CDASH_BUILD_URL_OUT" #one_value_keywords - "" #multi_value_keywords - ${ARGN} - ) - # Read in the tag file and get the build stamp from that - tribits_read_ctest_tag_file(${PREFIX_TAG_FILE} buildStartTime cdashGroup - cdashModel # The model is not used here but we still need to include this arg - ) - set(buildstamp "${buildStartTime}-${cdashGroup}") - # Build the URL and return it - tribits_get_cdash_build_url_from_parts( - INDEX_PHP_URL "${PREFIX_INDEX_PHP_URL}" - PROJECT_NAME "${PREFIX_PROJECT_NAME}" - SITE_NAME "${PREFIX_SITE_NAME}" - BUILD_NAME "${PREFIX_BUILD_NAME}" - BUILD_STAMP "${buildstamp}" - CDASH_BUILD_URL_OUT cdashBuildUrl - ) - set(${PREFIX_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE) -endfunction() - - -# @FUNCTION: tribits_get_cdash_index_php_from_drop_site_and_location() -# -# Get the CDash index.php URL from the input CTEST_DROP_SITE and -# CTEST_DROP_LOCATION vars used in a ctest -S script. -# -function(tribits_get_cdash_index_php_from_drop_site_and_location) - cmake_parse_arguments( - PREFIX #prefix - "" #options - "CTEST_DROP_SITE;CTEST_DROP_LOCATION;INDEX_PHP_URL_OUT" #one_value_keywords - "" #multi_value_keywords - ${ARGN} - ) - string(FIND "${PREFIX_CTEST_DROP_LOCATION}" "?" endOfSubmitPhpIdx) - string(SUBSTRING "${PREFIX_CTEST_DROP_LOCATION}" 0 ${endOfSubmitPhpIdx} submitPhpPart) - string(REPLACE "submit.php" "index.php" indexPhpPart "${submitPhpPart}") - set(indexPhpUrl "${PREFIX_CTEST_DROP_SITE}${indexPhpPart}") - SET(${PREFIX_INDEX_PHP_URL_OUT} "${indexPhpUrl}" PARENT_SCOPE) -endfunction() - - -# @FUNCTION: tribits_get_cdash_build_url_from_parts() -# -# Create CDash index.php URL from the build parts. -# -# Usage:: -# -# tribits_get_cdash_build_url_from_parts( -# INDEX_PHP_URL -# PROJECT_NAME -# SITE_NAME -# BUILD_NAME -# BUILD_STAMP -# CDASH_BUILD_URL_OUT -# ) -# -# Note that spaces are allowed ````, ```` or -# ```` and those will be handled correctly to produce a valid URL. -# -function(tribits_get_cdash_build_url_from_parts) - # Get arguments - cmake_parse_arguments( - PREFIX #prefix - "" #options - "INDEX_PHP_URL;PROJECT_NAME;SITE_NAME;BUILD_NAME;BUILD_STAMP;CDASH_BUILD_URL_OUT" #one_value_keywords - "" #multi_value_keywords - ${ARGN} - ) - # Do replacements for spaces and special chars in data - tribits_replace_chars_for_url("${PREFIX_PROJECT_NAME}" project) - tribits_replace_chars_for_url("${PREFIX_SITE_NAME}" site) - tribits_replace_chars_for_url("${PREFIX_BUILD_NAME}" buildname) - tribits_replace_chars_for_url("${PREFIX_BUILD_STAMP}" buildstamp) - # Build the URL - set(cdashIndexProj "${PREFIX_INDEX_PHP_URL}?project=${project}") - set(filtersPreTxt "filtercount=3&showfilters=1&filtercombine=and") - set(siteFlt "field1=site&compare1=61&value1=${site}") - set(buildnameFlt "field2=buildname&compare2=61&value2=${buildname}") - set(buildStampFlt "field3=buildstamp&compare3=61&value3=${buildstamp}") - set(cdashBuildUrl - "${cdashIndexProj}&${filtersPreTxt}&${siteFlt}&${buildnameFlt}&${buildStampFlt}") - set(${PREFIX_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE) -endfunction() - - -# Replace chars in a regular string for usage in a URL with CDash -# -function(tribits_replace_chars_for_url inputStr outputStrForUrlOutVar) - set(outputStrForUrl "${inputStr}") - string(REPLACE " " "%20" outputStrForUrl "${outputStrForUrl}") - string(REPLACE "+" "%2B" outputStrForUrl "${outputStrForUrl}") - set(${outputStrForUrlOutVar} "${outputStrForUrl}" PARENT_SCOPE) -endfunction() - -# LocalWords: GitHub tribits url buildname buildstamp -# LocalWords: tribits TRIBITS -# LocalWords: cmake CMake CMAKE -# LocalWords: ctest CTEST cdash CDash CDASH -# LocalWords: SUBSTRING -# LocalWords: endif endfunction diff --git a/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake new file mode 100644 index 000000000..04166830c --- /dev/null +++ b/tribits/ctest_driver/TribitsGetCDashUrlsInsideCTestS.cmake @@ -0,0 +1,527 @@ +# @HEADER +# ************************************************************************ +# +# TriBITS: Tribal Build, Integrate, and Test System +# Copyright 2013 Sandia Corporation +# +# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +# the U.S. Government retains certain rights in this software. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the Corporation nor the names of the +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# ************************************************************************ +# @HEADER + + +include(PrintVar) +include(TribitsParseArgumentsHelpers) +include(TribitsReadTagFile) + + +################################################################################ +# +# This module contains functions for constructing CDash URLs to build and test +# results from inside of a CTest -S script. +# +################################################################################ + + +# @FUNCTION: tribits_get_cdash_results_string_and_write_to_file() +# +# Calls `tribits_get_cdash_results_urls_string()`_ and then writes the CDash +# URLs to a file. +# +# Usage:: +# +# tribits_get_cdash_results_string_and_write_to_file( +# [CDASH_RESULTS_STRING_OUT ] +# [CDASH_RESULTS_FILE_OUT ] +# ) +# +function(tribits_get_cdash_results_string_and_write_to_file) + # Parse args + cmake_parse_arguments( PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + "CDASH_RESULTS_STRING_OUT;CDASH_RESULTS_FILE_OUT" # multi_value_keywords + ) + tribits_check_for_unparsed_arguments(PARSE) + tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_RESULTS_STRING_OUT + CDASH_RESULTS_FILE_OUT ) + # Get and set CDash results URL + tribits_get_cdash_results_urls_string(cdashResultsString) + if (PARSE_CDASH_RESULTS_STRING_OUT) + set(${PARSE_CDASH_RESULTS_STRING_OUT} "${cdashResultsString}" PARENT_SCOPE) + endif() + if (PARSE_CDASH_RESULTS_FILE_OUT) + file(WRITE "${PARSE_CDASH_RESULTS_FILE_OUT}" "${cdashResultsString}") + endif() +endfunction() + + +# @FUNCTION: tribits_get_cdash_results_urls_string() +# +# Call `tribits_get_cdash_results_urls()`_ and then construct a CDash URLs +# string fit for printing. +# +# Usage:: +# +# tribits_get_cdash_results_urls_string( +# +# ) +# +# Construct the build and test URLs on CDash given the site name, buildname, +# and buildstamp (taken from the TAG file) from inside of a running ctest -S +# program and optionally write it to a file as well. +# +function(tribits_get_cdash_results_urls_string cdashResultsUrlsStringOut) + tribits_get_cdash_results_urls( + CDASH_BUILD_URL_OUT cdashBuildUrl + CDASH_REVISION_BUILDS_URL_OUT cdashRevisionBuildsUrl + CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrl + ) + tribits_generate_cdash_results_string_from_urls( + CDASH_BUILD_URL "${cdashBuildUrl}" + CDASH_REVISION_BUILDS_URL "${cdashRevisionBuildsUrl}" + CDASH_REVISION_NONPASSING_TESTS_URL "${cdashRevisionNonpassingTestsUrl}" + CDASH_RESULTS_STRING_OUT cdashResultsUrlsString + ) + set(${cdashResultsUrlsStringOut} "${cdashResultsUrlsString}" PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_generate_cdash_results_string_from_urls() +# +# Generate the CDash results URL string given the individual URLs. +# +# Usage:: +# +# tribits_generate_cdash_results_string_from_urls( +# CDASH_BUILD_URL "" +# [CDASH_REVISION_BUILDS_URL ""] +# [CDASH_REVISION_NONPASSING_TESTS_URL ""] +# CDASH_RESULTS_STRING_OUT +# ) +# +# Takes the URLs returned from `tribits_get_cdash_results_urls()`_ and +# generates a string out of them which is set in the return var +# ````. +# +function(tribits_generate_cdash_results_string_from_urls) + # Parse args + cmake_parse_arguments(PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + # multi_value_keywords + "CDASH_BUILD_URL;CDASH_REVISION_BUILDS_URL;CDASH_REVISION_NONPASSING_TESTS_URL;CDASH_RESULTS_STRING_OUT" + ) + tribits_check_for_unparsed_arguments() + tribits_assert_parse_arg_one_value(PARSE CDASH_BUILD_URL + CDASH_RESULTS_STRING_OUT) + tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_REVISION_BUILDS_URL + CDASH_REVISION_NONPASSING_TESTS_URL) + # Construct CDash results URLs string + set(cdashResultsString "") + string(APPEND cdashResultsString + "Link to this build's results on CDash:\n" + "\n" + " ${PARSE_CDASH_BUILD_URL}\n") + if (PARSE_CDASH_REVISION_BUILDS_URL) + string(APPEND cdashResultsString + "\nLink to all builds for this repo version on CDash:\n" + "\n" + " ${PARSE_CDASH_REVISION_BUILDS_URL}\n") + endif() + if (PARSE_CDASH_REVISION_NONPASSING_TESTS_URL) + string(APPEND cdashResultsString + "\nLink to all nonpassing tests for all builds for this repo version on CDash:\n" + "\n" + " ${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL}\n") + endif() + # Set output + set(${PARSE_CDASH_RESULTS_STRING_OUT} ${cdashResultsString} PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_results_urls() +# +# Construct the build and test URLs on CDash given the site name, buildname, +# and buildstamp (taken from the TAG file) from inside of a running ctest -S +# program and optionally write it to a file as well. +# +# Usage:: +# +# tribits_get_cdash_results_urls( +# CDASH_BUILD_URL_OUT +# [CDASH_REVISION_BUILDS_URL_OUT ] +# [CDASH_REVISION_NONPASSING_TESTS_URL_OUT ] +# ) +# +# Here, the CDash URLs are constructed the following CMake variables already +# set in a ``ctest -S`` process: +# +# * ``CTEST_DROP_SITE`` +# * ``CTEST_DROP_LOCATION`` (``submit.php`` is replaced with ``index.php``) +# * ``CTEST_PROJECT_NAME`` +# * ``CTEST_SITE`` +# * ``CTEST_BUILD_NAME`` +# * ``CTEST_BINARY_DIRECTORY`` +# * ``CTEST_SOURCE_DIRECTORY`` +# +# and other information derived from that. +# +# The buildstamp is read in from the file +# ``${CTEST_BINARY_DIRECTORY}/Testing/TAG``. +# +# If available, the revision SHA1 is obtained from the git repo at +# ``CTEST_SOURCE_DIRECTORY`` if the directory +# ``${CTEST_SOURCE_DIRECTORY}/.git`` exists. If the base project source +# directory is not a git reposistory, then ```` and +# ````, if requested, will be set to +# empty. +# +# Note that the CDash URLs will have ``https://`` added to the beginning so +# that GitHub Actions and other systems will put in a hyperlink to them. +# +function(tribits_get_cdash_results_urls) + # Parse args + cmake_parse_arguments(PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + # multi_value_keywords + "CDASH_BUILD_URL_OUT;CDASH_REVISION_BUILDS_URL_OUT;CDASH_REVISION_NONPASSING_TESTS_URL_OUT" + ) + tribits_check_for_unparsed_arguments(PARSE) + tribits_assert_parse_arg_one_value(PARSE CDASH_BUILD_URL_OUT) + tribits_assert_parse_arg_zero_or_one_value(PARSE CDASH_REVISION_BUILDS_URL_OUT + CDASH_REVISION_NONPASSING_TESTS_URL_OUT) + # Get the info + tribits_get_cdash_build_url(cdashBuildUrl) + tribits_git_repo_sha1("${CTEST_SOURCE_DIRECTORY}" gitRepoSha1 + FAILURE_MESSAGE_OUT gitRepoSha1FailureMsg) + if (gitRepoSha1) + tribits_get_cdash_site_from_drop_site_and_location( + CTEST_DROP_SITE "${CTEST_DROP_SITE}" + CTEST_DROP_LOCATION "${CTEST_DROP_LOCATION}" + CDASH_SITE_URL_OUT cdashSiteUrl + ) + tribits_get_cdash_revision_builds_url( + CDASH_SITE_URL "${cdashSiteUrl}" + PROJECT_NAME "${CTEST_PROJECT_NAME}" + GIT_REPO_SHA1 "${gitRepoSha1}" + CDASH_REVISION_BUILDS_URL_OUT cdashRevisionBuildsUrl + ) + tribits_get_cdash_revision_nonpassing_tests_url( + CDASH_SITE_URL "${cdashSiteUrl}" + PROJECT_NAME "${CTEST_PROJECT_NAME}" + GIT_REPO_SHA1 "${gitRepoSha1}" + CDASH_REVISION_NONPASSING_TESTS_URL_OUT cdashRevisionNonpassingTestsUrl + ) + else() + set(cdashRevisionBuildsUrl "") + set(cdashRevisionNonpassingTestsUrl "") + endif() + # Set the outputs + set(${PARSE_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE) + set(${PARSE_CDASH_REVISION_BUILDS_URL_OUT} "${cdashRevisionBuildsUrl}" + PARENT_SCOPE) + set(${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL_OUT} "${cdashRevisionNonpassingTestsUrl}" + PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_revision_builds_url() +# +# Get the CDash URL for all builds with the same repo version SHA1 +# +# Usage:: +# +# tribits_get_cdash_revision_builds_url( +# CDASH_SITE_URL +# PROJECT_NAME +# GIT_REPO_SHA1 +# CDASH_REVISION_BUILDS_URL_OUT +# ) +# +function(tribits_get_cdash_revision_builds_url) + cmake_parse_arguments(PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + # multi_value_keywords + "CDASH_SITE_URL;PROJECT_NAME;GIT_REPO_SHA1;CDASH_REVISION_BUILDS_URL_OUT" + ) + tribits_check_for_unparsed_arguments() + tribits_assert_parse_arg_one_value(PARSE CDASH_SITE_URL PROJECT_NAME + GIT_REPO_SHA1 CDASH_REVISION_BUILDS_URL_OUT) + set(${PARSE_CDASH_REVISION_BUILDS_URL_OUT} + "${PARSE_CDASH_SITE_URL}/index.php?project=${PARSE_PROJECT_NAME}&filtercount=1&showfilters=1&field1=revision&compare1=61&value1=${PARSE_GIT_REPO_SHA1}" + PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_revision_nonpassing_tests_url() +# +# Get the CDash URL for all non-passing tests with the same repo version SHA1 +# +# Usage:: +# +# tribits_get_cdash_revision_nonpassing_tests_url( +# CDASH_SITE_URL +# PROJECT_NAME +# GIT_REPO_SHA1 +# CDASH_REVISION_NONPASSING_TESTS_URL_OUT +# ) +# +function(tribits_get_cdash_revision_nonpassing_tests_url) + cmake_parse_arguments( PARSE_ARGV 0 + PARSE "" "" # prefix, options, one_value_keywords + # multi_value_keywords + "CDASH_SITE_URL;PROJECT_NAME;GIT_REPO_SHA1;CDASH_REVISION_NONPASSING_TESTS_URL_OUT" + ) + tribits_check_for_unparsed_arguments() + tribits_assert_parse_arg_one_value(PARSE CDASH_SITE_URL PROJECT_NAME + GIT_REPO_SHA1 CDASH_REVISION_NONPASSING_TESTS_URL_OUT) + set(${PARSE_CDASH_REVISION_NONPASSING_TESTS_URL_OUT} + "${PARSE_CDASH_SITE_URL}/queryTests.php?project=${PARSE_PROJECT_NAME}&filtercount=2&showfilters=1&filtercombine=and&field1=revision&compare1=61&value1=${PARSE_GIT_REPO_SHA1}&field2=status&compare2=62&value2=passed" + PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_build_url() +# +# Construct the build URL on CDash given the site name, buildname, and +# buildstamp (taken from the TAG file) from inside of a running ctest -S +# program. +# +# Usage:: +# +# tribits_get_cdash_build_url() +# +# Here, ```` returns the CDash Build URL constructed from +# the following CMake variables already set in a ``ctest -S`` process: +# +# * ``CTEST_DROP_SITE`` +# * ``CTEST_DROP_LOCATION`` (``submit.php`` is replaced with ``index.php``) +# * ``CTEST_PROJECT_NAME`` +# * ``CTEST_SITE`` +# * ``CTEST_BUILD_NAME`` +# +# and the buildstamp read in from the file +# ``${CTEST_BINARY_DIRECTORY}/Testing/TAG``. +# +# Note that ```` will have ``https://`` added to the +# beginning of it so that GitHub Actions and other systems will put in a link +# to them. +# +function(tribits_get_cdash_build_url cdashBuildUrlOut) + tribits_get_cdash_index_php_from_drop_site_and_location( + CTEST_DROP_SITE "${CTEST_DROP_SITE}" + CTEST_DROP_LOCATION "${CTEST_DROP_LOCATION}" + INDEX_PHP_URL_OUT indexPhpUrl + ) + tribits_get_cdash_build_url_from_tag_file( + INDEX_PHP_URL "${indexPhpUrl}" + PROJECT_NAME "${CTEST_PROJECT_NAME}" + SITE_NAME "${CTEST_SITE}" + BUILD_NAME "${CTEST_BUILD_NAME}" + TAG_FILE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" + CDASH_BUILD_URL_OUT cdashBuildUrl + ) + set(${cdashBuildUrlOut} "${cdashBuildUrl}" PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_print_cdash_url() +# +# Print the URL on CDash where build results can be found. +# +# Usage:: +# +# tribits_print_cdash_url( ) +# +function(tribits_print_cdash_url msg cdashUrl) + message("\n${msg}\n") + message(" ${cdashUrl}\n") +endfunction() + + +# @FUNCTION: tribits_get_cdash_build_url_from_tag_file() +# +# Create CDash index.php URL from the build parts. +# +# Usage:: +# +# tribits_get_cdash_build_url_from_tag_file( +# INDEX_PHP_URL +# PROJECT_NAME +# SITE_NAME +# BUILD_NAME +# TAG_FILE +# CDASH_BUILD_URL_OUT +# ) +# +# Note that spaces are allowed ```` or ```` and those +# will be handled correctly to produce a valid URL. +# +function(tribits_get_cdash_build_url_from_tag_file) + # Get arguments + cmake_parse_arguments( + PREFIX #prefix + "" #options + "INDEX_PHP_URL;PROJECT_NAME;SITE_NAME;BUILD_NAME;TAG_FILE;CDASH_BUILD_URL_OUT" #one_value_keywords + "" #multi_value_keywords + ${ARGN} + ) + # Read in the tag file and get the build stamp from that + tribits_read_ctest_tag_file(${PREFIX_TAG_FILE} buildStartTime cdashGroup + cdashModel # The model is not used here but we still need to include this arg + ) + set(buildstamp "${buildStartTime}-${cdashGroup}") + # Build the URL and return it + tribits_get_cdash_build_url_from_parts( + INDEX_PHP_URL "${PREFIX_INDEX_PHP_URL}" + PROJECT_NAME "${PREFIX_PROJECT_NAME}" + SITE_NAME "${PREFIX_SITE_NAME}" + BUILD_NAME "${PREFIX_BUILD_NAME}" + BUILD_STAMP "${buildstamp}" + CDASH_BUILD_URL_OUT cdashBuildUrl + ) + set(${PREFIX_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_index_php_from_drop_site_and_location() +# +# Get the CDash index.php URL from the input CTEST_DROP_SITE and +# CTEST_DROP_LOCATION vars used in a ctest -S script. +# +function(tribits_get_cdash_index_php_from_drop_site_and_location) + cmake_parse_arguments( + PREFIX #prefix + "" #options + "CTEST_DROP_SITE;CTEST_DROP_LOCATION;INDEX_PHP_URL_OUT" #one_value_keywords + "" #multi_value_keywords + ${ARGN} + ) + tribits_get_cdash_site_from_drop_site_and_location( + CTEST_DROP_SITE ${PREFIX_CTEST_DROP_SITE} + CTEST_DROP_LOCATION ${PREFIX_CTEST_DROP_LOCATION} + CDASH_SITE_URL_OUT cdashSiteUrl ) + SET(${PREFIX_INDEX_PHP_URL_OUT} "${cdashSiteUrl}/index.php" PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_site_from_drop_site_and_location() +# +# Get the full CDash site base URL from the input CTEST_DROP_SITE and +# CTEST_DROP_LOCATION vars used in a ctest -S script. +# +# Usage:: +# +# tribits_get_cdash_site_from_drop_site_and_location( +# CTEST_DROP_SITE +# CTEST_DROP_LOCATION +# CDASH_SITE_URL_OUT +# ) +# +function(tribits_get_cdash_site_from_drop_site_and_location) + # Parse args + cmake_parse_arguments(PARSE_ARGV 0 + PREFIX #prefix + "" #options + "CTEST_DROP_SITE;CTEST_DROP_LOCATION;CDASH_SITE_URL_OUT" #one_value_keywords + "" #multi_value_keywords + ) + tribits_check_for_unparsed_arguments(PREFIX) + tribits_assert_parse_arg_one_value(PREFIX CTEST_DROP_SITE) + tribits_assert_parse_arg_one_value(PREFIX CTEST_DROP_LOCATION) + tribits_assert_parse_arg_one_value(PREFIX CDASH_SITE_URL_OUT) + # Get the full CDash site from parts + string(FIND "${PREFIX_CTEST_DROP_LOCATION}" "?" endOfSubmitPhpIdx) + string(SUBSTRING "${PREFIX_CTEST_DROP_LOCATION}" 0 ${endOfSubmitPhpIdx} submitPhpPart) + string(REPLACE "/submit.php" "" endCDashUrl "${submitPhpPart}") + set(cdashSiteUrl "${PREFIX_CTEST_DROP_SITE}${endCDashUrl}") + set(${PREFIX_CDASH_SITE_URL_OUT} "https://${cdashSiteUrl}" PARENT_SCOPE) +endfunction() + + +# @FUNCTION: tribits_get_cdash_build_url_from_parts() +# +# Create CDash index.php URL from the build parts. +# +# Usage:: +# +# tribits_get_cdash_build_url_from_parts( +# INDEX_PHP_URL +# PROJECT_NAME +# SITE_NAME +# BUILD_NAME +# BUILD_STAMP +# CDASH_BUILD_URL_OUT +# ) +# +# Note that spaces are allowed ````, ```` or +# ```` and those will be handled correctly to produce a valid URL. +# +function(tribits_get_cdash_build_url_from_parts) + # Get arguments + cmake_parse_arguments( + PREFIX #prefix + "" #options + "INDEX_PHP_URL;PROJECT_NAME;SITE_NAME;BUILD_NAME;BUILD_STAMP;CDASH_BUILD_URL_OUT" #one_value_keywords + "" #multi_value_keywords + ${ARGN} + ) + # Do replacements for spaces and special chars in data + tribits_replace_chars_for_url("${PREFIX_PROJECT_NAME}" project) + tribits_replace_chars_for_url("${PREFIX_SITE_NAME}" site) + tribits_replace_chars_for_url("${PREFIX_BUILD_NAME}" buildname) + tribits_replace_chars_for_url("${PREFIX_BUILD_STAMP}" buildstamp) + # Build the URL + set(cdashIndexProj "${PREFIX_INDEX_PHP_URL}?project=${project}") + set(filtersPreTxt "filtercount=3&showfilters=1&filtercombine=and") + set(siteFlt "field1=site&compare1=61&value1=${site}") + set(buildnameFlt "field2=buildname&compare2=61&value2=${buildname}") + set(buildStampFlt "field3=buildstamp&compare3=61&value3=${buildstamp}") + set(cdashBuildUrl + "${cdashIndexProj}&${filtersPreTxt}&${siteFlt}&${buildnameFlt}&${buildStampFlt}") + set(${PREFIX_CDASH_BUILD_URL_OUT} "${cdashBuildUrl}" PARENT_SCOPE) +endfunction() + + +# Replace chars in a regular string for usage in a URL with CDash +# +function(tribits_replace_chars_for_url inputStr outputStrForUrlOutVar) + set(outputStrForUrl "${inputStr}") + string(REPLACE " " "%20" outputStrForUrl "${outputStrForUrl}") + string(REPLACE "+" "%2B" outputStrForUrl "${outputStrForUrl}") + set(${outputStrForUrlOutVar} "${outputStrForUrl}" PARENT_SCOPE) +endfunction() + +# LocalWords: GitHub tribits url buildname buildstamp +# LocalWords: tribits TRIBITS +# LocalWords: cmake CMake CMAKE +# LocalWords: ctest CTEST cdash CDash CDASH +# LocalWords: SUBSTRING +# LocalWords: endif endfunction diff --git a/tribits/ctest_driver/TribitsReadTagFile.cmake b/tribits/ctest_driver/TribitsReadTagFile.cmake index 6fac636d7..5400b55f1 100644 --- a/tribits/ctest_driver/TribitsReadTagFile.cmake +++ b/tribits/ctest_driver/TribitsReadTagFile.cmake @@ -10,6 +10,7 @@ function(tribits_read_ctest_tag_file tagFileIn buildStartTimeOut cdashGroupOut cdashModelOut ) + cmake_policy(SET CMP0007 NEW) file(READ "${tagFileIn}" tagFileStr) string(REPLACE "\n" ";" tagFileStrList "${tagFileStr}") list(GET tagFileStrList 0 buildStartTime) diff --git a/tribits/ctest_driver/experimental_build_test.cmake b/tribits/ctest_driver/experimental_build_test.cmake index 0b36b05e8..0c70ab4a7 100644 --- a/tribits/ctest_driver/experimental_build_test.cmake +++ b/tribits/ctest_driver/experimental_build_test.cmake @@ -100,7 +100,7 @@ include(SetDefaultAndFromEnv) # All these can be changed by env vars set(CTEST_TEST_TYPE Experimental) -set(CTEST_DO_UPDATES FALSE) +set(CTEST_UPDATE_VERSION_ONLY TRUE) set(${PROJECT_NAME}_WARNINGS_AS_ERRORS_FLAGS "-Werror") # Don't change these in the env! diff --git a/tribits/doc/guides/TribitsGuidesBody.rst b/tribits/doc/guides/TribitsGuidesBody.rst index 6a6e62faa..fd4094662 100644 --- a/tribits/doc/guides/TribitsGuidesBody.rst +++ b/tribits/doc/guides/TribitsGuidesBody.rst @@ -2185,12 +2185,11 @@ downstream dependencies`_). For each TPL referenced in a `/TPLsList.cmake`_ file using the macro `tribits_repository_define_tpls()`_, there must exist a file, typically called -``FindTPL${TPL_NAME}.cmake``, that once processed, produces the variables -``TPL_${TPL_NAME}_LIBRARIES`` and ``TPL_${TPL_NAME}_INCLUDE_DIRS``. Most -``FindTPL${TPL_NAME}.cmake`` files just use the function -`tribits_tpl_find_include_dirs_and_libraries()`_ the define the TriBITS TPL. -A simple example of such a file is the common TriBITS ``FindTPLPETSC.cmake`` -module which is currently: +``FindTPL${TPL_NAME}.cmake``, that once processed, produces the target +```${TPL_NAME}::all_libs``. Most ``FindTPL${TPL_NAME}.cmake`` files just use +the function `tribits_tpl_find_include_dirs_and_libraries()`_ to define the +TriBITS TPL. A simple example of such a file is the common TriBITS +``FindTPLPETSC.cmake`` module which is currently: .. include:: ../../common_tpls/FindTPLPETSC.cmake :literal: @@ -2253,11 +2252,10 @@ override and specialize how a TPL's include directories and libraries are determined. However, note that the TriBITS system does not require the usage of the function ``tribits_tpl_find_include_dirs_and_libraries()`` and does not even care about the TPL module name ``FindTPL${TPL_NAME}.cmake``. All that is -required is that some CMake file fragment exist that once included, will -define the variables ``${TPL_NAME}_LIBRARIES`` and -``${TPL_NAME}_INCLUDE_DIRS``. However, to be user friendly, such a CMake file -should respond to the same variables as accepted by the standard -``tribits_tpl_find_include_dirs_and_libraries()`` function. +required is that some CMake file fragment exist such that, once included, will +define the target ``${TPL_NAME}::all_libs``. However, to be user friendly, +such a CMake file should respond to the same variables as accepted by the +standard ``tribits_tpl_find_include_dirs_and_libraries()`` function. The core variables related to an enabled TPL are ``${TPL_NAME}_LIBRARIES``, ``${TPL_NAME}_INCLUDE_DIRS``, and ``${TPL_NAME}_TESTGROUP`` as defined in diff --git a/tribits/doc/guides/UtilsMacroFunctionDocTemplate.rst b/tribits/doc/guides/UtilsMacroFunctionDocTemplate.rst index e75e63e38..f5c4cf397 100644 --- a/tribits/doc/guides/UtilsMacroFunctionDocTemplate.rst +++ b/tribits/doc/guides/UtilsMacroFunctionDocTemplate.rst @@ -44,5 +44,6 @@ @FUNCTION: unittest_has_substr_const() + @FUNCTION: unittest_not_has_substr_const() + @FUNCTION: unittest_string_regex() + +@FUNCTION: unittest_string_var_regex() + @FUNCTION: unittest_file_regex() + @FUNCTION: unittest_final_result() + diff --git a/tribits/examples/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake b/tribits/examples/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake index 957707d9b..13461825a 100644 --- a/tribits/examples/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject/packages/simple_cxx/cmake/Dependencies.cmake @@ -1,5 +1,5 @@ tribits_package_define_dependencies( LIB_REQUIRED_TPLS HeaderOnlyTpl - LIB_OPTIONAL_TPLS SimpleTpl + LIB_OPTIONAL_TPLS SimpleTpl MPI REGRESSION_EMAIL_LIST simplecxx-regressions@someurl.none ) diff --git a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt index c24397019..3adfc2cdb 100644 --- a/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt +++ b/tribits/examples/TribitsExampleProject/packages/wrap_external/CMakeLists.txt @@ -144,7 +144,6 @@ add_dependencies(build_external_func pws_a) # E.3) Update the TriBITS variables append_set(${PACKAGE_NAME}_LIB_TARGETS external_func) global_set(${PACKAGE_NAME}_LIBRARIES external_func pws_a) -global_set(${PACKAGE_NAME}_INCLUDE_DIRS ${EXTERNAL_FUNC_SOURCE_DIR}) global_set(${PACKAGE_NAME}_HAS_NATIVE_LIBRARIES ON) include_directories(${EXTERNAL_FUNC_SOURCE_DIR}) # NOTE: Above, you have to add the upstream dependent libraries to the current diff --git a/tribits/examples/TribitsExampleProject2/packages/package2/cmake/Dependencies.cmake b/tribits/examples/TribitsExampleProject2/packages/package2/cmake/Dependencies.cmake index 7351d3a19..46c260a26 100644 --- a/tribits/examples/TribitsExampleProject2/packages/package2/cmake/Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject2/packages/package2/cmake/Dependencies.cmake @@ -1,5 +1,4 @@ tribits_package_define_dependencies( LIB_REQUIRED_PACKAGES Package1 LIB_OPTIONAL_TPLS Tpl3 - Tpl2 Tpl1 # ToDo: Remove this line once TPL dependencies are implemented! (#299) ) diff --git a/tribits/examples/TribitsExampleProject2/packages/package3/cmake/Dependencies.cmake b/tribits/examples/TribitsExampleProject2/packages/package3/cmake/Dependencies.cmake index bde6d5305..6e9a0e1e4 100644 --- a/tribits/examples/TribitsExampleProject2/packages/package3/cmake/Dependencies.cmake +++ b/tribits/examples/TribitsExampleProject2/packages/package3/cmake/Dependencies.cmake @@ -2,7 +2,5 @@ tribits_package_define_dependencies( LIB_REQUIRED_PACKAGES Package1 LIB_OPTIONAL_PACKAGES Package2 LIB_REQUIRED_TPLS Tpl2 - Tpl1 # ToDo: Remove this line once TPL dependencies are implemented! (#299) LIB_OPTIONAL_TPLS Tpl4 - Tpl3 # ToDo: Remove this line once TPL dependencies are implemented! (#299) ) diff --git a/tribits/examples/TribitsOldSimpleExampleApp/CMakeLists.txt b/tribits/examples/TribitsOldSimpleExampleApp/CMakeLists.txt index 0b8d334d5..34302ee7b 100644 --- a/tribits/examples/TribitsOldSimpleExampleApp/CMakeLists.txt +++ b/tribits/examples/TribitsOldSimpleExampleApp/CMakeLists.txt @@ -44,7 +44,7 @@ target_include_directories(util # Build the APP and link to libraries from TribitsExProj packages add_executable(app app.cpp) target_link_libraries(app - PRIVATE ${TribitsExProj_LIBRARIES}) + PRIVATE ${TribitsExProj_LIBRARIES} ${TribitsExProj_TPL_LIBRARIES}) target_include_directories(app PRIVATE ${TribitsExProj_INCLUDE_DIRS} ${TribitsExProj_TPL_INCLUDE_DIRS})