diff --git a/test/core/ExamplesUnitTests/CMakeLists.txt b/test/core/ExamplesUnitTests/CMakeLists.txt index d68985ea8..52490f60a 100644 --- a/test/core/ExamplesUnitTests/CMakeLists.txt +++ b/test/core/ExamplesUnitTests/CMakeLists.txt @@ -2675,6 +2675,54 @@ IF (TribitsExampleProject_SimpleTpl_RPATH_CMAKE_SKIP_INSTALL_RPATH_run_NAMES ENDIF() +# +# Test cmake/ProjectCompilerPostConfig.cmake +# + +TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_ProjectCompilerPostConfig + OVERALL_WORKING_DIRECTORY TEST_NAME + OVERALL_NUM_MPI_PROCS 1 + XHOSTTYPE Darwin + + TEST_0 + MESSAGE "Copy TribitsExampleProject so that we can copy in cmake/ProjectCompilerPostConfig.cmake." + CMND cp + ARGS -r ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject . + + TEST_1 + MESSAGE "Copy in dummy cmake/ProjectCompilerPostConfig.cmake." + CMND cp + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/DummyProjectCompilerPostConfig.cmake + TribitsExampleProject/cmake/ProjectCompilerPostConfig.cmake + + TEST_2 + MESSAGE "Configure SimpleCxx and trace includes" + CMND ${CMAKE_COMMAND} + ARGS + ${TribitsExampleProject_COMMON_CONFIG_ARGS} + -DTribitsExProj_TRIBITS_DIR=${${PROJECT_NAME}_TRIBITS_DIR} + -DTribitsExProj_ENABLE_Fortran=OFF + -DTribitsExProj_ENABLE_DEBUG=OFF + -DTribitsExProj_TRACE_FILE_PROCESSING=ON + -DTribitsExProj_ENABLE_SimpleCxx=ON + TribitsExampleProject + PASS_REGULAR_EXPRESSION_ALL + "-- File Trace: PROJECT INCLUDE .*/cmake/ProjectCompilerPostConfig[.]cmake" + "Configuring done" + "Generating done" + ALWAYS_FAIL_ON_NONZERO_RETURN + + TEST_3 + MESSAGE "VERBOSE Build the simplecxx lib and verify that the new compiler flags is added " + CMND make + ARGS VERBOSE=1 simplecxx + PASS_REGULAR_EXPRESSION_ALL + "DDUMMY_DEFINE_JUST_TO_TSET_COMILER_POST_CONFIG" + ALWAYS_FAIL_ON_NONZERO_RETURN + + ) + + ######################################################################## # TribitsExampleProject + TribitsExampleProjectAddons ######################################################################## diff --git a/test/core/ExamplesUnitTests/DummyProjectCompilerPostConfig.cmake b/test/core/ExamplesUnitTests/DummyProjectCompilerPostConfig.cmake new file mode 100644 index 000000000..d37d1763f --- /dev/null +++ b/test/core/ExamplesUnitTests/DummyProjectCompilerPostConfig.cmake @@ -0,0 +1 @@ +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDUMMY_DEFINE_JUST_TO_TSET_COMILER_POST_CONFIG") \ No newline at end of file diff --git a/tribits/core/package_arch/TribitsGlobalMacros.cmake b/tribits/core/package_arch/TribitsGlobalMacros.cmake index ff7b47cac..63868dd0c 100644 --- a/tribits/core/package_arch/TribitsGlobalMacros.cmake +++ b/tribits/core/package_arch/TribitsGlobalMacros.cmake @@ -1808,6 +1808,18 @@ MACRO(TRIBITS_SETUP_ENV) ENABLE_LANGUAGE(Fortran) ENDIF() + # Do some project-specific tweaks for compiler options, etc. + SET(PROJECT_COMPILER_CONFIG_FILE + # Can be used for things like Kokkos. + "${${PROJECT_NAME}_SOURCE_DIR}/cmake/ProjectCompilerPostConfig.cmake" + CACHE FILEPATH + "Allow for project-specific compiler settings." + ) + IF (EXISTS "${PROJECT_COMPILER_CONFIG_FILE}") + TRIBITS_TRACE_FILE_PROCESSING(PROJECT INCLUDE "${PROJECT_COMPILER_CONFIG_FILE}") + INCLUDE("${PROJECT_COMPILER_CONFIG_FILE}") + ENDIF() + # Set up for strong compiler warnings and warnings as errors INCLUDE(TribitsSetupBasicCompileLinkFlags)