diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 4e50e93c4..127266aad 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 = 544" + "Final UnitTests Result: num_run = 550" "Final UnitTests Result: PASSED" ) diff --git a/test/core/ExamplesUnitTests/CMakeLists.txt b/test/core/ExamplesUnitTests/CMakeLists.txt index dd92f714a..777f453f9 100644 --- a/test/core/ExamplesUnitTests/CMakeLists.txt +++ b/test/core/ExamplesUnitTests/CMakeLists.txt @@ -4306,7 +4306,8 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithSubpkgsWithUserErrors_SU -DsubPackageA_DOUBLE_SUBPACKAGE_INIT=TRUE . PASS_REGULAR_EXPRESSION_ALL - "Already called TRIBITS_SUBPACKGE[(][)] for thePkgWithSubpkgsWithUserErrors" + "Already called TRIBITS_SUBPACKGE[(][)] for the PkgWithSubpkgsWithUserErrors" + "subpackage A" "Configuring incomplete, errors occurred!" ALWAYS_FAIL_ON_ZERO_RETURN @@ -4317,8 +4318,8 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithSubpkgsWithUserErrors_SU -DsubPAckageA_DOUBLE_SUBPACKAGE_POSTPROCESS=TRUE . PASS_REGULAR_EXPRESSION_ALL - "Already called TRIBITS_SUBPACKGE_POSTPROCESS[(][)] for" - "thePkgWithSubpkgsWithUserErrors subpackage A" + "Already called TRIBITS_SUBPACKGE_POSTPROCESS[(][)] for the" + "PkgWithSubpkgsWithUserErrors subpackage A" "Configuring incomplete, errors occurred!" ALWAYS_FAIL_ON_ZERO_RETURN @@ -4329,8 +4330,8 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_PkgWithSubpkgsWithUserErrors_SU -DsubPAckageA_DOUBLE_SUBPACKAGE_POSTPROCESS=FALSE . PASS_REGULAR_EXPRESSION_ALL - "TRIBITS_SUBPACKAGE[(][)] must be called before" - "TRIBITS_SUBPACKAGE_POSTPROCESS[(][)]for the PkgWithSubpkgsWithUserErrors" + "TRIBITS_SUBPACKAGE[(][)] must be called before TRIBITS_SUBPACKAGE_POSTPROCESS[(][)]" + " for the PkgWithSubpkgsWithUserErrors" "Configuring incomplete, errors occurred!" ALWAYS_FAIL_ON_ZERO_RETURN diff --git a/test/core/TestingFunctionMacro_UnitTests.cmake b/test/core/TestingFunctionMacro_UnitTests.cmake index 311fb2d24..a68e70ef0 100644 --- a/test/core/TestingFunctionMacro_UnitTests.cmake +++ b/test/core/TestingFunctionMacro_UnitTests.cmake @@ -58,6 +58,7 @@ INCLUDE(TribitsStripQuotesFromStr) INCLUDE(TribitsStandardizePaths) INCLUDE(TribitsGetVersionDate) INCLUDE(TribitsTplFindIncludeDirsAndLibraries) +INCLUDE(TribitsReportInvalidTribitsUsage) INCLUDE(UnitTestHelpers) INCLUDE(GlobalSet) INCLUDE(GlobalNullSet) @@ -556,6 +557,59 @@ FUNCTION(UNITTEST_TRIBITS_TPL_ALLOW_PRE_FIND_PACKAGE) ENDFUNCTION() +FUNCTION(UNITTEST_TRIBITS_REPORT_INVALID_TRIBITS_USAGE) + + MESSAGE("\n***") + MESSAGE("*** Testing TRIBITS_REPORT_INVALID_TRIBITS_USAGE()") + MESSAGE("***\n") + + SET(MESSAGE_WRAPPER_UNIT_TEST_MODE TRUE) + SET(PROJECT_NAME TRITU_PROJECT) + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): Default (FATAL_ERROR)") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went" " very wrong" " I think 1!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "FATAL_ERROR;Something went; very wrong; I think 1!") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): FATAL_ERROR") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE FATAL_ERROR) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went" " very wrong" " I think 2!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "FATAL_ERROR;Something went; very wrong; I think 2!") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): SEND_ERROR") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE SEND_ERROR) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went very wrong I think 3!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "SEND_ERROR;Something went very wrong I think 3!") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): WARNING") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE WARNING) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went very wrong I think 4!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "WARNING;Something went very wrong I think 4!") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): IGNORE") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE IGNORE) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went very wrong I think 5!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "") + + MESSAGE("TRIBITS_REPORT_INVALID_TRIBITS_USAGE(): INVALID_ARGUMENT") + GLOBAL_SET(MESSAGE_WRAPPER_INPUT) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE INVALID_ARGUMENT) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE("Something went very wrong I think 6!") + UNITTEST_COMPARE_CONST(MESSAGE_WRAPPER_INPUT + "FATAL_ERROR;Error, invalid value for; TRITU_PROJECT_ASSERT_CORRECT_TRIBITS_USAGE =; 'INVALID_ARGUMENT'!; Value values include 'FATAL_ERROR', 'SEND_ERROR', 'WARNING', and 'IGNORE'!") + +ENDFUNCTION() + + FUNCTION(UNITEST_TRIBITS_ADD_TEST_BASIC) MESSAGE("\n***") @@ -3590,6 +3644,7 @@ UNITEST_TRIBITS_STRIP_QUOTES_FROM_STR() UNITEST_TRIBITS_GET_VERSION_DATE_FROM_RAW_GIT_COMMIT_UTC_TIME() UNITEST_TRIBITS_GET_RAW_GIT_COMMIT_UTC_TIME() UNITTEST_TRIBITS_TPL_ALLOW_PRE_FIND_PACKAGE() +UNITTEST_TRIBITS_REPORT_INVALID_TRIBITS_USAGE() # Set the default test categories SET(${PROJECT_NAME}_TEST_CATEGORIES NIGHTLY) @@ -3641,4 +3696,4 @@ MESSAGE("*** Determine final result of all unit tests") MESSAGE("***\n") # Pass in the number of expected tests that must pass! -UNITTEST_FINAL_RESULT(544) +UNITTEST_FINAL_RESULT(550) diff --git a/tribits/core/package_arch/TribitsAddExecutable.cmake b/tribits/core/package_arch/TribitsAddExecutable.cmake index 29c4b9023..6745d93e8 100644 --- a/tribits/core/package_arch/TribitsAddExecutable.cmake +++ b/tribits/core/package_arch/TribitsAddExecutable.cmake @@ -42,6 +42,7 @@ INCLUDE(TribitsAddExecutableTestHelpers) INCLUDE(TribitsCommonArgsHelpers) INCLUDE(TribitsAddTestHelpers) INCLUDE(TribitsGeneralMacros) +INCLUDE(TribitsReportInvalidTribitsUsage) INCLUDE(PrintVar) INCLUDE(AppendSet) @@ -344,12 +345,14 @@ FUNCTION(TRIBITS_ADD_EXECUTABLE EXE_NAME) # This is a subpackage being processed IF(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_SUBPACKAGE() before TRIBITS_ADD_EXECUTABLE()" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_SUBPACKAGE() before TRIBITS_ADD_EXECUTABLE()" " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() IF(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_ADD_EXECUTABLE() before " + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_ADD_EXECUTABLE() before " " TRIBITS_SUBPACKAGE_POSTPROCESS() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() @@ -358,12 +361,14 @@ FUNCTION(TRIBITS_ADD_EXECUTABLE EXE_NAME) # This is a package being processed IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DECL() before" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DECL() before" " TRIBITS_ADD_EXECUTABLE() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_ADD_EXECUTABLE() before " + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_ADD_EXECUTABLE() before " " TRIBITS_PACKAGE_POSTPROCESS() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() @@ -488,25 +493,28 @@ FUNCTION(TRIBITS_ADD_EXECUTABLE EXE_NAME) FOREACH(IMPORTEDLIB ${PARSE_IMPORTEDLIBS}) SET(PREFIXED_LIB "${${PROJECT_NAME}_LIBRARY_NAME_PREFIX}${IMPORTEDLIB}") IF (${PREFIXED_LIB}_INCLUDE_DIRS) - MESSAGE(FATAL_ERROR "ERROR: Lib '${IMPORTEDLIB}' being passed through" - " IMPORTEDLIBS is not allowed to be a TESTONLY lib!" - " Use TESTONLYLIBS instead!" ) + MESSAGE(FATAL_ERROR + "ERROR: Lib '${IMPORTEDLIB}' being passed through" + " IMPORTEDLIBS is not allowed to be a TESTONLY lib!" + " Use TESTONLYLIBS instead!" ) ENDIF() LIST(FIND ${PACKAGE_NAME}_LIBRARIES ${PREFIXED_LIB} FOUND_IDX) IF (NOT FOUND_IDX EQUAL -1) - MESSAGE(FATAL_ERROR "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!") + MESSAGE(FATAL_ERROR + "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}) - MESSAGE(FATAL_ERROR "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" - " SE packages. If you want to link to a library in an upstream SE" - " package then add the SE package name for that library to the appropriate" - " list in this SE package's dependencies file" - " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") + MESSAGE(FATAL_ERROR + "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" + " SE packages. If you want to link to a library in an upstream SE" + " package then add the SE package name for that library to the appropriate" + " list in this SE package's dependencies file" + " ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/Dependencies.cmake") ENDIF() ENDFOREACH() diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index 8d1c0ed1f..65f207fc9 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -51,6 +51,7 @@ INCLUDE(TribitsVerbosePrintVar) INCLUDE(TribitsProcessEnabledTpl) INCLUDE(TribitsInstallHeaders) INCLUDE(TribitsGetVersionDate) +INCLUDE(TribitsReportInvalidTribitsUsage) # Standard TriBITS utilities includes INCLUDE(TribitsAddOptionAndDefine) @@ -622,16 +623,32 @@ MACRO(TRIBITS_DEFINE_GLOBAL_OPTIONS_AND_DEFINE_EXTRA_REPOS) "Relative CPU speed of the computer used to scale performance tests (default 1.0)." ) + IF ("${${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE_DEFAULT}" STREQUAL "") + SET(${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE_DEFAULT ON) + ENDIF() ADVANCED_SET( ${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE ${${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE_DEFAULT} CACHE BOOL - "Determines if a variety of development mode checks are turned on by default or not." ) + "Determines if a variety of development mode checks are turned on by default or not." + ) ADVANCED_SET( ${PROJECT_NAME}_ASSERT_MISSING_PACKAGES ${${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE} CACHE BOOL "Determines if asserts are performed on missing packages or not." ) + IF ("${${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE_DEFAULT}" STREQUAL "") + IF (${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE) + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE_DEFAULT FATAL_ERROR) + ELSE() + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE_DEFAULT IGNORE) + ENDIF() + ENDIF() + ADVANCED_SET( ${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE + "${${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE_DEFAULT}" + CACHE BOOL + "Assert correct usage of TriBITS. Value values include 'FATAL_ERROR', 'SEND_ERROR', 'WARNING', and 'IGNORE'. Default '${${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE_DEFAULT}' " ) + ADVANCED_SET( ${PROJECT_NAME}_WARN_ABOUT_MISSING_EXTERNAL_PACKAGES FALSE CACHE BOOL "If set to TRUE, a 'NOTE' is printed for each missing package that is ignored." ) @@ -2568,9 +2585,9 @@ MACRO(TRIBITS_CONFIGURE_ENABLED_PACKAGES) INCLUDE("${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() IF (NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS) - MESSAGE(FATAL_ERROR - "ERROR: Forgot to call TRIBITS_PACKAGE_POSTPROCESS() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}" - ) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "ERROR: Forgot to call TRIBITS_PACKAGE_POSTPROCESS() in" + " ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() LIST(APPEND ENABLED_PACKAGE_LIBS_TARGETS ${TRIBITS_PACKAGE}_libs) diff --git a/tribits/core/package_arch/TribitsLibraryMacros.cmake b/tribits/core/package_arch/TribitsLibraryMacros.cmake index 3ce74b2d6..882a1fde8 100644 --- a/tribits/core/package_arch/TribitsLibraryMacros.cmake +++ b/tribits/core/package_arch/TribitsLibraryMacros.cmake @@ -47,6 +47,7 @@ INCLUDE(AppendStringVar) INCLUDE(PrependGlobalSet) INCLUDE(RemoveGlobalDuplicates) INCLUDE(TribitsGeneralMacros) +INCLUDE(TribitsReportInvalidTribitsUsage) INCLUDE(SetAndIncDirs) ### @@ -483,12 +484,14 @@ FUNCTION(TRIBITS_ADD_LIBRARY LIBRARY_NAME_IN) # This is a subpackage being processed IF(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_SUBPACKAGE() before TRIBITS_ADD_LIBRARY()" + 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) - MESSAGE(FATAL_ERROR "Must call TRIBITS_ADD_LIBRARY() before " + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_ADD_LIBRARY() before " " TRIBITS_SUBPACKAGE_POSTPROCESS() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() @@ -497,12 +500,14 @@ FUNCTION(TRIBITS_ADD_LIBRARY LIBRARY_NAME_IN) # This is a package being processed IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DECL() before" + 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) - MESSAGE(FATAL_ERROR "Must call TRIBITS_ADD_LIBRARY() before " + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_ADD_LIBRARY() before " " TRIBITS_PACKAGE_POSTPROCESS() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() diff --git a/tribits/core/package_arch/TribitsPackageMacros.cmake b/tribits/core/package_arch/TribitsPackageMacros.cmake index dd6210410..73fb7cc33 100644 --- a/tribits/core/package_arch/TribitsPackageMacros.cmake +++ b/tribits/core/package_arch/TribitsPackageMacros.cmake @@ -56,6 +56,7 @@ INCLUDE(TribitsAddExecutableAndTest) INCLUDE(TribitsAddTest) INCLUDE(TribitsAddAdvancedTest) INCLUDE(TribitsCopyFilesToBinaryDir) +INCLUDE(TribitsReportInvalidTribitsUsage) ### @@ -189,17 +190,19 @@ MACRO(TRIBITS_PACKAGE_DECL PACKAGE_NAME_IN) ENDIF() IF (CURRENTLY_PROCESSING_SUBPACKAGE) - MESSAGE(FATAL_ERROR "Cannot call TRIBITS_PACKAGE_DECL() in a subpackage." + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Cannot call TRIBITS_PACKAGE_DECL() in a subpackage." " Use TRIBITS_SUBPACKAGE() instead" " error in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - MESSAGE(FATAL_ERROR "TRIBITS_PACKAGE_DECL() called more than once in Package ${PACKAGE_NAME}" - "This may be because TRIBITS_PACKAGE_DECL was expicitly called more than once or" - "TRIBITS_PACKAGE_DECL was called after TRIBITS_PACKAGE. You do not need both." - "If your package has subpackages then do not call TRIBITS_PACKAGE() instead call:" - "TRIBITS_PACAKGE_DECL then TRIBITS_PROCESS_SUBPACKAGES then TRIBITS PACKAGE_DEF" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "TRIBITS_PACKAGE_DECL() called more than once in Package ${PACKAGE_NAME}" + " This may be because TRIBITS_PACKAGE_DECL was expicitly called more than once or" + " TRIBITS_PACKAGE_DECL was called after TRIBITS_PACKAGE. You do not need both." + " If your package has subpackages then do not call TRIBITS_PACKAGE() instead call:" + " TRIBITS_PACAKGE_DECL then TRIBITS_PROCESS_SUBPACKAGES then TRIBITS PACKAGE_DEF" ) ENDIF() @@ -303,7 +306,8 @@ MACRO(TRIBITS_PACKAGE_DEF) # check that this is not being called from a subpackage IF(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) IF (CURRENTLY_PROCESSING_SUBPACKAGE) - MESSAGE(FATAL_ERROR "Cannot call TRIBITS_PACKAGE_DEF() in a subpackage." + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Cannot call TRIBITS_PACKAGE_DEF() in a subpackage." " Use TRIBITS_SUBPACKAGE() instead" " error in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() @@ -314,9 +318,9 @@ MACRO(TRIBITS_PACKAGE_DEF) # check that this is not called morethan once in a package IF (${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED) - MESSAGE(FATAL_ERROR "TRIBITS_PACKAGE_DEF was called more than once in" - "${CURRENT_SUBPACKAGE_CMAKELIST_FILE}" - ) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "TRIBITS_PACKAGE_DEF was called more than once in" + "${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() IF (${PROJECT_NAME}_VERBOSE_CONFIGURE) @@ -365,25 +369,27 @@ MACRO(TRIBITS_PACKAGE PACKAGE_NAME_IN) IF (CURRENTLY_PROCESSING_SUBPACKAGE) IF (NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Cannot call TRIBITS_PACKAGE() in a subpackage." - " Use TRIBITS_SUBPACKAGE() instead" - " error in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Cannot call TRIBITS_PACKAGE() in a subpackage." + " Use TRIBITS_SUBPACKAGE() instead" + " error in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() ENDIF() IF(${PACKAGE_NAME}_SUBPACKAGES) - MESSAGE(FATAL_ERROR "This package has subpackages so you cannot use TRIBITS_PACKAGE()" - "\n Instead use the following call order:" - "\n TRIBITS_PROJECT_DECL(${PACKAGE_NAME})" - "\n TRIBITS_PROCESS_SUBPACKAGES()" - "\n [do other things you want to do]" - "\n TRIBITS_PACKAGE_DEF()" - "\n TRIBITS_PACKAGE_POSTPROCESS()" - ) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "This package has subpackages so you cannot use TRIBITS_PACKAGE()" + "\n Instead use the following call order:" + "\n TRIBITS_PROJECT_DECL(${PACKAGE_NAME})" + "\n TRIBITS_PROCESS_SUBPACKAGES()" + "\n [do other things you want to do]" + "\n TRIBITS_PACKAGE_DEF()" + "\n TRIBITS_PACKAGE_POSTPROCESS()" ) ENDIF() IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_CALLED) - MESSAGE(FATAL_ERROR "Package ${PACKAGE_NAME} declared more than once!") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Package ${PACKAGE_NAME} declared more than once!") ENDIF() SET(${PACKAGE_NAME}_TRIBITS_PACKAGE_CALLED TRUE) @@ -421,12 +427,14 @@ MACRO(TRIBITS_ADD_TEST_DIRECTORIES) # This is a subpackage being processed IF(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_SUBPACKAGE() before TRIBITS_ADD_TEST_DIRECTORIES()" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_SUBPACKAGE() before TRIBITS_ADD_TEST_DIRECTORIES()" " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() IF(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_ADD_TEST_DIRECTORIES() before " + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_ADD_TEST_DIRECTORIES() before " " TRIBITS_SUBPACKAGE_POSTPROCESS() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() @@ -435,12 +443,14 @@ MACRO(TRIBITS_ADD_TEST_DIRECTORIES) # This is a package being processed IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DECL() before" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DECL() before" " TRIBITS_ADD_TEST_DIRECTORIES() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_ADD_TEST_DIRECTORIES() before " + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_ADD_TEST_DIRECTORIES() before " " TRIBITS_PACKAGE_POSTPROCESS() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() @@ -571,12 +581,14 @@ MACRO(TRIBITS_ADD_EXAMPLE_DIRECTORIES) # This is a subpackage being processed IF(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_SUBPACKAGE() before TRIBITS_ADD_EXAMPLE_DIRECTORIES()" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_SUBPACKAGE() before TRIBITS_ADD_EXAMPLE_DIRECTORIES()" " in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() IF(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_ADD_EXAMPLE_DIRECTORIES() before " + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_ADD_EXAMPLE_DIRECTORIES() before " " TRIBITS_SUBPACKAGE_POSTPROCESS() in ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() @@ -584,12 +596,14 @@ MACRO(TRIBITS_ADD_EXAMPLE_DIRECTORIES) # This is a package being processed IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DECL() before" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DECL() before" " TRIBITS_ADD_EXAMPLE_DIRECTORIES() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_ADD_EXAMPLE_DIRECTORIES() before " + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_ADD_EXAMPLE_DIRECTORIES() before " " TRIBITS_PACKAGE_POSTPROCESS() in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() @@ -728,9 +742,10 @@ MACRO(TRIBITS_PACKAGE_POSTPROCESS) # check that this is not being called from inside a subpackage IF (CURRENTLY_PROCESSING_SUBPACKAGE) IF(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Cannot call TRIBITS_PACKAGE_POSTPROCESS() in a subpackage." - " Use TRIBITS_SUBPACKAGE_POSTPROCESS() instead" - " ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Cannot call TRIBITS_PACKAGE_POSTPROCESS() in a subpackage." + " Use TRIBITS_SUBPACKAGE_POSTPROCESS() instead" + " ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() ENDIF() @@ -741,17 +756,18 @@ MACRO(TRIBITS_PACKAGE_POSTPROCESS) NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED OR NOT ${PACKAGE_NAME}_TRIBITS_PROCESS_SUBPACKAGES_CALLED ) - MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE_DECL(), TRIBITS_PROCESS_SUBPACKAGES()" - "and TRIBITS_PACKAGE_DEF before TRIBITS_PACKAGE_POSTPROCESS()." - " Because this package has subpackages you cannot use TRIBITS_PACKAGE()" - " you must call these in the following order:" - " TRIBITS_PACKAGE_DECL" - " TRIBITS_PROCESS_SUBPACKAGES" - " TRIBITS_PACKAGE_DEF" - " TRIBITS_PACKAGE_POSTPROCESS" - " in file: " - "${TRIBITS_PACKAGE_CMAKELIST_FILE}" - ) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_PACKAGE_DECL(), TRIBITS_PROCESS_SUBPACKAGES()" + "and TRIBITS_PACKAGE_DEF before TRIBITS_PACKAGE_POSTPROCESS()." + " Because this package has subpackages you cannot use TRIBITS_PACKAGE()" + " you must call these in the following order:" + " TRIBITS_PACKAGE_DECL" + " TRIBITS_PROCESS_SUBPACKAGES" + " TRIBITS_PACKAGE_DEF" + " TRIBITS_PACKAGE_POSTPROCESS" + " in file: " + "${TRIBITS_PACKAGE_CMAKELIST_FILE}" + ) ENDIF() ELSE() @@ -763,7 +779,8 @@ MACRO(TRIBITS_PACKAGE_POSTPROCESS) AND (NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED) ) - MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DEF() before" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_PACKAGE() or TRIBITS_PACKAGE_DEF() before" " TRIBITS_PACKAGE_POSTPROCESS()" " at the top of the file:\n" " ${TRIBITS_PACKAGE_CMAKELIST_FILE}" @@ -773,16 +790,19 @@ MACRO(TRIBITS_PACKAGE_POSTPROCESS) ENDIF() IF(NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED) - MESSAGE(FATAL_ERROR "Must call TRIBITS_PACKAGE() before TRIBITS_PACKAGE_POSTPROCESS()" - "Or if your package has subpackages you must first call TRIBITS_PACKAGE_DECL, " - "then TRIBITS_PROCESS_SUBPACKAGES, then TRIBITS_PACKAGE_DEF, then" - " TRIBITS_PACKAGE_POSTPROCESS" - " ${TRIBITS_PACKAGE_CMAKELIST_FILE}" - ) + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Must call TRIBITS_PACKAGE() before TRIBITS_PACKAGE_POSTPROCESS()" + "Or if your package has subpackages you must first call TRIBITS_PACKAGE_DECL, " + "then TRIBITS_PROCESS_SUBPACKAGES, then TRIBITS_PACKAGE_DEF, then" + " TRIBITS_PACKAGE_POSTPROCESS" + " ${TRIBITS_PACKAGE_CMAKELIST_FILE}" + ) ENDIF() IF(${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "TRIBITS_PACKAGE_POSTPROCESS() has been called more than once in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "TRIBITS_PACKAGE_POSTPROCESS() has been called more than once in" + " ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() # Only parent packages have the targets (${PACKAGE_NAME}_libs and @@ -826,31 +846,32 @@ ENDMACRO() MACRO(TRIBITS_PROCESS_SUBPACKAGES) IF (CURRENTLY_PROCESSING_SUBPACKAGE) - MESSAGE(FATAL_ERROR "Cannot call TRIBITS_PROCESS_SUBPACKAGES() in a subpackage." - " subpackages cannot contain other subpackages" - " ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Cannot call TRIBITS_PROCESS_SUBPACKAGES() in a subpackage." + " subpackages cannot contain other subpackages" + " ${CURRENT_SUBPACKAGE_CMAKELIST_FILE}") ENDIF() IF (${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( "Must call TRIBITS_PROCESS_SUBPACKAGES() before TRIBITS_PACKAGE_POSTPROCESS()" " in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() IF (NOT ${PACKAGE_NAME}_TRIBITS_PACKAGE_DECL_CALLED) - MESSAGE(FATAL_ERROR + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( "Must call TRIBITS_PACKAGE_DECL() before TRIBITS_PROCESS_SUBPACKAGES()" "in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() IF (${PACKAGE_NAME}_TRIBITS_PACKAGE_DEF_CALLED) - MESSAGE(FATAL_ERROR + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( "Must call TRIBITS_PACKAGE_DEF() after TRIBITS_PROCESS_SUBPACKAGES()" " in ${TRIBITS_PACKAGE_CMAKELIST_FILE}") ENDIF() IF (NOT ${PARENT_PACKAGE_NAME}_SUBPACKAGES) - MESSAGE(FATAL_ERROR + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( "The TriBITS Package '${PACKAGE_NAME}' does not have any subpackages." " Therefore, you are not allowed to call TRIBITS_PROCESS_SUBPACKAGES()!") ENDIF() diff --git a/tribits/core/package_arch/TribitsReportInvalidTribitsUsage.cmake b/tribits/core/package_arch/TribitsReportInvalidTribitsUsage.cmake new file mode 100644 index 000000000..f4bdaaeb7 --- /dev/null +++ b/tribits/core/package_arch/TribitsReportInvalidTribitsUsage.cmake @@ -0,0 +1,87 @@ +# @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 + +IF (__TribitsReportInvalidTribitsUsage_INCLUDED__) + RETURN() +ELSE() + SET(__TribitsReportInvalidTribitsUsage_INCLUDED__ TRUE) +ENDIF() + +INCLUDE(MessageWrapper) + +# Called to report incorrect usage +# +# Usage: +# +# TRIBITS_REPORT_INVALID_TRIBITS_USAGE("" "" ...) +# +# Depending on the value of ${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE, this +# function will: +# +# * FATAL_ERROR: Calls MESSAGE(FATAL_ERROR "") +# * SEND_ERROR: Calls MESSAGE(SEND_ERROR "") +# * WARNING: Calls MESSAGE(WARNING "") +# * IGNORE: Does not call MESSAGE() at all and is silent +# +# If '${${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE}' is empty on call, then +# `FATAL_ERROR` will be used. +# +FUNCTION(TRIBITS_REPORT_INVALID_TRIBITS_USAGE) + IF ("${${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE}" STREQUAL "") + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE FATAL_ERROR) + ENDIF() + SET(PRINT_ERR_MSG) + IF (${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE STREQUAL "FATAL_ERROR") + SET(PRINT_ERR_MSG FATAL_ERROR) + ELSEIF (${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE STREQUAL "SEND_ERROR") + SET(PRINT_ERR_MSG SEND_ERROR) + ELSEIF (${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE STREQUAL "WARNING") + SET(PRINT_ERR_MSG WARNING) + ELSEIF (${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE STREQUAL "IGNORE") + SET(PRINT_ERR_MSG) + ELSE() + MESSAGE_WRAPPER(FATAL_ERROR "Error, invalid value for" + " ${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE =" + " '${${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE}'!" + " Value values include 'FATAL_ERROR', 'SEND_ERROR', 'WARNING', and 'IGNORE'!") + ENDIF() + IF (PRINT_ERR_MSG) + MESSAGE_WRAPPER(${PRINT_ERR_MSG} ${ARGN}) + ENDIF() +ENDFUNCTION() diff --git a/tribits/core/package_arch/TribitsSubPackageMacros.cmake b/tribits/core/package_arch/TribitsSubPackageMacros.cmake index a164ae9f1..433ebbeb6 100644 --- a/tribits/core/package_arch/TribitsSubPackageMacros.cmake +++ b/tribits/core/package_arch/TribitsSubPackageMacros.cmake @@ -38,6 +38,7 @@ # @HEADER INCLUDE(TribitsPackageMacros) +INCLUDE(TribitsReportInvalidTribitsUsage) # @@ -81,27 +82,31 @@ MACRO(TRIBITS_SUBPACKAGE SUBPACKAGE_NAME_IN) IF (NOT CURRENTLY_PROCESSING_SUBPACKAGE) # we are in a package - MESSAGE(FATAL_ERROR "Cannot call TRIBITS_SUBPACKAGE() from a package." - " Use TRIBITS_PACKAGE() instead" - " ${CURRENT_PACKAGE_CMAKELIST_FILE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Cannot call TRIBITS_SUBPACKAGE() from a package." + " Use TRIBITS_PACKAGE() instead" + " ${CURRENT_PACKAGE_CMAKELIST_FILE}") ELSE() # We are in a subpackage # check to see if postprocess is called before subpackage IF(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "TRIBITS_SUBPACKAGE_POSTPROCESS() called before TRIBITS_SUBPACKAGE()") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "TRIBITS_SUBPACKAGE_POSTPROCESS() called before TRIBITS_SUBPACKAGE()") ENDIF() # check to see if we have already called this macro IF(${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - MESSAGE(FATAL_ERROR "Already called TRIBITS_SUBPACKGE() for the" - "${PARENT_PACKAGE_NAME} subpackage ${TRIBITS_SUBPACKAGE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Already called TRIBITS_SUBPACKGE() for the" + " ${PARENT_PACKAGE_NAME} subpackage ${TRIBITS_SUBPACKAGE}") ENDIF() # make sure the name in the macro call matches the name in the packages cmake file IF (NOT ${SUBPACKAGE_NAME_IN} STREQUAL ${SUBPACKAGE_NAME}) - MESSAGE(FATAL_ERROR "Error, the package-defined subpackage name" + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Error, the package-defined subpackage name" " '${SUBPACKAGE_NAME_IN}' is not the same as the subpackage name" " '${SUBPACKAGE_NAME}' defined in the parent packages's" " Dependencies.cmake file") @@ -147,23 +152,26 @@ MACRO(TRIBITS_SUBPACKAGE_POSTPROCESS) # This is being called from a package - MESSAGE(FATAL_ERROR "Cannot call TRIBITS_SUBPACKAGE_POSTPROCESS() from a package." - " Use TRIBITS_PACKAGE_POSTPROCESS() instead" - " ${CURRENT_PACKAGE_CMAKELIST_FILE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Cannot call TRIBITS_SUBPACKAGE_POSTPROCESS() from a package." + " Use TRIBITS_PACKAGE_POSTPROCESS() instead" + " ${CURRENT_PACKAGE_CMAKELIST_FILE}") ELSE() # This is being caleld from a subpackage # check to make sure this has not already been called IF (${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_POSTPROCESS_CALLED) - MESSAGE(FATAL_ERROR "Already called TRIBITS_SUBPACKGE_POSTPROCESS() for the" - "${PARENT_PACKAGE_NAME} subpackage ${TRIBITS_SUBPACKAGE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "Already called TRIBITS_SUBPACKGE_POSTPROCESS() for the" + " ${PARENT_PACKAGE_NAME} subpackage ${TRIBITS_SUBPACKAGE}") ENDIF() # make sure subpackage is called prior to subpackage postprocess IF(NOT ${SUBPACKAGE_FULLNAME}_TRIBITS_SUBPACKAGE_CALLED) - MESSAGE(FATAL_ERROR "TRIBITS_SUBPACKAGE() must be called before TRIBITS_SUBPACKAGE_POSTPROCESS()" - "for the ${PARENT_PACKAGE_NAME} subpackage ${TRIBITS_SUBPACKAGE}") + TRIBITS_REPORT_INVALID_TRIBITS_USAGE( + "TRIBITS_SUBPACKAGE() must be called before TRIBITS_SUBPACKAGE_POSTPROCESS()" + " for the ${PARENT_PACKAGE_NAME} subpackage ${TRIBITS_SUBPACKAGE}") ENDIF() ENDIF() diff --git a/tribits/doc/build_ref/TribitsBuildReferenceBody.rst b/tribits/doc/build_ref/TribitsBuildReferenceBody.rst index 83f4456aa..a17357e5a 100644 --- a/tribits/doc/build_ref/TribitsBuildReferenceBody.rst +++ b/tribits/doc/build_ref/TribitsBuildReferenceBody.rst @@ -2422,11 +2422,12 @@ To turn off CMake configure-time development-mode checking, set:: -D _ENABLE_DEVELOPMENT_MODE=OFF This turns off a number of CMake configure-time checks for the -TriBITS/CMake files including checking the package dependencies. These checks -can be expensive and may also not be appropriate for a tarball release of the -software. However, this also turns off strong compiler warnings so this is -not recommended by default (see `_DISABLE_STRONG_WARNINGS`_). -For a release of this option is set OFF by default. +TriBITS/CMake files including checking the package dependencies and other +usage of TriBITS. These checks can be expensive and may also not be +appropriate for a tarball release of the software. However, this also turns +off strong compiler warnings so this is not recommended by default (see +`_DISABLE_STRONG_WARNINGS`_). For a release of +this option is set OFF by default. One of the CMake configure-time debug-mode checks performed as part of ``_ENABLE_DEVELOPMENT_MODE=ON`` is to assert the existence of TriBITS @@ -2434,16 +2435,16 @@ package directories. In development mode, the failure to find a package directory is usually a programming error (i.e. a miss-spelled package directory name). But in a tarball release of the project, package directories may be purposefully missing (see `Creating a tarball of the source tree`_) and -must be ignored. When building from a reduced tarball created from the +must be ignored. When building from a reduced source tarball created from the development sources, set:: -D _ASSERT_MISSING_PACKAGES=OFF -Setting this off will cause the TriBITS CMake configure to simply ignore any -missing packages and turn off all dependencies on these missing packages. +Setting this ``OFF`` will cause the TriBITS CMake configure to simply ignore +any missing packages and turn off all dependencies on these missing packages. Another type of checking is for optional inserted/external packages -(e.g. packages who's source can optionally be included in and is flagged with +(e.g. packages who's source can optionally be included and is flagged with ``TRIBITS_ALLOW_MISSING_EXTERNAL_PACKAGES()``). Any of these package directories that are missing result in the packages being silently ignored by default. However, notes on what missing packages are being ignored can @@ -2455,6 +2456,24 @@ These warnings (starting with 'NOTE', not 'WARNING' that would otherwise trigger warnings in CDash) about missing inserted/external packages will print regardless of the setting for ``_ASSERT_MISSING_PACKAGES``. +Finally, ``_ENABLE_DEVELOPMENT_MODE=ON`` results in a number of +checks for invalid usage of TriBITS in the project's ``CMakeList.txt`` files +and will abort configure with a fatal error on the first check failure. This +is appropriate for development mode when a project is clean of all such +invalid usage patterns but there are times when it makes sense to report these +check failures in different ways (such as when upgrading TriBITS in a project +that has some invalid usage patterns that just happen work but may be +disallowed in future versions of TriBITS). To change how these invalid usage +checks are handled, set:: + + -D _ASSERT_CORRECT_TRIBITS_USAGE= + +where ```` can be 'FATAL_ERROR', 'SEND_ERROR', 'WARNING', or +'IGNORE'. + +For ``_ENABLE_DEVELOPMENT_MODE=OFF``, the default for +``_ASSERT_CORRECT_TRIBITS_USAGE`` is actually set to ``IGNORE``. + Building (Makefile generator) ============================= diff --git a/tribits/doc/developers_guide/TribitsDevelopersGuide.rst b/tribits/doc/developers_guide/TribitsDevelopersGuide.rst index 6a4d1e67e..85609b522 100644 --- a/tribits/doc/developers_guide/TribitsDevelopersGuide.rst +++ b/tribits/doc/developers_guide/TribitsDevelopersGuide.rst @@ -8016,6 +8016,7 @@ be documented in `TribitsBuildReference`_. The global project-level TriBITS options for which defaults can be provided by a given TriBITS project are: +* `${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE`_ * `${PROJECT_NAME}_C_Standard`_ * `${PROJECT_NAME}_CHECK_FOR_UNPARSED_ARGUMENTS`_ * `${PROJECT_NAME}_CONFIGURE_OPTIONS_FILE_APPEND`_ @@ -8055,6 +8056,26 @@ a given TriBITS project are: These options are described below. +.. _${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE: + +**${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE** + + The CMake cache variable ``${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE`` is + used to define how some invalid TriBITS usage checks are handled. The valid + values include 'FATAL_ERROR', 'SEND_ERROR', 'WARNING', and 'IGNORE'. The + default value is 'FATAL_ERROR' for a project when + ``${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE=ON``, which is best for + development mode for a project that currently has no invalid usage patterns. + The default is 'IGNORE' when + ``${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE=OFF``. But a project with some + existing invalid usage patterns might want to set, for example, a default of + 'WARNING' in order to allow for a smooth upgrade of TriBITS. To do so, + set:: + + SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE_DEFAULT WARNING) + + in the project's base `/ProjectName.cmake`_ file. + .. _${PROJECT_NAME}_C_Standard: **${PROJECT_NAME}_C_Standard**