From 09d503739bfc566abf60e6d0a566794cf4adb8ca Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Thu, 4 Jan 2018 12:05:13 -0700 Subject: [PATCH] Automatic snapshot commit from tribits at 1ef4e3d Origin repo remote tracking branch: 'github/master' Origin repo remote repo URL: 'github = git@github.com:TriBITSPub/TriBITS.git' At commit: commit c5d3fc9b4620cfd8d2e938ea4d9ca9d974b386f3 Author: Roscoe A. Bartlett Date: Wed Dec 20 16:03:01 2017 -0700 Summary: Merge pull request #246 from dalg24/fix_typo_developers_guide --- .../package_arch/TribitsAddAdvancedTest.cmake | 49 +++++++++------ .../TribitsDevelopersGuide.rst | 61 ++++++++++++++++--- 2 files changed, 86 insertions(+), 24 deletions(-) diff --git a/cmake/tribits/core/package_arch/TribitsAddAdvancedTest.cmake b/cmake/tribits/core/package_arch/TribitsAddAdvancedTest.cmake index 352c2db154a1..fbeb2a2a81df 100644 --- a/cmake/tribits/core/package_arch/TribitsAddAdvancedTest.cmake +++ b/cmake/tribits/core/package_arch/TribitsAddAdvancedTest.cmake @@ -192,7 +192,11 @@ INCLUDE(PrintVar) # The base name of the test (which will have ``${PACKAGE_NAME}_`` # prepended to the name, see below) that will be used to name # the output CMake script file as well as the CTest test name passed into -# ``ADD_TEST()``. This must be the first argument to this function. +# ``ADD_TEST()``. This must be the first argument to this function. The +# name is allowed to contain '/' chars but these will be replaced with +# '__' in the overall working directory name and the ctest -P script +# (`Debugging and Examining Test Generation +# (TRIBITS_ADD_ADVANCED_TEST())`_). # # ``OVERALL_WORKING_DIRECTORY `` # @@ -200,11 +204,11 @@ INCLUDE(PrintVar) # (relative or absolute path) will be created and all of the test commands # by default will be run from within this directory. If the value # ``=TEST_NAME`` is given, then the working directory -# will be given the name ````. By default, if the directory -# ```` exists before the test runs, it will be deleted -# and created again. If one wants to preserve the contents of this -# directory between test runs then set -# ``SKIP_CLEAN_OVERALL_WORKING_DIRECTORY``. Using a separate test +# will be given the name ```` where any '/' chars are replaced +# with '__'. By default, if the directory ```` exists +# before the test runs, it will be deleted and created again. If one +# wants to preserve the contents of this directory between test runs then +# set ``SKIP_CLEAN_OVERALL_WORKING_DIRECTORY``. Using a separate test # directory is a good option to use if the commands create intermediate # files and one wants to make sure they get deleted before the test cases # are run again. It is also important to create a separate test directory @@ -662,8 +666,8 @@ INCLUDE(PrintVar) # # Since raw CTest does not support the features provided by this function, the # way an advanced test is implemented is that a ``cmake -P`` script with the -# name ``.cmake`` gets created in the current binary directory that -# then gets added to CTest using:: +# name ``.cmake`` (with any '/' replaced with '__') gets created in +# the current binary directory that then gets added to CTest using:: # # ADD_TEST( cmake [other options] -P .cmake) # @@ -852,6 +856,23 @@ FUNCTION(TRIBITS_ADD_ADVANCED_TEST TEST_NAME_IN) SET(${PARSE_ADDED_TEST_NAME_OUT} "" PARENT_SCOPE ) ENDIF() + # Set the name of the cmake -P script. + STRING(REPLACE "/" "__" NORMALIZED_TEST_NAME "${TEST_NAME}") + SET(TEST_SCRIPT_FILE_NAME "${NORMALIZED_TEST_NAME}.cmake") + + # Set the relative overall working directory and abs working directory + IF (PARSE_OVERALL_WORKING_DIRECTORY) + IF ("${PARSE_OVERALL_WORKING_DIRECTORY}" STREQUAL "TEST_NAME") + SET(PARSE_OVERALL_WORKING_DIRECTORY ${NORMALIZED_TEST_NAME}) + ENDIF() + # Test will run in created working subdir + SET(ABS_OVERALL_WORKING_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/${PARSE_OVERALL_WORKING_DIRECTORY}) + ELSE() + # Test runs in current binary directory (not a good idea!) + SET(ABS_OVERALL_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + ENDIF() + # # B) Add or don't add tests based on a number of criteria # @@ -1164,11 +1185,11 @@ FUNCTION(TRIBITS_ADD_ADVANCED_TEST TEST_NAME_IN) "${PARSE_DEST_DIR}") ELSE() SET(COPY_FILES_TO_TEST_DIR_DEST_DIR - "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}/${PARSE_DEST_DIR}") + "${ABS_OVERALL_WORKING_DIRECTORY}/${PARSE_DEST_DIR}") ENDIF() ELSE() SET(COPY_FILES_TO_TEST_DIR_DEST_DIR - "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}") + "${ABS_OVERALL_WORKING_DIRECTORY}") ENDIF() ELSE() @@ -1335,7 +1356,7 @@ FUNCTION(TRIBITS_ADD_ADVANCED_TEST TEST_NAME_IN) # F.1) Call ADD_TEST() and set the test properties # - SET(TEST_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.cmake") + SET(TEST_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SCRIPT_FILE_NAME}") IF(NOT TRIBITS_ADD_TEST_ADD_TEST_UNITTEST) # Tell CTest to run our script for this test. Pass the test-type @@ -1394,12 +1415,6 @@ FUNCTION(TRIBITS_ADD_ADVANCED_TEST TEST_NAME_IN) # # F.2) Write the cmake -P script # - - IF (PARSE_OVERALL_WORKING_DIRECTORY) - IF ("${PARSE_OVERALL_WORKING_DIRECTORY}" STREQUAL "TEST_NAME") - SET(PARSE_OVERALL_WORKING_DIRECTORY ${TEST_NAME}) - ENDIF() - ENDIF() APPEND_STRING_VAR( TEST_SCRIPT_STR "\n" diff --git a/cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst b/cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst index fc2df766edad..c0f2c7fd75e9 100644 --- a/cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst +++ b/cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst @@ -674,6 +674,7 @@ ${PROJECT_SOURCE_DIR}``) are:: cmake/ NativeRepositoriesList.cmake # [Optional] Rarely used ExtraRepositoriesList.cmake # [Optional] Lists repos and VC URLs + ProjectCompilerPostConfig.cmake # [Optional] Override/tweak build flags ProjectDependenciesSetup.cmake # [Optional] Project deps overrides CallbackDefineProjectPackaging.cmake # [Optional] CPack settings tribits/ # [Optional] Or provide ${PROJECT_NAME}_TRIBITS_DIR @@ -689,6 +690,7 @@ These TriBITS Project files are documented in more detail below: * `/project-checkin-test-config.py`_ * `/cmake/NativeRepositoriesList.cmake`_ * `/cmake/ExtraRepositoriesList.cmake`_ +* `/cmake/ProjectCompilerPostConfig.cmake`_ * `/cmake/ProjectDependenciesSetup.cmake`_ * `/cmake/CallbackDefineProjectPackaging.cmake`_ * `/cmake/tribits/`_ @@ -924,6 +926,47 @@ NOTE: This file can be overridden by setting the cache variable .. behavior here. +.. _/cmake/ProjectCompilerPostConfig.cmake: + +**/cmake/ProjectCompilerPostConfig.cmake**: [Optional] If present, +then this file is read using ``INCLUDE()`` at the top-level CMakeLists.txt +file scope right after the compilers for the languages ```` = ``C``, +``CXX``, and ``Fortran`` are determined and checked using +``ENABLE_LANGUAGE()`` but before any other checks are performed. This +file can contain logic for the project to adjust the flags set in +``CMAKE__FLAGS`` and changes to other aspects of the build flags +(including link flags, etc.). + +One example of the usage of this file is the Trilinos project where this file +is (or was) used to apply specialized logic implemented in the Kokkos build +system to select compiler options and to determine how C++11 and OpenMP flags +are set. This file in Trilinos looked like:: + + IF (${Trilinos_ENABLE_Kokkos}) + + ... + + include(${Kokkos_GEN_DIR}/kokkos_generated_settings.cmake) + + IF (NOT KOKKOS_ARCH STREQUAL "None") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KOKKOS_CXX_FLAGS}") + + MESSAGE("-- " "Skip adding flags for C++11 because Kokkos flags does that ...") + SET(${PROJECT_NAME}_CXX11_FLAGS " ") + + MESSAGE("-- " "Skip adding flags for OpenMP because Kokkos flags does that ...") + SET(OpenMP_CXX_FLAGS_OVERRIDE " ") + + ENDIF() + + ENDIF() + +The exact context where this file is processed (if it exists) is described in +`Full Processing of TriBITS Project Files`_ and `TriBITS Environment Probing +and Setup`_. + + .. _/cmake/ProjectDependenciesSetup.cmake: **/cmake/ProjectDependenciesSetup.cmake**: [Optional] If present, @@ -2258,7 +2301,7 @@ proceeds through the call to `TRIBITS_PROJECT()`_. | 3. Call `TRIBITS_PROJECT()`_: | 1) Set `PROJECT_SOURCE_DIR`_ and `PROJECT_BINARY_DIR`_ | 2) For each ```` in ${`${PROJECT_NAME}_CONFIGURE_OPTIONS_FILE`_} -| ${`${PROJECT_NAME}_CONFIGURE_OPTIONS_FILE_APPEND`_} +| then in ${`${PROJECT_NAME}_CONFIGURE_OPTIONS_FILE_APPEND`_} : | * ``INCLUDE()`` | 3) Set variables ``CMAKE_HOST_SYSTEM_NAME`` and ``${PROJECT_NAME}_HOSTNAME`` @@ -2288,6 +2331,7 @@ proceeds through the call to `TRIBITS_PROJECT()`_. | (see `Package Dependencies and Enable/Disable Logic`_) | 11) `Probe and set up the environment`_ (finds MPI, compilers, etc.) | (see `TriBITS Environment Probing and Setup`_) +| * ``INCLUDE(`` `/cmake/ProjectCompilerPostConfig.cmake`_ ``)`` | 12) For each ```` in the set of enabled TPLs: | * ``INCLUDE(${_FINDMOD})`` (see `TriBITS TPL`_) | 13) For each ```` in all defined TriBITS repositories: @@ -4210,7 +4254,7 @@ More detailed descriptions of the test groups are given below. .. _ST: -* **Secondary Tested (PT)** Code is still very important code for the project +* **Secondary Tested (ST)** Code is still very important code for the project and represents important capability to maintain but is excluded from the ``PT`` set of code for one of a few different reasons. First, code may be marked as ``ST`` if is not critical to drive most day-to-day development @@ -6247,18 +6291,21 @@ Processing of TriBITS Project Files`_. This is executed by the TriBITS macro **Probe and set up the environment:** -* Set ``CMAKE_BUILD_TYPE`` +* Set ``CMAKE_BUILD_TYPE`` default (if not already set) * Set up for MPI (MPI compilers, etc.) -* Set up C, C++, and Fortran compilers +* Set up C, C++, and Fortran compilers using ``ENABLE_LANGUAGE()`` +* ``INCLUDE(`` `/cmake/ProjectCompilerPostConfig.cmake`_ ``)`` * Find Perl (sets ``PERL_EXECUTABLE``) * Determine mixed language C/Fortran linking -* Set up C++11, OpenMP, and Windows support +* Set up C++11 (`${PROJECT_NAME}_ENABLE_CXX11`_) +* Set up OpenMP (with ``FIND_PACKAGE(OpenMP)``) +* Set up optional Windows support * Find Doxygen (sets ``DOXYGEN_EXECUTABLE``) -* Perform some other configure-time tests (see ``cmake`` output) +* Perform some other configure-time tests (see ``cmake`` configure output) At the completion of this part of the processing, the TriBITS CMake project is ready to compile code. All of the major variables set as part of this process -are printed to the ``cmake`` stdout. +are printed to the ``cmake`` stdout when the project is configured. RPATH Handling