Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tribits 2018 01 04 #2126

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions cmake/tribits/core/package_arch/TribitsAddAdvancedTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,23 @@ INCLUDE(PrintVar)
# The base name of the test (which will have ``${PACKAGE_NAME}_``
# prepended to the name, see <testName> 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 <overallWorkingDir>``
#
# If specified, then the working directory ``<overallWorkingDir>``
# (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
# ``<overallWorkingDir>=TEST_NAME`` is given, then the working directory
# will be given the name ``<testName>``. By default, if the directory
# ``<overallWorkingDir>`` 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 ``<testName>`` where any '/' chars are replaced
# with '__'. By default, if the directory ``<overallWorkingDir>`` 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
Expand Down Expand Up @@ -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 ``<testName>.cmake`` gets created in the current binary directory that
# then gets added to CTest using::
# name ``<testName>.cmake`` (with any '/' replaced with '__') gets created in
# the current binary directory that then gets added to CTest using::
#
# ADD_TEST(<testName> cmake [other options] -P <testName>.cmake)
#
Expand Down Expand Up @@ -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
#
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
61 changes: 54 additions & 7 deletions cmake/tribits/doc/developers_guide/TribitsDevelopersGuide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -689,6 +690,7 @@ These TriBITS Project files are documented in more detail below:
* `<projectDir>/project-checkin-test-config.py`_
* `<projectDir>/cmake/NativeRepositoriesList.cmake`_
* `<projectDir>/cmake/ExtraRepositoriesList.cmake`_
* `<projectDir>/cmake/ProjectCompilerPostConfig.cmake`_
* `<projectDir>/cmake/ProjectDependenciesSetup.cmake`_
* `<projectDir>/cmake/CallbackDefineProjectPackaging.cmake`_
* `<projectDir>/cmake/tribits/`_
Expand Down Expand Up @@ -924,6 +926,47 @@ NOTE: This file can be overridden by setting the cache variable
.. behavior here.


.. _<projectDir>/cmake/ProjectCompilerPostConfig.cmake:

**<projectDir>/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 ``<LANG>`` = ``C``,
``CXX``, and ``Fortran`` are determined and checked using
``ENABLE_LANGUAGE(<LANG>)`` but before any other checks are performed. This
file can contain logic for the project to adjust the flags set in
``CMAKE_<LANG>_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`_.


.. _<projectDir>/cmake/ProjectDependenciesSetup.cmake:

**<projectDir>/cmake/ProjectDependenciesSetup.cmake**: [Optional] If present,
Expand Down Expand Up @@ -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 ``<optFile>`` in ${`${PROJECT_NAME}_CONFIGURE_OPTIONS_FILE`_}
| ${`${PROJECT_NAME}_CONFIGURE_OPTIONS_FILE_APPEND`_}
| then in ${`${PROJECT_NAME}_CONFIGURE_OPTIONS_FILE_APPEND`_}
:
| * ``INCLUDE(<optFile>)``
| 3) Set variables ``CMAKE_HOST_SYSTEM_NAME`` and ``${PROJECT_NAME}_HOSTNAME``
Expand Down Expand Up @@ -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(`` `<projectDir>/cmake/ProjectCompilerPostConfig.cmake`_ ``)``
| 12) For each ``<tplName>`` in the set of enabled TPLs:
| * ``INCLUDE(${<tplName>_FINDMOD})`` (see `TriBITS TPL`_)
| 13) For each ``<repoDir>`` in all defined TriBITS repositories:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(<LANG>)``
* ``INCLUDE(`` `<projectDir>/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
Expand Down