diff --git a/.travis.yml b/.travis.yml
index b584fcb59..20f8d2789 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -112,8 +112,8 @@ addons:
- gcc-4.9
- g++-4.9
- gfortran-4.9
- - mpich2
- - libmpich2-dev
+ - mpich
+ - libmpich-dev
before_install:
# workaround apt related for error:
# Err:6 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty InRelease
@@ -160,6 +160,7 @@ script:
# c & c++ compilers
- CMAKE_OPTS="${CMAKE_OPTS} -DCMAKE_C_COMPILER=${BLT_CC}"
- CMAKE_OPTS="${CMAKE_OPTS} -DCMAKE_CXX_COMPILER=${BLT_CXX}"
+ - CMAKE_OPTS="${CMAKE_OPTS} -DBLT_CXX_STD:STRING=c++11"
# gtest support
- CMAKE_OPTS="${CMAKE_OPTS} -DENABLE_GTEST=${BLT_GTEST}"
# gmock support
diff --git a/COPYRIGHT b/COPYRIGHT
deleted file mode 100644
index 530b018dc..000000000
--- a/COPYRIGHT
+++ /dev/null
@@ -1,44 +0,0 @@
-Intellectual Property Notice
-------------------------------
-
-BLT is licensed under the BSD 3-Clause license,
-(BSD-3-Clause or https://opensource.org/licenses/BSD-3-Clause).
-
-Copyrights and patents in the BLT project are retained by contributors.
-No copyright assignment is required to contribute to BLT.
-
-
-SPDX usage
-------------
-
-Individual files contain SPDX tags instead of the full license text.
-This enables machine processing of license information based on the SPDX
-License Identifiers that are available here: https://spdx.org/licenses/
-
-Files that are licensed as BSD 3-Clause contain the following
-text in the license header:
-
- SPDX-License-Identifier: (BSD-3-Clause)
-
-
-External Packages
--------------------
-BLT bundles its external dependencies in thirdparty_builtin/. These
-packages are covered by various permissive licenses. A summary listing
-follows. See the license included with each package for full details.
-
-PackageName: fruit
-PackageHomePage: https://sourceforge.net/projects/fortranxunit/
-PackageLicenseDeclared: BSD-3-Clause
-
-PackageName: gbenchmark
-PackageHomePage: https://github.com/google/benchmark
-PackageLicenseDeclared: Apache-2.0
-
-PackageName: gmock
-PackageHomePage: https://github.com/google/googlemock
-PackageLicenseDeclared: BSD-3-Clause
-
-PackageName: gtest
-PackageHomePage: https://github.com/google/googletest
-PackageLicenseDeclared: BSD-3-Clause
diff --git a/LICENSE b/LICENSE
index 9c5ca2178..a7d513ff3 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,69 +1,27 @@
Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC.
-
-Produced at the Lawrence Livermore National Laboratory
-
-Developers include:
-
-Chris White (white238@llnl.gov)
-Cyrus Harrison (harrison37@llnl.gov)
-George Zagaris (zagaris2@llnl.gov)
-Kenneth Weiss (kweiss@llnl.gov)
-Lee Taylor (taylor16@llnl.gov)
-Aaron Black (black27@llnl.gov)
-David A. Beckingsale (beckingsale1@llnl.gov)
-Richard Hornung (hornung1@llnl.gov)
-Randolph Settgast (settgast1@llnl.gov)
-Peter Robinson (robinson96@llnl.gov)
-
-LLNL-CODE-725085.
-
All rights reserved.
-This file is part of BLT. For details, see https://github.com/LLNL/blt.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
-• Redistributions of source code must retain the above copyright notice, this
- list of conditions and the disclaimer below.
-
-• Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the disclaimer (as noted below) in the
- documentation and/or other materials provided with the distribution.
-
-• Neither the name of the LLNS/LLNL nor the names of its contributors may
- be used to endorse or promote products derived from this software without
- specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE
-U.S. DEPARTMENT OF ENERGY OR 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.
-
-Additional BSD Notice
-
-1. This notice is required to be provided under our contract with the U.S.
-Department of Energy (DOE). This work was produced at Lawrence Livermore
-National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE.
-
-2. Neither the United States Government nor Lawrence Livermore National
-Security, LLC nor any of their employees, makes any warranty, express or
-implied, or assumes any liability or responsibility for the accuracy,
-completeness, or usefulness of any information, apparatus, product, or process
-disclosed, or represents that its use would not infringe privately-owned rights.
-
-3. Also, reference herein to any specific commercial products, process, or
-services by trade name, trademark, manufacturer or otherwise does not
-necessarily constitute or imply its endorsement, recommendation, or favoring by
-the United States Government or Lawrence Livermore National Security, LLC. The
-views and opinions of authors expressed herein do not necessarily state or
-reflect those of the United States Government or Lawrence Livermore National
-Security, LLC, and shall not be used for advertising or product endorsement
-purposes.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* 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.
+
+* Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER OR 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.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 000000000..d64ac16ab
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,20 @@
+Additional BSD Notice
+
+1. This notice is required to be provided under our contract with the U.S.
+Department of Energy (DOE). This work was produced at Lawrence Livermore
+National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE.
+
+2. Neither the United States Government nor Lawrence Livermore National
+Security, LLC nor any of their employees, makes any warranty, express or
+implied, or assumes any liability or responsibility for the accuracy,
+completeness, or usefulness of any information, apparatus, product, or process
+disclosed, or represents that its use would not infringe privately-owned rights.
+
+3. Also, reference herein to any specific commercial products, process, or
+services by trade name, trademark, manufacturer or otherwise does not
+necessarily constitute or imply its endorsement, recommendation, or favoring by
+the United States Government or Lawrence Livermore National Security, LLC. The
+views and opinions of authors expressed herein do not necessarily state or
+reflect those of the United States Government or Lawrence Livermore National
+Security, LLC, and shall not be used for advertising or product endorsement
+purposes.
diff --git a/README.md b/README.md
index f42c742b3..a329910c3 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-# v0.2
+#
[![Build Status](https://travis-ci.org/LLNL/blt.svg)](https://travis-ci.org/LLNL/blt)
[![Build Status](https://ci.appveyor.com/api/projects/status/fuaftu9mvp0y488j/branch/master?svg=true)](https://ci.appveyor.com/project/cyrush/blt/branch/master)
-[![Documentation Status](https://readthedocs.org/projects/llnl-blt/badge/?version=latest)](https://llnl-blt.readthedocs.io/en/latest/?badge=latest)
+[![Documentation Status](https://readthedocs.org/projects/llnl-blt/badge/?version=develop)](https://llnl-blt.readthedocs.io/en/develop/?badge=develop)
BLT is a streamlined [CMake](https://cmake.org)-based foundation for
Building, Linking and Testing large-scale high performance computing (HPC) applications.
@@ -71,8 +71,8 @@ Developers include:
Please see the [BLT Contributors Page](https://github.com/LLNL/BLT/graphs/contributors) for the full list of project contributors.
-Projects using this library
----------------------------
+Open-Source Projects using BLT
+------------------------------
* [Ascent](https://github.com/Alpine-DAV/ascent): A flyweight in-situ visualization and analysis runtime for multi-physics HPC simulations
* [Axom](https://github.com/LLNL/axom): Software infrastructure for the development of multi-physics applications and computational tools
@@ -85,19 +85,50 @@ Projects using this library
If you would like to add a library to this list, please let us know via [email](mailto:blt-dev@llnl.gov)
or by submitting an [issue](https://github.com/LLNL/blt/issues) or [pull-request](https://github.com/LLNL/blt/pulls).
-Release
+License
-------
-Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC.
+BLT is licensed under the BSD 3-Clause license,
+(BSD-3-Clause or https://opensource.org/licenses/BSD-3-Clause).
-Produced at the Lawrence Livermore National Laboratory.
-
-All rights reserved.
+Copyrights and patents in the BLT project are retained by contributors.
+No copyright assignment is required to contribute to BLT.
+See [LICENSE](./LICENSE) for details.
+
Unlimited Open Source - BSD 3-clause Distribution
`LLNL-CODE-725085` `OCEC-17-023`
-Additional license and copyright information can be found in the following files:
- * [LICENSE](./LICENSE)
- * [COPYRIGHT](./COPYRIGHT)
-
+SPDX usage
+------------
+
+Individual files contain SPDX tags instead of the full license text.
+This enables machine processing of license information based on the SPDX
+License Identifiers that are available here: https://spdx.org/licenses/
+
+Files that are licensed as BSD 3-Clause contain the following
+text in the license header:
+
+ SPDX-License-Identifier: (BSD-3-Clause)
+
+External Packages
+-------------------
+BLT bundles its external dependencies in thirdparty_builtin/. These
+packages are covered by various permissive licenses. A summary listing
+follows. See the license included with each package for full details.
+
+PackageName: fruit
+PackageHomePage: https://sourceforge.net/projects/fortranxunit/
+PackageLicenseDeclared: BSD-3-Clause
+
+PackageName: gbenchmark
+PackageHomePage: https://github.com/google/benchmark
+PackageLicenseDeclared: Apache-2.0
+
+PackageName: gmock
+PackageHomePage: https://github.com/google/googlemock
+PackageLicenseDeclared: BSD-3-Clause
+
+PackageName: gtest
+PackageHomePage: https://github.com/google/googletest
+PackageLicenseDeclared: BSD-3-Clause
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 830a0b1fc..3dd782792 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -7,10 +7,40 @@ The format of this file is based on [Keep a Changelog](http://keepachangelog.com
The project release numbers follow [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [Unreleased] - Release date yyyy-mm-dd
+
+## [Version 0.3.0] - Release date 2020-01-08
+
+### Added
+- Sets CMake policy CMP0074 to NEW, when available.
+- Added simpler Clang+XLF+Cuda host-config for LLNL's blueos
+- API Docs that are public!
+- Added the ability to override blt's custom target names, e.g. for code checks,
+ formatting and generating documentation. The new variables are: ``BLT_CODE_CHECK_TARGET_NAME``,
+ ``BLT_CODE_STYLE_TARGET_NAME``, ``BLT_DOCS_TARGET_NAME`` and ``BLT_RUN_BENCHMARKS_TARGET_NAME``.
+- Clean up linking flags when ``CUDA_LINK_WITH_NVCC`` is ON. Added logic to automatically convert
+ '-Wl,-rpath' linking flag to '-Xlinker -rpath -Xlinker' and removes ``-pthread`` from from
+ MPI linking flags returned from FindMPI because it doesn't work
+ (see https://gitlab.kitware.com/cmake/cmake/issues/18008).
+- In CMake 3.13+, "SHELL:" was added to blt_add_target_link_flags. This stops CMake from de-duplicating
+ needed linker flags.
+- Added optional SCOPE to all target property macros, blt_add_target_link_flags, etc. It defaults to PUBLIC.
+- Added support for Cray compilers in blt_append_custom_compiler_flag.
+- Added ability to add flags to the cppcheck command line through blt_add_code_checks()
+- Added ability for blt_add_test() to set required number of OpenMP threads via new option NUM_OMP_THREADS.
+
+### Changed
+- Restructured the host-config directory by site and platform.
+- Updated gbenchmark to 1.5.0, note that this requires C++11 to build.
+- Updated gtest and gmock to Master as of 2020-01-07, note that this requires C++11 to build.
+
+### Fixed
+- Fixed some warnings in CMake 3.14+
+
## [Version 0.2.5] - Release date 2019-06-13
### Added
-- Added support for C++17. Note: Neither XL or CMake's CUDA_STANDARD does not support
+- Added support for C++17. Note: Neither XL nor CMake's CUDA_STANDARD supports
C++17 (A BLT fatal error will occur).
- Added ability to override all MPI variables: BLT_MPI_COMPILE_FLAGS,
BLT_MPI_INCLUDES, BLT_MPI_LIBRARIES, and BLT_MPI_LINK_FLAGS
@@ -70,5 +100,8 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/
### Known Bugs
+
+[Unreleased]: https://github.com/LLNL/blt/compare/v0.3.0...develop
+[Version 0.3.0]: https://github.com/LLNL/blt/compare/v0.2.5...v0.3.0
[Version 0.2.5]: https://github.com/LLNL/blt/compare/v0.2.0...v0.2.5
[Version 0.2.0]: https://github.com/LLNL/blt/compare/v0.1.0...v0.2.0
diff --git a/SetupBLT.cmake b/SetupBLT.cmake
index f2487f4bb..c0b88f0ff 100644
--- a/SetupBLT.cmake
+++ b/SetupBLT.cmake
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: (BSD-3-Clause)
if (NOT BLT_LOADED)
- set(BLT_VERSION "0.2.5" CACHE STRING "")
+ set(BLT_VERSION "0.3.0" CACHE STRING "")
mark_as_advanced(BLT_VERSION)
message(STATUS "BLT Version: ${BLT_VERSION}")
@@ -59,6 +59,12 @@ if (NOT BLT_LOADED)
cmake_policy(SET CMP0057 NEW)
endif()
+ # Policy to use _ROOT variable in find_ commands
+ # Policy added in 3.12+
+ if(POLICY CMP0074)
+ cmake_policy(SET CMP0074 NEW)
+ endif()
+
# New turns relative target_sources() paths to absolute
# Policy added in 3.13+
# NOTE: this will be deprecated eventually but NEW causes
@@ -167,9 +173,9 @@ if (NOT BLT_LOADED)
#
################################
set(BLT_C_FILE_EXTS ".cpp" ".hpp" ".cxx" ".hxx" ".c" ".h" ".cc" ".hh" ".inl" ".cu"
- CACHE LIST "List of known file extensions used for C/CXX sources")
+ CACHE STRING "List of known file extensions used for C/CXX sources")
set(BLT_Fortran_FILE_EXTS ".F" ".f" ".f90" ".F90"
- CACHE LIST "List of known file extensions used for Fortran sources")
+ CACHE STRING "List of known file extensions used for Fortran sources")
################################
diff --git a/appveyor.yml b/appveyor.yml
index 1f070bbfe..035f49af6 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -77,6 +77,7 @@ build_script:
-D ENABLE_GMOCK=%ENABLE_GMOCK% ^
-D ENABLE_BENCHMARKS=%ENABLE_BENCHMARKS% ^
-D ENABLE_OPENMP=ON ^
+ -D BLT_CXX_STD:STRING=c++11 ^
-D ENABLE_MPI=%ENABLE_MPI% ^
-D MPI_C_INCLUDE_PATH:PATH="%MPI_HOME%/Include" ^
-D MPI_C_LIBRARIES:PATH="%MPI_HOME%/Lib/x86/msmpi.lib" ^
diff --git a/cmake/BLTGitMacros.cmake b/cmake/BLTGitMacros.cmake
index 9812e6bcc..d6024f6f6 100644
--- a/cmake/BLTGitMacros.cmake
+++ b/cmake/BLTGitMacros.cmake
@@ -11,36 +11,6 @@
## [QUIET] )
##
## Runs the supplied git command on the given Git repository.
-##
-## This macro runs the user-supplied Git command, given by GIT_COMMAND, on the
-## given Git repository corresponding to SOURCE_DIR. The supplied GIT_COMMAND
-## is just a string consisting of the Git command and its arguments. The
-## resulting output is returned to the supplied CMake variable provided by
-## the OUTPUT_VARIABLE argument.
-##
-## A return code for the Git command is returned to the caller via the CMake
-## variable provided with the RETURN_CODE argument. A non-zero return code
-## indicates that an error has occured.
-##
-## Note, this macro assumes FindGit() was invoked and was successful. It relies
-## on the following variables set by FindGit():
-## - Git_FOUND flag that indicates if git is found
-## - GIT_EXECUTABLE points to the Git binary
-##
-## If Git_FOUND is "false" this macro will throw a FATAL_ERROR message.
-##
-## Usage Example:
-##
-## blt_git( SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
-## GIT_COMMAND describe --tags master
-## OUTPUT_VARIABLE axom_tag
-## RETURN_CODE rc
-## )
-##
-## if (NOT ${rc} EQUAL 0)
-## message( FATAL_ERROR "blt_git failed!" )
-## endif()
-##
##------------------------------------------------------------------------------
macro(blt_git)
@@ -95,30 +65,12 @@ macro(blt_git)
endmacro(blt_git)
+
##------------------------------------------------------------------------------
## blt_is_git_repo( OUTPUT_STATE
-## [SOURCE_DIR ]
-## )
+## [SOURCE_DIR ] )
##
## Checks if we are working with a valid Git repository.
-##
-## This macro checks if the corresponding source directory is a valid Git repo.
-## Nominally, the corresponding source directory that is used is set to
-## ${CMAKE_CURRENT_SOURCE_DIR}. A different source directory may be optionally
-## specified using the SOURCE_DIR argument.
-##
-## The resulting state is stored in the CMake variable specified by the caller
-## using the OUTPUT_STATE parameter.
-##
-## Usage Example:
-##
-## blt_is_git_repo( OUTTPUT_STATE is_git_repo )
-## if ( ${is_git_repo} )
-## message(STATUS "Pointing to a valid Git repo!")
-## else()
-## message(STATUS "Not a Git repo!")
-## endif()
-##
##------------------------------------------------------------------------------
macro(blt_is_git_repo)
@@ -161,33 +113,9 @@ endmacro(blt_is_git_repo)
## blt_git_tag( OUTPUT_TAG
## RETURN_CODE
## [SOURCE_DIR ]
-## [ON_BRANCH ]
-## )
+## [ON_BRANCH ] )
##
## Returns the latest tag on a corresponding Git repository.
-##
-## This macro gets the latest tag from a Git repository that can be specified
-## via the SOURCE_DIR argument. If SOURCE_DIR is not supplied, the macro will
-## use ${CMAKE_CURRENT_SOURCE_DIR}. By default the macro will return the latest
-## tag on the branch that is currently checked out. A particular branch may be
-## specified using the ON_BRANCH option.
-##
-## The tag is stored in the CMake variable specified by the caller using the
-## the OUTPUT_TAG parameter.
-##
-## A return code for the Git command is returned to the caller via the CMake
-## variable provided with the RETURN_CODE argument. A non-zero return code
-## indicates that an error has occured.
-##
-## Usage Example:
-##
-## blt_git_tag( OUTPUT_TAG tag RETURN_CODE rc ON_BRANCH master )
-##
-## if ( NOT ${rc} EQUAL 0 )
-## message( FATAL_ERROR "blt_git_tag failed!" )
-## endif()
-##
-## message( STATUS "tag=${tag}" )
##------------------------------------------------------------------------------
macro(blt_git_tag)
@@ -233,29 +161,9 @@ endmacro(blt_git_tag)
##------------------------------------------------------------------------------
## blt_git_branch( BRANCH_NAME
## RETURN_CODE
-## [SOURCE_DIR ]
-## )
+## [SOURCE_DIR ] )
##
## Returns the name of the active branch in the checkout space.
-##
-## This macro gets the name of the current active branch in the checkout space
-## that can be specified using the SOURCE_DIR argument. If SOURCE_DIR is not
-## supplied by the caller, this macro will point to the checkout space
-## corresponding to ${CMAKE_CURRENT_SOURCE_DIR}.
-##
-## A return code for the Git command is returned to the caller via the CMake
-## variable provided with the RETURN_CODE argument. A non-zero return code
-## indicates that an error has occured.
-##
-## Usage Example:
-##
-## blt_git_branch( BRANCH_NAME active_branch RETURN_CODE rc )
-##
-## if ( NOT ${rc} EQUAL 0 )
-## message( FATAL_ERROR "blt_git_tag failed!" )
-## endif()
-##
-## message( STATUS "active_branch=${active_branch}" )
##------------------------------------------------------------------------------
macro(blt_git_branch)
@@ -299,26 +207,6 @@ endmacro(blt_git_branch)
## )
##
## Returns the SHA-1 hashcode at the tip of a branch.
-##
-## This macro returns the SHA-1 hashcode at the tip of a branch that may be
-## specified with the ON_BRANCH argument. If the ON_BRANCH argument is not
-## supplied, the macro will return the SHA-1 hash at the tip of the current
-## branch. In addition, the caller may specify the target Git repository using
-## the SOURCE_DIR argument. Otherwise, if SOURCE_DIR is not specified, the
-## macro will use ${CMAKE_CURRENT_SOURCE_DIR}.
-##
-## A return code for the Git command is returned to the caller via the CMake
-## variable provided with the RETURN_CODE argument. A non-zero return code
-## indicates that an error has occured.
-##
-## Usage Example:
-##
-## blt_git_hashcode( HASHCODE sha1 RETURN_CODE rc )
-## if ( NOT ${rc} EQUAL 0 )
-## message( FATAL_ERROR "blt_git_hashcode failed!" )
-## endif()
-##
-## message( STATUS "sha1=${sha1}" )
##------------------------------------------------------------------------------
macro(blt_git_hashcode)
diff --git a/cmake/BLTMacros.cmake b/cmake/BLTMacros.cmake
index bdae54fd3..b040162ac 100644
--- a/cmake/BLTMacros.cmake
+++ b/cmake/BLTMacros.cmake
@@ -9,24 +9,6 @@ include(${BLT_ROOT_DIR}/cmake/BLTPrivateMacros.cmake)
## blt_list_append( TO ELEMENTS [ ...] IF )
##
## Appends elements to a list if the specified bool evaluates to true.
-##
-## This macro is essentially a wrapper around CMake's `list(APPEND ...)`
-## command which allows inlining a conditional check within the same call
-## for clarity and convenience.
-##
-## This macro requires specifying:
-## (1) The target list to append to by passing TO
-## (2) A condition to check by passing IF
-## (3) The list of elements to append by passing ELEMENTS [...]
-##
-## Note, the argument passed to the IF option has to be a single boolean value
-## and cannot be a boolean expression since CMake cannot evaluate those inline.
-##
-## Usage Example:
-##
-## set(mylist A B)
-## blt_list_append( TO mylist ELEMENTS C IF ${ENABLE_C} )
-##
##------------------------------------------------------------------------------
macro(blt_list_append)
@@ -38,7 +20,7 @@ macro(blt_list_append)
cmake_parse_arguments(arg
"${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN} )
- # sanity checks
+ # Sanity checks
if( NOT DEFINED arg_TO )
message(FATAL_ERROR "blt_list_append() requires a TO argument")
endif()
@@ -71,15 +53,6 @@ endmacro(blt_list_append)
## blt_list_remove_duplicates( TO )
##
## Removes duplicate elements from the given TO list.
-##
-## This macro is essentially a wrapper around CMake's `list(REMOVE_DUPLICATES ...)`
-## command but doesn't throw an error if the list is empty or not defined.
-##
-## Usage Example:
-##
-## set(mylist A B A)
-## blt_list_remove_duplicates( TO mylist )
-##
##------------------------------------------------------------------------------
macro(blt_list_remove_duplicates)
@@ -91,7 +64,7 @@ macro(blt_list_remove_duplicates)
cmake_parse_arguments(arg
"${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN} )
- # sanity checks
+ # Sanity checks
if( NOT DEFINED arg_TO )
message(FATAL_ERROR "blt_list_append() requires a TO argument")
endif()
@@ -104,115 +77,82 @@ endmacro(blt_list_remove_duplicates)
##------------------------------------------------------------------------------
-## blt_add_target_definitions(TO TARGET_DEFINITIONS [FOO [BAR ...]])
+## blt_add_target_definitions(TO
+## SCOPE
+## TARGET_DEFINITIONS [FOO [BAR ...]])
##
## Adds pre-processor definitions to the given target.
-##
-## Adds pre-processor definitions to a particular target. This macro provides very
-## similar functionality to cmake's native "add_definitions" command, but,
-## it provides more fine-grained scoping for the compile definitions on a
-## per target basis. Given a list of definitions, e.g., FOO and BAR, this macro
-## adds compiler definitions to the compiler command for the given target, i.e.,
-## it will pass -DFOO and -DBAR.
-##
-## The supplied target must be added via add_executable() or add_library() or
-## with the corresponding blt_add_executable() and blt_add_library() macros.
-##
-## Note, the target definitions can either include or omit the "-D" characters.
-## E.g. the following are all valid ways to add two compile definitions
-## (A=1 and B) to target 'foo'
-##
-## blt_add_target_definitions(TO foo TARGET_DEFINITIONS A=1 B)
-## blt_add_target_definitions(TO foo TARGET_DEFINITIONS -DA=1 -DB)
-## blt_add_target_definitions(TO foo TARGET_DEFINITIONS "A=1;-DB")
-## blt_add_target_definitions(TO foo TARGET_DEFINITIONS " " -DA=1;B")
##------------------------------------------------------------------------------
macro(blt_add_target_definitions)
set(options)
- set(singleValueArgs TO)
+ set(singleValueArgs TO SCOPE)
set(multiValueArgs TARGET_DEFINITIONS)
# Parse the arguments to the macro
cmake_parse_arguments(arg
"${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN})
- ## check that the passed in parameter TO is actually a target
+ # Sanity checks
if(NOT TARGET ${arg_TO})
message(FATAL_ERROR "Target ${arg_TO} passed to blt_add_target_definitions is not a valid cmake target")
endif()
- ## only add the flag if it is not empty
+ blt_determine_scope(TARGET ${arg_TO} SCOPE "${arg_SCOPE}" OUT _scope)
+
+ # Only add the flag if it is not empty
string(STRIP "${arg_TARGET_DEFINITIONS}" _strippedDefs)
if(NOT "${_strippedDefs}" STREQUAL "")
- get_property(_targetType TARGET ${arg_TO} PROPERTY TYPE)
- if(${_targetType} STREQUAL "INTERFACE_LIBRARY")
- target_compile_definitions(${arg_TO} INTERFACE ${_strippedDefs})
- else()
- target_compile_definitions(${arg_TO} PUBLIC ${_strippedDefs})
- endif()
+ target_compile_definitions(${arg_TO} ${_scope} ${_strippedDefs})
endif()
- unset(_targetType)
+ unset(_scope)
unset(_strippedDefs)
endmacro(blt_add_target_definitions)
##------------------------------------------------------------------------------
-## blt_add_target_compile_flags (TO FLAGS [FOO [BAR ...]])
+## blt_add_target_compile_flags(TO
+## SCOPE
+## FLAGS [FOO [BAR ...]])
##
## Adds compiler flags to a target (library, executable or interface) by
## appending to the target's existing flags.
-##
-## The TO argument (required) specifies a cmake target.
-##
-## The FLAGS argument contains a list of compiler flags to add to the target.
-## This macro will strip away leading and trailing whitespace from each flag.
##------------------------------------------------------------------------------
macro(blt_add_target_compile_flags)
set(options)
- set(singleValuedArgs TO)
+ set(singleValuedArgs TO SCOPE)
set(multiValuedArgs FLAGS)
- ## parse the arguments to the macro
+ # Parse the arguments to the macro
cmake_parse_arguments(arg
"${options}" "${singleValuedArgs}" "${multiValuedArgs}" ${ARGN} )
- ## check that the passed in parameter TO is actually a target
+ # Sanity checks
if(NOT TARGET ${arg_TO})
message(FATAL_ERROR "Target ${arg_TO} passed to blt_add_target_compile_flags is not a valid cmake target")
endif()
- ## only add the flag if it is not empty
+ blt_determine_scope(TARGET ${arg_TO} SCOPE "${arg_SCOPE}" OUT _scope)
+
+ # Only add the flag if it is not empty
string(STRIP "${arg_FLAGS}" _strippedFlags)
if(NOT "${_strippedFlags}" STREQUAL "")
- get_property(_targetType TARGET ${arg_TO} PROPERTY TYPE)
- if(${_targetType} STREQUAL "INTERFACE_LIBRARY")
- target_compile_options(${arg_TO} INTERFACE ${_strippedFlags})
- else()
- target_compile_options(${arg_TO} PUBLIC ${_strippedFlags})
- endif()
+ target_compile_options(${arg_TO} ${_scope} ${_strippedFlags})
endif()
- unset(_targetType)
unset(_strippedFlags)
+ unset(_scope)
endmacro(blt_add_target_compile_flags)
##------------------------------------------------------------------------------
-## blt_set_target_folder (TARGET FOLDER )
+## blt_set_target_folder(TARGET FOLDER )
##
## Sets the folder property of cmake target to .
-##
-## This feature is only available when blt's ENABLE_FOLDERS option is ON and
-## in cmake generators that support folders (but is safe to call regardless
-## of the generator or value of ENABLE_FOLDERS).
-##
-## Note: Do not use this macro on header-only (INTERFACE) library targets, since
-## this will generate a cmake configuration error.
##------------------------------------------------------------------------------
macro(blt_set_target_folder)
@@ -220,11 +160,11 @@ macro(blt_set_target_folder)
set(singleValuedArgs TARGET FOLDER)
set(multiValuedArgs)
- ## parse the arguments to the macro
+ # Parse the arguments to the macro
cmake_parse_arguments(arg
"${options}" "${singleValuedArgs}" "${multiValuedArgs}" ${ARGN} )
- ## check for required arguments
+ # Sanity checks
if(NOT DEFINED arg_TARGET)
message(FATAL_ERROR "TARGET is a required parameter for blt_set_target_folder macro")
endif()
@@ -237,7 +177,7 @@ macro(blt_set_target_folder)
message(FATAL_ERROR "FOLDER is a required parameter for blt_set_target_folder macro")
endif()
- ## set the folder property for this target
+ # Set the folder property for this target
if(ENABLE_FOLDERS AND NOT "${arg_FOLDER}" STREQUAL "")
set_property(TARGET ${arg_TARGET} PROPERTY FOLDER "${arg_FOLDER}")
endif()
@@ -246,37 +186,51 @@ endmacro(blt_set_target_folder)
##------------------------------------------------------------------------------
-## blt_add_target_link_flags (TO FLAGS [FOO [BAR ...]])
+## blt_add_target_link_flags (TO
+## SCOPE
+## FLAGS [FOO [BAR ...]])
##
## Adds linker flags to a target by appending to the target's existing flags.
-##
-## The FLAGS argument expects a ; delimited list of linker flags to add to the target.
-##
-## Note: In CMake versions prior to 3.13, this list is converted to a string internally
-## and any ; characters will be removed.
##------------------------------------------------------------------------------
macro(blt_add_target_link_flags)
set(options)
- set(singleValuedArgs TO)
+ set(singleValuedArgs TO SCOPE)
set(multiValuedArgs FLAGS)
## parse the arguments to the macro
cmake_parse_arguments(arg
"${options}" "${singleValuedArgs}" "${multiValuedArgs}" ${ARGN} )
+ set(_flags ${arg_FLAGS})
+ # Convert rpath flag if linking with CUDA
+ if (CUDA_LINK_WITH_NVCC)
+ string(REPLACE "-Wl,-rpath," "-Xlinker -rpath -Xlinker "
+ _flags "${_flags}")
+ endif()
+
+ # Only add the flag if it is not empty
if(NOT "${arg_FLAGS}" STREQUAL "")
if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0" )
# In CMake 3.13+, LINK_FLAGS was converted to LINK_OPTIONS.
- # This now supports generator expressions but expects a list
+ # This now supports generator expressions and scoping but expects a list
# not a string
- set_property(TARGET ${arg_TO} APPEND PROPERTY LINK_OPTIONS ${arg_FLAGS})
+ blt_determine_scope(TARGET ${arg_TO} SCOPE "${arg_SCOPE}" OUT _scope)
+
+ # Note: "SHELL:"" causes the flags to be not de-duplicated and parsed with
+ # separate_arguments
+ if(NOT "${arg_FLAGS}" MATCHES SHELL:)
+ target_link_options(${arg_TO} ${_scope} SHELL:${arg_FLAGS})
+ else()
+ target_link_options(${arg_TO} ${_scope} ${arg_FLAGS})
+ endif()
else()
+ # In CMake <= 3.12, there is no target_link_flags or target_link_options command
get_target_property(_link_flags ${arg_TO} LINK_FLAGS)
if(NOT _link_flags)
set(_link_flags "")
endif()
- set(_link_flags "${arg_FLAGS} ${_link_flags}")
+ set(_link_flags "${_flags} ${_link_flags}")
# Convert from a CMake ;-list to a string
string (REPLACE ";" " " _link_flags_str "${_link_flags}")
@@ -285,6 +239,11 @@ macro(blt_add_target_link_flags)
endif()
endif()
+ unset(_flags)
+ unset(_link_flags)
+ unset(_link_flags_str)
+ unset(_scope)
+
endmacro(blt_add_target_link_flags)
@@ -299,35 +258,7 @@ endmacro(blt_add_target_link_flags)
## LINK_FLAGS [ flag1 [ flag2 ..]]
## DEFINES [def1 [def2 ...]] )
##
-## Registers a library to the project to ease use in other blt macro calls.
-##
-## Stores information about a library in a specific way that is easily recalled
-## in other macros. For example, after registering gtest, you can add gtest to
-## the DEPENDS_ON in your blt_add_executable call and it will add the INCLUDES
-## and LIBRARIES to that executable.
-##
-## TREAT_INCLUDES_AS_SYSTEM informs the compiler to treat this library's include paths
-## as system headers. Only some compilers support this. This is useful if the headers
-## generate warnings you want to not have them reported in your build. This defaults
-## to OFF.
-##
-## This does not actually build the library. This is strictly to ease use after
-## discovering it on your system or building it yourself inside your project.
-##
-## Note: The OBJECT parameter is for internal BLT support for object libraries
-## and is not for users. Object libraries are created using blt_add_library().
-##
-## Output variables (name = "foo"):
-## BLT_FOO_IS_REGISTERED_LIBRARY
-## BLT_FOO_IS_OBJECT_LIBRARY
-## BLT_FOO_DEPENDS_ON
-## BLT_FOO_INCLUDES
-## BLT_FOO_TREAT_INCLUDES_AS_SYSTEM
-## BLT_FOO_FORTRAN_MODULES
-## BLT_FOO_LIBRARIES
-## BLT_FOO_COMPILE_FLAGS
-## BLT_FOO_LINK_FLAGS
-## BLT_FOO_DEFINES
+## Registers a library to the project to ease use in other BLT macro calls.
##------------------------------------------------------------------------------
macro(blt_register_library)
@@ -349,12 +280,12 @@ macro(blt_register_library)
set(BLT_${uppercase_name}_IS_REGISTERED_LIBRARY TRUE CACHE BOOL "" FORCE)
if( arg_DEPENDS_ON )
- set(BLT_${uppercase_name}_DEPENDS_ON ${arg_DEPENDS_ON} CACHE LIST "" FORCE)
+ set(BLT_${uppercase_name}_DEPENDS_ON ${arg_DEPENDS_ON} CACHE STRING "" FORCE)
mark_as_advanced(BLT_${uppercase_name}_DEPENDS_ON)
endif()
if( arg_INCLUDES )
- set(BLT_${uppercase_name}_INCLUDES ${arg_INCLUDES} CACHE LIST "" FORCE)
+ set(BLT_${uppercase_name}_INCLUDES ${arg_INCLUDES} CACHE STRING "" FORCE)
mark_as_advanced(BLT_${uppercase_name}_INCLUDES)
endif()
@@ -373,12 +304,12 @@ macro(blt_register_library)
mark_as_advanced(BLT_${uppercase_name}_TREAT_INCLUDES_AS_SYSTEM)
if( ENABLE_FORTRAN AND arg_FORTRAN_MODULES )
- set(BLT_${uppercase_name}_FORTRAN_MODULES ${arg_INCLUDES} CACHE LIST "" FORCE)
+ set(BLT_${uppercase_name}_FORTRAN_MODULES ${arg_INCLUDES} CACHE STRING "" FORCE)
mark_as_advanced(BLT_${uppercase_name}_FORTRAN_MODULES)
endif()
if( arg_LIBRARIES )
- set(BLT_${uppercase_name}_LIBRARIES ${arg_LIBRARIES} CACHE LIST "" FORCE)
+ set(BLT_${uppercase_name}_LIBRARIES ${arg_LIBRARIES} CACHE STRING "" FORCE)
else()
# This prevents cmake from falling back on adding -l
# to the command line for BLT registered libraries which are not
@@ -398,7 +329,7 @@ macro(blt_register_library)
endif()
if( arg_DEFINES )
- set(BLT_${uppercase_name}_DEFINES ${arg_DEFINES} CACHE LIST "" FORCE)
+ set(BLT_${uppercase_name}_DEFINES ${arg_DEFINES} CACHE STRING "" FORCE)
mark_as_advanced(BLT_${uppercase_name}_DEFINES)
endif()
@@ -417,53 +348,9 @@ endmacro(blt_register_library)
## SHARED [TRUE | FALSE]
## OBJECT [TRUE | FALSE]
## CLEAR_PREFIX [TRUE | FALSE]
-## FOLDER [name]
-## )
+## FOLDER [name])
##
## Adds a library target, called , to be built from the given sources.
-## This macro uses the BUILD_SHARED_LIBS, which is defaulted to OFF, to determine
-## whether the library will be build as shared or static. The optional boolean
-## SHARED argument can be used to override this choice.
-##
-## The OBJECT argument creates a CMake object library. Basically it is a collection
-## of compiled source files that are not archived or linked. Unlike regular CMake
-## object libraries you do not have to use the $> syntax,
-## you can just use .
-## Note: Object libraries do not follow CMake's transitivity rules until 3.12.
-## BLT will add the various information provided in this macro and its
-## dependencies in the order you provide them to help.
-##
-## The INCLUDES argument allows you to define what include directories are
-## needed by any target that is dependent on this library. These will
-## be inherited by CMake's target dependency rules.
-##
-## The DEFINES argument allows you to add needed compiler definitions that are
-## needed by any target that is dependent on this library. These will
-## be inherited by CMake's target dependency rules.
-##
-## If given a DEPENDS_ON argument, it will add the necessary includes and
-## libraries if they are already registered with blt_register_library. If
-## not it will add them as a CMake target dependency.
-##
-## In addition, this macro will add the associated dependencies to the given
-## library target. Specifically, it will add the dependency for the CMake target
-## and for copying the headers for that target as well.
-##
-## The OUTPUT_DIR is used to control the build output directory of this
-## library. This is used to overwrite the default lib directory.
-##
-## OUTPUT_NAME is the name of the output file; the default is NAME.
-## It's useful when multiple libraries with the same name need to be created
-## by different targets. NAME is the target name, OUTPUT_NAME is the library name.
-##
-## CLEAR_PREFIX allows you to remove the automatically appended "lib" prefix
-## from your built library. The created library will be foo.a instead of libfoo.a.
-##
-## FOLDER is an optional keyword to organize the target into a folder in an IDE.
-## This is available when ENABLE_FOLDERS is ON and when the cmake generator
-## supports this feature and will otherwise be ignored.
-## Note: Do not use with header-only (INTERFACE)libraries, as this will generate
-## a cmake configuration error.
##------------------------------------------------------------------------------
macro(blt_add_library)
@@ -475,7 +362,7 @@ macro(blt_add_library)
cmake_parse_arguments(arg
"${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN} )
- # sanity checks
+ # Sanity checks
if( "${arg_NAME}" STREQUAL "" )
message(FATAL_ERROR "blt_add_library() must be called with argument NAME ")
endif()
@@ -615,35 +502,15 @@ endmacro(blt_add_library)
##------------------------------------------------------------------------------
-## blt_add_executable( NAME
-## SOURCES [source1 [source2 ...]]
-## INCLUDES [dir1 [dir2 ...]]
-## DEFINES [define1 [define2 ...]]
+## blt_add_executable( NAME
+## SOURCES [source1 [source2 ...]]
+## INCLUDES [dir1 [dir2 ...]]
+## DEFINES [define1 [define2 ...]]
## DEPENDS_ON [dep1 [dep2 ...]]
## OUTPUT_DIR [dir]
-## FOLDER [name])
-##
-## Adds an executable target, called .
-##
-## The INCLUDES argument allows you to define what include directories are
-## needed to compile this executable.
-##
-## The DEFINES argument allows you to add needed compiler definitions that are
-## needed to compile this executable.
-##
-## If given a DEPENDS_ON argument, it will add the necessary includes and
-## libraries if they are already registered with blt_register_library. If
-## not it will add them as a cmake target dependency.
+## FOLDER [name])
##
-## The OUTPUT_DIR is used to control the build output directory of this
-## executable. This is used to overwrite the default bin directory.
-##
-## If the first entry in SOURCES is a Fortran source file, the fortran linker
-## is used. (via setting the CMake target property LINKER_LANGUAGE to Fortran )
-##
-## FOLDER is an optional keyword to organize the target into a folder in an IDE.
-## This is available when ENABLE_FOLDERS is ON and when using a cmake generator
-## that supports this feature and will otherwise be ignored.
+## Adds an executable target, called , to be built from the given sources.
##------------------------------------------------------------------------------
macro(blt_add_executable)
@@ -655,7 +522,7 @@ macro(blt_add_executable)
cmake_parse_arguments(arg
"${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN})
- # sanity checks
+ # Sanity checks
if( "${arg_NAME}" STREQUAL "" )
message(FATAL_ERROR "blt_add_executable() must be called with argument NAME ")
endif()
@@ -694,6 +561,12 @@ macro(blt_add_executable)
DEPENDS_ON ${arg_DEPENDS_ON}
OBJECT FALSE)
+ # fix the openmp flags for fortran if needed
+ # NOTE: this needs to be called after blt_setup_target()
+ if (_lang STREQUAL Fortran)
+ blt_fix_fortran_openmp_flags( ${arg_NAME} )
+ endif()
+
if ( arg_INCLUDES )
target_include_directories(${arg_NAME} PUBLIC ${arg_INCLUDES})
endif()
@@ -723,28 +596,19 @@ endmacro(blt_add_executable)
##------------------------------------------------------------------------------
-## blt_add_test( NAME [name] COMMAND [command] NUM_MPI_TASKS [n] )
-##
-## Adds a CMake test to the project.
+## blt_add_test( NAME [name]
+## COMMAND [command]
+## NUM_MPI_TASKS [n]
+## NUM_OMP_THREADS [n]
+## CONFIGURATIONS [config1 [config2...]])
##
-## NAME is used for the name that CTest reports with.
-##
-## COMMAND is the command line that will be used to run the test. This will
-## have the RUNTIME_OUTPUT_DIRECTORY prepended to it to fully qualify the path.
-##
-## NUM_MPI_TASKS indicates this is an MPI test and how many tasks to use. The
-## command line will use MPIEXEC, MPIEXEC_NUMPROC_FLAG, and BLT_MPI_COMMAND_APPEND
-## to create the MPI run line.
-##
-## MPIEXEC and MPIEXEC_NUMPROC_FLAG are filled in by CMake's FindMPI.cmake but can
-## be overwritten in your host-config specific to your platform. BLT_MPI_COMMAND_APPEND
-## is useful on machines that require extra arguments to MPIEXEC.
+## Adds a test to the project.
##------------------------------------------------------------------------------
macro(blt_add_test)
set(options )
- set(singleValueArgs NAME NUM_MPI_TASKS)
- set(multiValueArgs COMMAND)
+ set(singleValueArgs NAME NUM_MPI_TASKS NUM_OMP_THREADS)
+ set(multiValueArgs COMMAND CONFIGURATIONS)
# Parse the arguments to the macro
cmake_parse_arguments(arg
@@ -786,7 +650,7 @@ macro(blt_add_test)
endif()
# Handle MPI
- if ( ${arg_NUM_MPI_TASKS} )
+ if( arg_NUM_MPI_TASKS )
# Handle CMake changing MPIEXEC to MPIEXEC_EXECUTABLE
if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10.0" )
set(_mpiexec ${MPIEXEC_EXECUTABLE})
@@ -797,76 +661,42 @@ macro(blt_add_test)
set(test_command ${_mpiexec} ${MPIEXEC_NUMPROC_FLAG} ${arg_NUM_MPI_TASKS} ${BLT_MPI_COMMAND_APPEND} ${test_command} )
endif()
- add_test(NAME ${arg_NAME}
- COMMAND ${test_command} )
+ add_test(NAME ${arg_NAME}
+ COMMAND ${test_command}
+ CONFIGURATIONS ${arg_CONFIGURATIONS})
+
+ # Handle OpenMP
+ if( arg_NUM_OMP_THREADS )
+ set_property(TEST ${arg_NAME}
+ APPEND PROPERTY ENVIRONMENT OMP_NUM_THREADS=${arg_NUM_OMP_THREADS})
+ endif()
endmacro(blt_add_test)
##------------------------------------------------------------------------------
-## blt_add_benchmark( NAME [name] COMMAND [command] )
-##
-## Adds a (google) benchmark test to the project.
-##
-## NAME is used for the name that CTest reports and should include the string 'benchmark'.
-##
-## COMMAND is the command line that will be used to run the test and can include arguments.
-## This will have the RUNTIME_OUTPUT_DIRECTORY prepended to it to fully qualify the path.
-##
-## The underlying executable (added with blt_add_executable) should include gbenchmark
-## as one of its dependencies.
+## blt_add_benchmark( NAME [name]
+## COMMAND [command]
+## NUM_MPI_TASKS [n])
##
-## Example
-## blt_add_executable(NAME component_benchmark ... DEPENDS gbenchmark)
-## blt_add_benchmark(
-## NAME component_benchmark
-## COMMAND component_benchmark "--benchmark_min_time=0.0 --v=3 --benchmark_format=json"
-## )
+## Adds a benchmark to the project.
##------------------------------------------------------------------------------
macro(blt_add_benchmark)
- if(ENABLE_BENCHMARKS)
-
- set(options)
- set(singleValueArgs NAME)
- set(multiValueArgs COMMAND)
-
- ## parse the arguments to the macro
- cmake_parse_arguments(arg
- "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN} )
-
- if ( NOT DEFINED arg_NAME )
- message(FATAL_ERROR "NAME is a required parameter to blt_add_benchmark")
- endif()
-
- if ( NOT DEFINED arg_COMMAND )
- message(FATAL_ERROR "COMMAND is a required parameter to blt_add_benchmark")
- endif()
-
- # Generate command
- if ( NOT TARGET ${arg_NAME} )
- # Handle case of running multiple tests against one executable,
- # the NAME will not be the target
- list(GET arg_COMMAND 0 executable)
- get_target_property(runtime_output_directory ${executable} RUNTIME_OUTPUT_DIRECTORY )
- else()
- get_target_property(runtime_output_directory ${arg_NAME} RUNTIME_OUTPUT_DIRECTORY )
- endif()
- set(test_command ${runtime_output_directory}/${arg_COMMAND} )
-
- # Note: No MPI handling for now. If desired, see how this is handled in blt_add_test macro
-
- # The 'CONFIGURATIONS Benchmark' line excludes benchmarks
- # from the general list of tests
- add_test( NAME ${arg_NAME}
- COMMAND ${test_command}
- CONFIGURATIONS Benchmark
- )
-
- if(ENABLE_TESTS)
- add_dependencies(run_benchmarks ${arg_NAME})
- endif()
- endif()
+ set(options)
+ set(singleValueArgs NAME NUM_MPI_TASKS)
+ set(multiValueArgs COMMAND)
+
+ ## parse the arguments to the macro
+ cmake_parse_arguments(arg
+ "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN} )
+
+ # The 'CONFIGURATIONS Benchmark' line excludes benchmarks
+ # from the general list of tests
+ blt_add_test( NAME ${arg_NAME}
+ COMMAND ${arg_COMMAND}
+ NUM_MPI_TASKS ${arg_NUM_MPI_TASKS}
+ CONFIGURATIONS Benchmark)
endmacro(blt_add_benchmark)
@@ -883,23 +713,14 @@ endmacro(blt_add_benchmark)
## MSVC msvcFlag (optional)
## MSVC_INTEL msvcIntelFlag (optional)
## PGI pgiFlag (optional)
-## )
+## CRAY crayFlag (optional))
##
## Appends compiler-specific flags to a given variable of flags
-##
-## If a custom flag is given for the current compiler, we use that.
-## Otherwise, we will use the DEFAULT flag (if present)
-## If ENABLE_FORTRAN is On, any flagsVar with "fortran" (any capitalization)
-## in its name will pick the compiler family (GNU,CLANG, INTEL, etc) based on
-## the fortran compiler family type. This allows mixing C and Fortran compiler
-## families, e.g. using Intel fortran compilers with clang C compilers.
-## When using the Intel toolchain within visual studio, we use the
-## MSVC_INTEL flag, when provided, with a fallback to the MSVC flag.
##------------------------------------------------------------------------------
macro(blt_append_custom_compiler_flag)
set(options)
- set(singleValueArgs FLAGS_VAR DEFAULT GNU CLANG HCC PGI INTEL XL MSVC MSVC_INTEL)
+ set(singleValueArgs FLAGS_VAR DEFAULT GNU CLANG HCC PGI INTEL XL MSVC MSVC_INTEL CRAY)
set(multiValueArgs)
# Parse the arguments
@@ -931,6 +752,8 @@ macro(blt_append_custom_compiler_flag)
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_PGI} " )
elseif( DEFINED arg_GNU AND Fortran_COMPILER_FAMILY_IS_GNU )
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_GNU} " )
+ elseif( DEFINED arg_CRAY AND Fortran_COMPILER_FAMILY_IS_CRAY )
+ set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_CRAY} " )
elseif( DEFINED arg_DEFAULT )
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_DEFAULT} ")
endif()
@@ -947,6 +770,8 @@ macro(blt_append_custom_compiler_flag)
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_PGI} " )
elseif( DEFINED arg_GNU AND C_COMPILER_FAMILY_IS_GNU )
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_GNU} " )
+ elseif( DEFINED arg_CRAY AND C_COMPILER_FAMILY_IS_CRAY )
+ set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_CRAY} " )
elseif( DEFINED arg_DEFAULT )
set (${arg_FLAGS_VAR} "${${arg_FLAGS_VAR}} ${arg_DEFAULT} ")
endif()
@@ -958,21 +783,11 @@ endmacro(blt_append_custom_compiler_flag)
##------------------------------------------------------------------------------
## blt_find_libraries( FOUND_LIBS
-## NAMES [libname1 [libname2 ...]]
-## REQUIRED [TRUE (default) | FALSE ]
-## PATHS [path1 [path2 ...]] )
+## NAMES [libname1 [libname2 ...]]
+## REQUIRED [TRUE (default) | FALSE ]
+## PATHS [path1 [path2 ...]] )
##
## This command is used to find a list of libraries.
-##
-## If the libraries are found the results are appended to the given FOUND_LIBS variable name.
-##
-## NAMES lists the names of the libraries that will be searched for in the given PATHS.
-##
-## If REQUIRED is set to TRUE, BLT will produce an error message if any of the
-## given libraries are not found. The default value is TRUE.
-##
-## PATH lists the paths in which to search for NAMES. No system paths will be searched.
-##
##------------------------------------------------------------------------------
macro(blt_find_libraries)
@@ -1024,8 +839,7 @@ endmacro(blt_find_libraries)
## SOURCE_LIBS [lib1 ...]
## LIB_TYPE [STATIC,SHARED]
## LINK_PREPEND []
-## LINK_POSTPEND []
-## )
+## LINK_POSTPEND [])
##
## Adds a library target, called , to be built from the set of
## static libraries given in SOURCE_LIBS.
@@ -1047,7 +861,7 @@ macro(blt_combine_static_libraries)
cmake_parse_arguments(arg
"${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN} )
- # sanity checks
+ # Sanity checks
if( "${arg_NAME}" STREQUAL "" )
message(FATAL_ERROR "blt_combine_static_libraries() must be called with argument NAME ")
endif()
@@ -1204,16 +1018,9 @@ endmacro(blt_combine_static_libraries)
##------------------------------------------------------------------------------
-## blt_print_target_properties (TARGET )
+## blt_print_target_properties(TARGET )
##
## Prints out all properties of the given target.
-##
-## The required target parameteter must either be a valid cmake target
-## or was registered via blt_register_library.
-##
-## Output is of the form:
-## [ property] :
-## for each property
##------------------------------------------------------------------------------
macro(blt_print_target_properties)
@@ -1288,7 +1095,7 @@ macro(blt_print_target_properties)
## Filter to get variables of the form BLT__ and print
get_cmake_property(_variable_names VARIABLES)
foreach (prop ${_variable_names})
- if(prop MATCHES "${_target_prefix}?")
+ if(prop MATCHES "^${_target_prefix}")
message (STATUS "[${arg_TARGET} property] ${prop}: ${${prop}}")
endif()
endforeach()
diff --git a/cmake/BLTOptions.cmake b/cmake/BLTOptions.cmake
index 52b93c46d..35fded947 100644
--- a/cmake/BLTOptions.cmake
+++ b/cmake/BLTOptions.cmake
@@ -2,20 +2,25 @@
# other BLT Project Developers. See the top-level COPYRIGHT file for details
#
# SPDX-License-Identifier: (BSD-3-Clause)
+#------------------------------------------------------------------------------
+# Sets up configuration options for BLT
+#------------------------------------------------------------------------------
-################################
+include(CMakeDependentOption)
+
+#------------------------------------------------------------------------------
# Build Targets
-################################
+#------------------------------------------------------------------------------
option(ENABLE_DOCS "Enables documentation" ON)
option(ENABLE_EXAMPLES "Enables examples" ON)
option(ENABLE_TESTS "Enables tests" ON)
option(ENABLE_BENCHMARKS "Enables benchmarks" OFF)
option(ENABLE_COVERAGE "Enables code coverage support" OFF)
-
-################################
+#------------------------------------------------------------------------------
# TPL Executable Options
-################################
+#------------------------------------------------------------------------------
+option(ENABLE_CLANGQUERY "Enables Clang-query support" ON)
option(ENABLE_CPPCHECK "Enables Cppcheck support" ON)
option(ENABLE_DOXYGEN "Enables Doxygen support" ON)
option(ENABLE_GIT "Enables Git support" ON)
@@ -24,10 +29,9 @@ option(ENABLE_UNCRUSTIFY "Enables Uncrustify support" ON)
option(ENABLE_ASTYLE "Enables AStyle support" ON)
option(ENABLE_VALGRIND "Enables Valgrind support" ON)
-
-################################
+#------------------------------------------------------------------------------
# Build Options
-################################
+#------------------------------------------------------------------------------
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if(_languages MATCHES "Fortran")
set(_fortran_already_enabled TRUE)
@@ -47,6 +51,9 @@ option(ENABLE_HIP "Enable HIP support" OFF)
option(ENABLE_HCC "Enable HCC support" OFF)
set(BLT_ROCM_ARCH "gfx900" CACHE STRING "gfx architecture to use when generating ROCm code")
+#------------------------------------------------------------------------------
+# Test Options
+#
# Options that control if Google Test, Google Mock, and Fruit are built
# and available for use.
#
@@ -54,7 +61,7 @@ set(BLT_ROCM_ARCH "gfx900" CACHE STRING "gfx architecture to use when generating
#
# Google Mock requires and always builds Google Test, so ENABLE_GMOCK=ON
# implies ENABLE_GTEST=ON.
-#
+#------------------------------------------------------------------------------
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if(_languages MATCHES "CXX")
set(_CXX_enabled ON)
@@ -64,27 +71,34 @@ endif()
option(ENABLE_GTEST "Enable Google Test testing support (if ENABLE_TESTS=ON)" ${_CXX_enabled})
option(ENABLE_GMOCK "Enable Google Mock testing support (if ENABLE_TESTS=ON)" OFF)
option(ENABLE_FRUIT "Enable Fruit testing support (if ENABLE_TESTS=ON and ENABLE_FORTRAN=ON)" ON)
+option(ENABLE_GBENCHMARK "Enable Google Benchmark support (if ENABLE_TESTS=ON)" ${ENABLE_BENCHMARKS})
+
if( (NOT _CXX_enabled) AND ENABLE_GTEST )
message( FATAL_ERROR
"You must have CXX enabled in your project to use GTEST!" )
endif()
-################################
+#------------------------------------------------------------------------------
# Compiler Options
-################################
-option(ENABLE_ALL_WARNINGS "Enables all compiler warnings on all build targets" ON)
-option(ENABLE_WARNINGS_AS_ERRORS "Enables treating compiler warnings as errors on all build targets" OFF)
-
-################################
+#------------------------------------------------------------------------------
+option(ENABLE_ALL_WARNINGS "Enables all compiler warnings on all build targets" ON)
+option(ENABLE_WARNINGS_AS_ERRORS "Enables treating compiler warnings as errors on all build targets" OFF)
+cmake_dependent_option(BLT_ENABLE_MSVC_STATIC_MD_TO_MT
+ "When linking statically with MS Visual Studio, enables changing /MD to /MT"
+ ON
+ "NOT BUILD_SHARED_LIBS"
+ OFF)
+mark_as_advanced(BLT_ENABLE_MSVC_STATIC_MD_TO_MT)
+
+#------------------------------------------------------------------------------
# Generator Options
-################################
+#------------------------------------------------------------------------------
option(ENABLE_FOLDERS "Organize projects using folders (in generators that support this)" OFF)
-
-################################
+#------------------------------------------------------------------------------
# Advanced configuration options
-################################
+#------------------------------------------------------------------------------
option(ENABLE_FIND_MPI "Enables CMake's Find MPI support (Turn off when compiling with the mpi wrapper directly)" ON)
@@ -97,14 +111,28 @@ option(
ENABLE_WRAP_ALL_TESTS_WITH_MPIEXEC
"Option to ensure that all tests are invoked through mpiexec. Required on some platforms, like IBM's BG/Q."
OFF )
-
-# All advanced options should be marked as advanced
-mark_as_advanced(
- ENABLE_FIND_MPI
- ENABLE_GTEST_DEATH_TESTS
- ENABLE_WRAP_ALL_TESTS_WITH_MPIEXEC )
if (DEFINED ENABLE_SHARED_LIBS)
message(FATAL_ERROR "ENABLE_SHARED_LIBS is a deprecated BLT option."
"Use the standard CMake option, BUILD_SHARED_LIBS, instead.")
endif()
+
+# Provide some overridable target names for custom targets that blt defines.
+# This can be useful when working with other build systems since CMake requires
+# unique names for targets.
+set(BLT_CODE_CHECK_TARGET_NAME "check" CACHE STRING "Name of the master code check target")
+set(BLT_CODE_STYLE_TARGET_NAME "style" CACHE STRING "Name of the master code formatting target")
+set(BLT_DOCS_TARGET_NAME "docs" CACHE STRING "Name of the master documentation generation target")
+set(BLT_RUN_BENCHMARKS_TARGET_NAME "run_benchmarks" CACHE STRING "Name of the target to run benchmark tests")
+
+
+# All advanced options should be marked as advanced
+mark_as_advanced(
+ ENABLE_FIND_MPI
+ ENABLE_GTEST_DEATH_TESTS
+ ENABLE_WRAP_ALL_TESTS_WITH_MPIEXEC
+ BLT_CODE_CHECK_TARGET_NAME
+ BLT_CODE_STYLE_TARGET_NAME
+ BLT_DOCS_TARGET_NAME
+ BLT_RUN_BENCHMARKS_TARGET_NAME )
+
diff --git a/cmake/BLTPrivateMacros.cmake b/cmake/BLTPrivateMacros.cmake
index 90e259e66..32337c480 100644
--- a/cmake/BLTPrivateMacros.cmake
+++ b/cmake/BLTPrivateMacros.cmake
@@ -1,6 +1,6 @@
# Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
# other BLT Project Developers. See the top-level COPYRIGHT file for details
-#
+#
# SPDX-License-Identifier: (BSD-3-Clause)
include(CMakeParseArguments)
@@ -8,6 +8,69 @@ include(CMakeParseArguments)
## Internal BLT CMake Macros
+##-----------------------------------------------------------------------------
+## blt_determine_scope(TARGET
+## SCOPE
+## OUT )
+##
+## Returns the normalized scope string for a given SCOPE and TARGET to be used
+## in BLT macros.
+##
+## TARGET - Name of CMake Target that the property is being added to
+## Note: the only real purpose of this parameter is to make sure we aren't
+## adding returning other than INTERFACE for Interface Libraries
+## SCOPE - case-insensitive scope string, defaults to PUBLIC
+## OUT - variable that is filled with the uppercased scope
+##
+##-----------------------------------------------------------------------------
+macro(blt_determine_scope)
+
+ set(options)
+ set(singleValueArgs TARGET SCOPE OUT)
+ set(multiValueArgs )
+
+ # Parse the arguments
+ cmake_parse_arguments(arg "${options}" "${singleValueArgs}"
+ "${multiValueArgs}" ${ARGN} )
+
+ # Convert to upper case and strip white space
+ string(TOUPPER "${arg_SCOPE}" _uppercaseScope)
+ string(STRIP "${_uppercaseScope}" _uppercaseScope )
+
+ if("${_uppercaseScope}" STREQUAL "")
+ # Default to public
+ set(_uppercaseScope PUBLIC)
+ elseif(NOT ("${_uppercaseScope}" STREQUAL "PUBLIC" OR
+ "${_uppercaseScope}" STREQUAL "INTERFACE" OR
+ "${_uppercaseScope}" STREQUAL "PRIVATE"))
+ message(FATAL_ERROR "Given SCOPE (${arg_SCOPE}) is not valid, valid options are:"
+ "PUBLIC, INTERFACE, or PRIVATE")
+ endif()
+
+ if(TARGET ${arg_TARGET})
+ get_property(_targetType TARGET ${arg_TARGET} PROPERTY TYPE)
+ if(${_targetType} STREQUAL "INTERFACE_LIBRARY")
+ # Interface targets can only set INTERFACE
+ if("${_uppercaseScope}" STREQUAL "PUBLIC" OR
+ "${_uppercaseScope}" STREQUAL "INTERFACE")
+ set(${arg_OUT} INTERFACE)
+ else()
+ message(FATAL_ERROR "Cannot set PRIVATE scope to Interface Library."
+ "Change to Scope to INTERFACE.")
+ endif()
+ else()
+ set(${arg_OUT} ${_uppercaseScope})
+ endif()
+ else()
+ set(${arg_OUT} ${_uppercaseScope})
+ endif()
+
+ unset(_targetType)
+ unset(_uppercaseScope)
+
+endmacro(blt_determine_scope)
+
+
##-----------------------------------------------------------------------------
## blt_error_if_target_exists()
##
@@ -20,6 +83,34 @@ function(blt_error_if_target_exists target_name error_msg)
endif()
endfunction()
+##-----------------------------------------------------------------------------
+## blt_fix_fortran_openmp_flags()
+##
+## Fixes the openmp flags for a Fortran target if they are different from the
+## corresponding C/C++ openmp flags.
+##-----------------------------------------------------------------------------
+function(blt_fix_fortran_openmp_flags target_name)
+
+
+ if (ENABLE_FORTRAN AND ENABLE_OPENMP AND BLT_OPENMP_FLAGS_DIFFER)
+
+ get_target_property(target_link_flags ${target_name} LINK_FLAGS)
+ if ( target_link_flags )
+
+ message(STATUS "Fixing OpenMP Flags for target[${target_name}]")
+
+ string( REPLACE "${OpenMP_CXX_FLAGS}" "${OpenMP_Fortran_FLAGS}"
+ correct_link_flags
+ "${target_link_flags}"
+ )
+
+ set_target_properties( ${target_name} PROPERTIES LINK_FLAGS
+ "${correct_link_flags}" )
+ endif()
+
+ endif()
+
+endfunction()
##-----------------------------------------------------------------------------
## blt_find_executable(NAME
@@ -98,7 +189,7 @@ endmacro(blt_find_executable)
##------------------------------------------------------------------------------
macro(blt_inherit_target_info)
set(options)
- set(singleValueArgs TO FROM)
+ set(singleValueArgs TO FROM OBJECT)
set(multiValueArgs)
# Parse the arguments
@@ -150,8 +241,8 @@ endmacro(blt_inherit_target_info)
##------------------------------------------------------------------------------
-## blt_setup_target( NAME [name]
-## DEPENDS_ON [dep1 ...]
+## blt_setup_target( NAME [name]
+## DEPENDS_ON [dep1 ...]
## OBJECT [TRUE | FALSE])
##------------------------------------------------------------------------------
macro(blt_setup_target)
@@ -208,6 +299,18 @@ macro(blt_setup_target)
${BLT_${uppercase_dependency}_FORTRAN_MODULES} )
endif()
+ if ( arg_OBJECT )
+ # Object libraries need to inherit info from their CMake targets listed
+ # in their LIBRARIES
+ foreach( _library ${BLT_${uppercase_dependency}_LIBRARIES} )
+ if(TARGET ${_library})
+ blt_inherit_target_info(TO ${arg_NAME}
+ FROM ${_library}
+ OBJECT ${arg_OBJECT})
+ endif()
+ endforeach()
+ endif()
+
if ( arg_OBJECT OR BLT_${uppercase_dependency}_IS_OBJECT_LIBRARY )
# We want object libraries to inherit the vital info but not call
# target_link_libraries() otherwise you have to install the object
@@ -215,7 +318,7 @@ macro(blt_setup_target)
if ( TARGET ${dependency} )
blt_inherit_target_info(TO ${arg_NAME}
FROM ${dependency}
- OBJECT TRUE)
+ OBJECT ${arg_OBJECT})
endif()
elseif (DEFINED BLT_${uppercase_dependency}_LIBRARIES)
# This prevents cmake from adding -l to the
@@ -288,7 +391,7 @@ macro(blt_setup_cuda_target)
endif()
if (${_depends_on_cuda_runtime} OR ${_depends_on_cuda})
- if (CUDA_LINK_WITH_NVCC)
+ if (CUDA_LINK_WITH_NVCC)
set_target_properties( ${arg_NAME} PROPERTIES LINKER_LANGUAGE CUDA)
endif()
endif()
@@ -554,7 +657,7 @@ macro(blt_filter_list)
set(multiValueArgs )
# Parse arguments
- cmake_parse_arguments(arg "${options}" "${singleValueArgs}"
+ cmake_parse_arguments(arg "${options}" "${singleValueArgs}"
"${multiValueArgs}" ${ARGN} )
# Check arguments
@@ -615,7 +718,7 @@ macro(blt_clean_target)
set(multiValueArgs )
# Parse arguments
- cmake_parse_arguments(arg "${options}" "${singleValueArgs}"
+ cmake_parse_arguments(arg "${options}" "${singleValueArgs}"
"${multiValueArgs}" ${ARGN} )
# Properties to remove duplicates from
diff --git a/cmake/SetupCodeChecks.cmake b/cmake/SetupCodeChecks.cmake
index 3ee38b124..68f4ce870 100644
--- a/cmake/SetupCodeChecks.cmake
+++ b/cmake/SetupCodeChecks.cmake
@@ -2,37 +2,36 @@
# other BLT Project Developers. See the top-level COPYRIGHT file for details
#
# SPDX-License-Identifier: (BSD-3-Clause)
-
-###############################################################################
+#------------------------------------------------------------------------------
# Targets related to source code checks (formatting, static analysis, etc)
-###############################################################################
+#------------------------------------------------------------------------------
-add_custom_target(check)
-add_custom_target(style)
+add_custom_target(${BLT_CODE_CHECK_TARGET_NAME})
+add_custom_target(${BLT_CODE_STYLE_TARGET_NAME})
if(UNCRUSTIFY_FOUND)
# targets for verifying formatting
add_custom_target(uncrustify_check)
- add_dependencies(check uncrustify_check)
+ add_dependencies(${BLT_CODE_CHECK_TARGET_NAME} uncrustify_check)
# targets for modifying formatting
add_custom_target(uncrustify_style)
- add_dependencies(style uncrustify_style)
+ add_dependencies(${BLT_CODE_STYLE_TARGET_NAME} uncrustify_style)
endif()
if(ASTYLE_FOUND)
# targets for verifying formatting
add_custom_target(astyle_check)
- add_dependencies(check astyle_check)
+ add_dependencies(${BLT_CODE_CHECK_TARGET_NAME} astyle_check)
# targets for modifying formatting
add_custom_target(astyle_style)
- add_dependencies(style astyle_style)
+ add_dependencies(${BLT_CODE_STYLE_TARGET_NAME} astyle_style)
endif()
if(CPPCHECK_FOUND)
add_custom_target(cppcheck_check)
- add_dependencies(check cppcheck_check)
+ add_dependencies(${BLT_CODE_CHECK_TARGET_NAME} cppcheck_check)
endif()
if(CLANGQUERY_FOUND)
@@ -43,7 +42,7 @@ if(CLANGQUERY_FOUND)
# sense as a dependency of check
add_custom_target(clang_query_check)
add_custom_target(interactive_clang_query_check)
- add_dependencies(check clang_query_check)
+ add_dependencies(${BLT_CODE_CHECK_TARGET_NAME} clang_query_check)
endif()
# Code check targets should only be run on demand
@@ -61,36 +60,19 @@ endforeach()
##------------------------------------------------------------------------------
## blt_add_code_checks( PREFIX
## SOURCES [source1 [source2 ...]]
-## UNCRUSTIFY_CFG_FILE
-## ASTYLE_CFG_FILE )
+## UNCRUSTIFY_CFG_FILE
+## ASTYLE_CFG_FILE
+## CPPCHECK_FLAGS )
##
## This macro adds all enabled code check targets for the given SOURCES. It
-## filters based on file extensions.
-##
-## PREFIX is used in the creation of all the underlying targets. For example:
-## _uncrustify_check.
-##
-## Sources are filtered based on file extensions for use in these code checks. If you need
-## additional file extensions defined add them to BLT_C_FILE_EXTS and BLT_Fortran_FILE_EXTS.
-##
-## This macro supports formatting with either Uncrustify or AStyle (but not both) using
-## the following parameters:
-##
-## * UNCRUSTIFY_CFG_FILE is the configuration file for Uncrustify. If UNCRUSTIFY_EXECUTABLE
-## is defined, found, and UNCRUSTIFY_CFG_FILE is provided it will create both check and
-## style function for the given C/C++ files.
-##
-## * ASTYLE_CFG_FILE is the configuration file for AStyle. If ASTYLE_EXECUTABLE
-## is defined, found, and ASTYLE_CFG_FILE is provided it will create both check and
-## style function for the given C/C++ files.
-##
+## filters checks based on file extensions.
##------------------------------------------------------------------------------
macro(blt_add_code_checks)
set(options )
set(singleValueArgs PREFIX UNCRUSTIFY_CFG_FILE ASTYLE_CFG_FILE)
- set(multiValueArgs SOURCES)
+ set(multiValueArgs SOURCES CPPCHECK_FLAGS)
cmake_parse_arguments(arg
"${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -178,43 +160,29 @@ macro(blt_add_code_checks)
blt_add_cppcheck_target( NAME ${_cppcheck_target_name}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- SRC_FILES ${_c_sources})
+ SRC_FILES ${_c_sources}
+ PREPEND_FLAGS ${arg_CPPCHECK_FLAGS})
endif()
if (CLANGQUERY_FOUND)
set(_clang_query_target_name ${arg_PREFIX}_clang_query_check)
blt_error_if_target_exists(${_clang_query_target_name} ${_error_msg})
- blt_add_clang_query_target( NAME ${_clang_query_target_name}
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- SRC_FILES ${_c_sources})
+ blt_add_clang_query_target( NAME ${_clang_query_target_name}
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ SRC_FILES ${_c_sources})
endif()
endmacro(blt_add_code_checks)
##-----------------------------------------------------------------------------
-## blt_add_clang_query_target( NAME
-## WORKING_DIRECTORY
-## COMMENT
-## CHECKERS
-## DIE_ON_MATCH
-## SRC_FILES [FILE1 [FILE2 ...]] )
+## blt_add_clang_query_target( NAME
+## WORKING_DIRECTORY
+## COMMENT
+## CHECKERS
+## DIE_ON_MATCH
+## SRC_FILES [FILE1 [FILE2 ...]] )
##
## Creates a new target with the given NAME for running clang_query over the given SRC_FILES
-##
-## COMMENT is prepended to the commented outputted by CMake.
-##
-## WORKING_DIRECTORY is the directory that clang_query will be ran. It defaults to the directory
-## where this macro is called.
-##
-## DIE_ON_MATCH This will make a match cause the build to fail, useful if you're using this in
-## CI to enforce rules about your code
-##
-## CHECKERS are the static analysis passes to specifically run on the target. Options
-## (no value) : run all available static analysis checks found
-## (checker1:checker2) : run checker1 and checker2
-## (interpreter) : run the clang-query interpeter to interactively develop queries
-##
-## SRC_FILES is a list of source files that clang_query will be run on.
##-----------------------------------------------------------------------------
macro(blt_add_clang_query_target)
if(CLANGQUERY_FOUND)
@@ -290,17 +258,6 @@ endmacro(blt_add_clang_query_target)
## SRC_FILES [FILE1 [FILE2 ...]] )
##
## Creates a new target with the given NAME for running cppcheck over the given SRC_FILES
-##
-## PREPEND_FLAGS are additional flags added to the front of the cppcheck flags.
-##
-## APPEND_FLAGS are additional flags added to the end of the cppcheck flags.
-##
-## COMMENT is prepended to the commented outputted by CMake.
-##
-## WORKING_DIRECTORY is the directory that cppcheck will be ran. It defaults to the directory
-## where this macro is called.
-##
-## SRC_FILES is a list of source files that cppcheck will be run on.
##-----------------------------------------------------------------------------
macro(blt_add_cppcheck_target)
@@ -352,25 +309,6 @@ endmacro(blt_add_cppcheck_target)
## SRC_FILES [FILE1 [FILE2 ...]] )
##
## Creates a new target with the given NAME for running uncrustify over the given SRC_FILES.
-##
-## MODIFY_FILES, if set to TRUE, modifies the files in place and adds the created target to
-## the style target. Otherwise the files are not modified and the created target is added
-## to the check target.
-## Note: Setting MODIFY_FILES to FALSE is only supported in Uncrustify v0.61 or greater.
-##
-## CFG_FILE defines the uncrustify settings.
-##
-## PREPEND_FLAGS are additional flags added to the front of the uncrustify flags.
-##
-## APPEND_FLAGS are additional flags added to the end of the uncrustify flags.
-##
-## COMMENT is prepended to CMake's output for this target.
-##
-## WORKING_DIRECTORY is the directory in which uncrustify will be run. It defaults
-## to the directory where this macro is called.
-##
-## SRC_FILES is a list of source files to style/check with uncrustify.
-##
##------------------------------------------------------------------------------
macro(blt_add_uncrustify_target)
@@ -461,25 +399,6 @@ endmacro(blt_add_uncrustify_target)
## SRC_FILES [FILE1 [FILE2 ...]] )
##
## Creates a new target with the given NAME for running astyle over the given SRC_FILES.
-##
-## MODIFY_FILES, if set to TRUE, modifies the files in place and adds the created target to
-## the style target. Otherwise the files are not modified and the created target is added
-## to the check target.
-## Note: Setting MODIFY_FILES to FALSE is only supported in AStyle v2.05 or greater.
-##
-## CFG_FILE defines the astyle settings.
-##
-## PREPEND_FLAGS are additional flags added to the front of the astyle flags.
-##
-## APPEND_FLAGS are additional flags added to the end of the astyle flags.
-##
-## COMMENT is prepended to CMake's output for this target.
-##
-## WORKING_DIRECTORY is the directory in which astyle will be run. It defaults to
-## the directory where this macro is called.
-##
-## SRC_FILES is a list of source files to style/check with astyle.
-##
##------------------------------------------------------------------------------
macro(blt_add_astyle_target)
@@ -525,6 +444,7 @@ macro(blt_add_astyle_target)
execute_process(
COMMAND ${ASTYLE_EXECUTABLE} --version
OUTPUT_VARIABLE _version_str
+ ERROR_VARIABLE _version_str
OUTPUT_STRIP_TRAILING_WHITESPACE )
string(REGEX MATCH "([0-9]+(\\.)?)+$" _astyle_version ${_version_str})
diff --git a/cmake/SetupCompilerOptions.cmake b/cmake/SetupCompilerOptions.cmake
index 0ae2e52fc..49d92c953 100644
--- a/cmake/SetupCompilerOptions.cmake
+++ b/cmake/SetupCompilerOptions.cmake
@@ -9,8 +9,8 @@
#####################################################
# Set some variables to simplify determining compiler
-# Compiler string list from:
-# https://cmake.org/cmake/help/v3.0/variable/CMAKE_LANG_COMPILER_ID.html
+# Compiler string list from:
+# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html
####################################################3
# use CMAKE_BUILD_TOOL to identify visual studio
@@ -46,6 +46,10 @@ else()
set(C_COMPILER_FAMILY_IS_PGI 1)
message(STATUS "C Compiler family is PGI")
+ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Cray")
+ set(C_COMPILER_FAMILY_IS_CRAY 1)
+ message(STATUS "C Compiler family is Cray")
+
else()
message(STATUS "C Compiler family not set!!!")
endif()
@@ -70,6 +74,10 @@ else()
set(Fortran_COMPILER_FAMILY_IS_PGI 1)
message(STATUS "Fortran Compiler family is PGI")
+ elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Cray")
+ set(Fortran_COMPILER_FAMILY_IS_CRAY 1)
+ message(STATUS "Fortran Compiler family is Cray")
+
elseif(ENABLE_FORTRAN)
message(STATUS "Fortran Compiler family not set!!!")
endif()
@@ -333,21 +341,42 @@ blt_append_custom_compiler_flag(
)
#
-# Modify flags to avoid static linking runtime issues on windows.
-# (adapted from RAJA)
+# Modify flags to avoid static linking runtime issues on MS Windows.
+#
+# When building on Windows, you can link in the runtime library
+# - statically (with /MT), or
+# - dynamically (with /MD).
+# See https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019.
+#
+# Mixing /MD with /MT can cause linking errors. CMake specifies
+# /MD when generating project files for MSVC and provides no way to
+# change this. This can be a problem with Google Test in particular,
+# which when building statically replaces all /MD with /MT. HDF5, on
+# the other hand, sternly warns against the use of /MT, even when
+# built statically.
+#
+# See https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace.
+# Once we require CMake >= 3.15 we can address the issue differently, using
+# CMAKE_MSVC_RUNTIME_LIBRARY:
+# https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html
#
if ( COMPILER_FAMILY_IS_MSVC AND NOT BUILD_SHARED_LIBS )
- foreach(_lang C CXX)
- foreach(_build
- FLAGS FLAGS_DEBUG FLAGS_RELEASE
- FLAGS_MINSIZEREL FLAGS_RELWITHDEBINFO)
- set(_flag CMAKE_${_lang}_${_build})
- if(${_flag} MATCHES "/MD")
- string(REGEX REPLACE "/MD" "/MT" ${_flag} "${${_flag}}")
- endif()
+ if ( BLT_ENABLE_MSVC_STATIC_MD_TO_MT )
+ foreach(_lang C CXX)
+ foreach(_build
+ FLAGS FLAGS_DEBUG FLAGS_RELEASE
+ FLAGS_MINSIZEREL FLAGS_RELWITHDEBINFO)
+ set(_flag CMAKE_${_lang}_${_build})
+ if(${_flag} MATCHES "/MD")
+ string(REGEX REPLACE "/MD" "/MT" ${_flag} "${${_flag}}")
+ endif()
+ endforeach()
endforeach()
- endforeach()
+ elseif (ENABLE_GTEST)
+ message(FATAL_ERROR
+ "For static linking with MS Visual Studio using GTEST, you must set BLT_ENABLE_MSVC_STATIC_MD_TO_MT to ON in order to enable changing /MD to /MT.")
+ endif()
endif()
set(langFlags "CMAKE_C_FLAGS" "CMAKE_CXX_FLAGS")
diff --git a/cmake/SetupDocs.cmake b/cmake/SetupDocs.cmake
index 813a07841..6b99b0769 100644
--- a/cmake/SetupDocs.cmake
+++ b/cmake/SetupDocs.cmake
@@ -2,31 +2,27 @@
# other BLT Project Developers. See the top-level COPYRIGHT file for details
#
# SPDX-License-Identifier: (BSD-3-Clause)
+#------------------------------------------------------------------------------
+# Sets up targets and macros associated with documentation
+#------------------------------------------------------------------------------
-add_custom_target(docs)
+add_custom_target(${BLT_DOCS_TARGET_NAME})
if(DOXYGEN_FOUND)
add_custom_target(doxygen_docs)
- add_dependencies(docs doxygen_docs)
+ add_dependencies(${BLT_DOCS_TARGET_NAME} doxygen_docs)
endif()
if(SPHINX_FOUND)
add_custom_target(sphinx_docs)
- add_dependencies(docs sphinx_docs)
+ add_dependencies(${BLT_DOCS_TARGET_NAME} sphinx_docs)
endif()
##------------------------------------------------------------------------------
-## - Macro for invoking doxygen to generate docs
-##
-## blt_add_doxygen_target(doxygen_target_name)
-##
-## Expects to find a Doxyfile.in in the directory the macro is called in.
-##
-## This macro sets up the doxygen paths so that the doc builds happen
-## out of source. For a make install, this will place the resulting docs in
-## docs/doxygen/`doxygen_target_name`
+## blt_add_doxygen_target(doxygen_target_name)
##
+## Creates a build target for invoking doxygen to generate docs
##------------------------------------------------------------------------------
macro(blt_add_doxygen_target doxygen_target_name)
@@ -48,23 +44,9 @@ endmacro(blt_add_doxygen_target)
##------------------------------------------------------------------------------
-## - Macro for invoking sphinx to generate docs
-##
-## blt_add_sphinx_target(sphinx_target_name)
-##
-## Expects to find a conf.py or conf.py.in in the directory the macro is
-## called in.
-##
-##
-## If conf.py is found, it is directly used as input to sphinx.
-##
-## If conf.py.in is found, this macro uses CMake's configure_file() command
-## to generate a conf.py, which is then used as input to sphinx.
-##
-## This macro sets up the sphinx paths so that the doc builds happen
-## out of source. For a make install, this will place the resulting docs in
-## docs/sphinx/`sphinx_target_name`
+## blt_add_sphinx_target(sphinx_target_name)
##
+## Creates a build target for invoking sphinx to generate docs
##------------------------------------------------------------------------------
macro(blt_add_sphinx_target sphinx_target_name )
diff --git a/cmake/thirdparty/SetupCUDA.cmake b/cmake/thirdparty/SetupCUDA.cmake
index 105661821..a574b920e 100644
--- a/cmake/thirdparty/SetupCUDA.cmake
+++ b/cmake/thirdparty/SetupCUDA.cmake
@@ -52,6 +52,12 @@ else()
endif()
endif()
+# Override rpath link flags for nvcc
+if (CUDA_LINK_WITH_NVCC)
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_CUDA_FLAG "-Xlinker -rpath -Xlinker " CACHE STRING "")
+ set(CMAKE_SHARED_LIBRARY_RPATH_LINK_CUDA_FLAG "-Xlinker -rpath -Xlinker " CACHE STRING "")
+endif()
+
############################################################
# Basics
@@ -70,7 +76,6 @@ endif ()
# FindMPI can break nvcc. In that case, you should set ENABLE_FIND_MPI to Off and control
# the link using CMAKE_CUDA_LINK_FLAGS. -Wl,-rpath, equivalent would be -Xlinker -rpath -Xlinker
if (CUDA_LINK_WITH_NVCC)
- set(CMAKE_SHARED_LIBRARY_RPATH_LINK_CUDA_FLAG "-Xlinker -rpath -Xlinker")
set(CMAKE_CUDA_LINK_EXECUTABLE
"${CMAKE_CUDA_COMPILER} -o ")
# do a no-op for the device links - for some reason the device link library dependencies are only a subset of the
diff --git a/cmake/thirdparty/SetupHIP.cmake b/cmake/thirdparty/SetupHIP.cmake
index 7abc5b5a6..cdc917553 100644
--- a/cmake/thirdparty/SetupHIP.cmake
+++ b/cmake/thirdparty/SetupHIP.cmake
@@ -32,7 +32,8 @@ set(HIP_RUNTIME_COMPILE_FLAGS "${HIP_RUNTIME_COMPILE_FLAGS};-D${HIP_RUNTIME_DEFI
# through a hip compiler (hipcc)
blt_register_library(NAME hip
INCLUDES ${HIP_INCLUDE_DIRS}
- LIBRARIES ${HIP_LIBRARIES})
+ LIBRARIES ${HIP_LIBRARIES}
+ TREAT_INCLUDES_AS_SYSTEM ON)
# depend on 'hip_runtime', if you only need to use hip
# headers or link to hip libs, but don't need to run your source
@@ -41,4 +42,5 @@ blt_register_library(NAME hip_runtime
INCLUDES ${HIP_RUNTIME_INCLUDE_DIRS}
DEFINES ${HIP_RUNTIME_DEFINES}
COMPILE_FLAGS ${HIP_RUNTIME_COMPILE_FLAGS}
- LIBRARIES ${HIP_RUNTIME_LIBRARIES})
+ LIBRARIES ${HIP_RUNTIME_LIBRARIES}
+ TREAT_INCLUDES_AS_SYSTEM ON)
diff --git a/cmake/thirdparty/SetupMPI.cmake b/cmake/thirdparty/SetupMPI.cmake
index 63079af5d..9c475fdfd 100644
--- a/cmake/thirdparty/SetupMPI.cmake
+++ b/cmake/thirdparty/SetupMPI.cmake
@@ -40,17 +40,35 @@ if (ENABLE_FIND_MPI)
# Merge found MPI info and remove duplication
#-------------------
# Compile flags
- list(APPEND _mpi_compile_flags ${MPI_C_${_mpi_compile_flags_suffix}})
- if (NOT "${MPI_C_${_mpi_compile_flags_suffix}}" STREQUAL
- "${MPI_CXX_${_mpi_compile_flags_suffix}}")
- list(APPEND _mpi_compile_flags ${MPI_CXX_${_mpi_compile_flags_suffix}})
+ set(_c_flag ${MPI_C_${_mpi_compile_flags_suffix}})
+ if (_c_flag AND ENABLE_CUDA)
+ list(APPEND _mpi_compile_flags
+ $<$>:${_c_flag}>
+ $<$:-Xcompiler=${_c_flag}>)
+ else()
+ list(APPEND _mpi_compile_flags ${_c_flag})
+ endif()
+
+ set(_cxx_flag ${MPI_CXX_${_mpi_compile_flags_suffix}})
+ if (_cxx_flag AND NOT "${_c_flag}" STREQUAL "${_cxx_flag}")
+ if (ENABLE_CUDA)
+ list(APPEND _mpi_compile_flags
+ $<$>:${_cxx_flag}>
+ $<$:-Xcompiler=${_cxx_flag}>)
+ else()
+ list(APPEND _mpi_compile_flags ${_cxx_flag})
+ endif()
endif()
+
if (ENABLE_FORTRAN)
- if (NOT "${MPI_C_${_mpi_compile_flags_suffix}}" STREQUAL
- "${MPI_Fortran_${_mpi_compile_flags_suffix}}")
- list(APPEND _mpi_compile_flags ${MPI_Fortran_${_mpi_compile_flags_suffix}})
+ set(_f_flag ${MPI_Fortran_${_mpi_compile_flags_suffix}})
+ if (_f_flag AND NOT "${c_flg}" STREQUAL "${_f_flag}")
+ list(APPEND _mpi_compile_flags ${_f_flag})
endif()
endif()
+ unset(_c_flag)
+ unset(_cxx_flag)
+ unset(_f_flag)
# Include paths
list(APPEND _mpi_includes ${MPI_C_${_mpi_includes_suffix}}
@@ -70,6 +88,15 @@ if (ENABLE_FIND_MPI)
list(APPEND _mpi_link_flags ${MPI_CXX_LINK_FLAGS})
endif()
endif()
+ # Fixes for linking with NVCC
+ if (CUDA_LINK_WITH_NVCC)
+ # Convert rpath flag if linking with CUDA
+ string(REPLACE "-Wl,-rpath," "-Xlinker -rpath -Xlinker "
+ _mpi_link_flags "${_mpi_link_flags}")
+ # -pthread just doesn't work with nvcc
+ string(REPLACE "-pthread" " "
+ _mpi_link_flags "${_mpi_link_flags}")
+ endif()
# Libraries
set(_mpi_libraries ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
diff --git a/cmake/thirdparty/SetupOpenMP.cmake b/cmake/thirdparty/SetupOpenMP.cmake
index 65ae0a909..1d7b617e8 100644
--- a/cmake/thirdparty/SetupOpenMP.cmake
+++ b/cmake/thirdparty/SetupOpenMP.cmake
@@ -10,19 +10,21 @@
find_package(OpenMP REQUIRED)
-# avoid generator expressions if possible, as generator expressions can be
-# passed as flags to downstream projects that might not be using the same
-# languages. See https://github.com/LLNL/blt/issues/205
-if (ENABLE_FORTRAN AND NOT OpenMP_CXX_FLAGS STREQUAL OpenMP_Fortran_FLAGS)
- set(ESCAPE_FORTRAN ON)
-else()
- set(ESCAPE_FORTRAN OFF)
+# check if the openmp flags used for C/C++ are different from the openmp flags
+# used by the Fortran compiler
+set(BLT_OPENMP_FLAGS_DIFFER FALSE CACHE BOOL "")
+if (ENABLE_FORTRAN)
+ string(COMPARE NOTEQUAL "${OpenMP_CXX_FLAGS}" "${OpenMP_Fortran_FLAGS}"
+ BLT_OPENMP_FLAGS_DIFFER )
endif()
+# avoid generator expressions if possible, as generator expressions can be
+# passed as flags to downstream projects that might not be using the same
+# languages. See https://github.com/LLNL/blt/issues/205
set(_compile_flags ${OpenMP_CXX_FLAGS})
set(_link_flags ${OpenMP_CXX_FLAGS})
-if(NOT COMPILER_FAMILY_IS_MSVC AND ENABLE_CUDA AND ESCAPE_FORTRAN)
+if(NOT COMPILER_FAMILY_IS_MSVC AND ENABLE_CUDA AND BLT_OPENMP_FLAGS_DIFFER)
set(_compile_flags
$<$>,$>>:${OpenMP_CXX_FLAGS}>
$<$:-Xcompiler=${OpenMP_CXX_FLAGS}>
@@ -31,7 +33,7 @@ elseif(NOT COMPILER_FAMILY_IS_MSVC AND ENABLE_CUDA)
set(_compile_flags
$<$>:${OpenMP_CXX_FLAGS}>
$<$:-Xcompiler=${OpenMP_CXX_FLAGS}>)
-elseif(NOT COMPILER_FAMILY_IS_MSVC AND ESCAPE_FORTRAN)
+elseif(NOT COMPILER_FAMILY_IS_MSVC AND BLT_OPENMP_FLAGS_DIFFER)
set(_compile_flags
$<$>:${OpenMP_CXX_FLAGS}>
$<$:${OpenMP_Fortran_FLAGS}>)
diff --git a/docs/api/code_check.rst b/docs/api/code_check.rst
new file mode 100644
index 000000000..b9b1cddf4
--- /dev/null
+++ b/docs/api/code_check.rst
@@ -0,0 +1,254 @@
+.. # Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+.. # other BLT Project Developers. See the top-level COPYRIGHT file for details
+.. #
+.. # SPDX-License-Identifier: (BSD-3-Clause)
+
+Code Check Macros
+==================
+
+blt_add_code_checks
+~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_code_checks( PREFIX
+ SOURCES [source1 [source2 ...]]
+ UNCRUSTIFY_CFG_FILE
+ ASTYLE_CFG_FILE
+ CPPCHECK_FLAGS )
+
+This macro adds all enabled code check targets for the given SOURCES.
+
+PREFIX
+ Prefix used for the created code check build targets. For example:
+ _uncrustify_check
+
+SOURCES
+ Source list that the code checks will be ran on
+
+UNCRUSTIFY_CFG_FILE
+ Path to Uncrustify config file
+
+ASTYLE_CFG_FILE
+ Path to AStyle config file
+
+CPPCHECK_FLAGS
+ List of flags added to Cppcheck
+
+Sources are filtered based on file extensions for use in these code checks. If you need
+additional file extensions defined add them to BLT_C_FILE_EXTS and BLT_Fortran_FILE_EXTS.
+Currently this macro only has code checks for C/C++ and simply filters out the Fortran files.
+
+This macro supports code formatting with either Uncrustify or AStyle (but not both at the same time)
+only if the following requirements are met:
+
+- Uncrustify
+
+ * UNCRUSTIFY_CFG_FILE is given
+ * UNCRUSTIFY_EXECUTABLE is defined and found prior to calling this macro
+
+- AStyle
+
+ * ASTYLE_CFG_FILE is given
+ * ASTYLE_EXECUTABLE is defined and found prior to calling this macro
+
+Enabled code formatting checks produce a `check` build target that will test to see if you
+are out of compliance with your code formatting and a `style` build target that will actually
+modify your source files. It also creates smaller child build targets that follow the pattern
+`__`.
+
+This macro supports the following static analysis tools with their requirements:
+
+- CppCheck
+
+ * CPPCHECK_EXECUTABLE is defined and found prior to calling this macro
+ * CPPCHECK_FLAGS added to the cppcheck command line before the sources
+
+- Clang-Query
+
+ * CLANGQUERY_EXECUTABLE is defined and found prior to calling this macro
+
+These are added as children to the `check` build target and produce child build targets
+that follow the pattern `__check`.
+
+blt_add_clang_query_target
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_clang_query_target( NAME
+ WORKING_DIRECTORY
+ COMMENT
+ CHECKERS
+ DIE_ON_MATCH
+ SRC_FILES [source1 [source2 ...]])
+
+Creates a new build target for running clang-query.
+
+NAME
+ Name of created build target
+
+WORKING_DIRECTORY
+ Directory in which the clang-query command is run. Defaults to where macro is called.
+
+COMMENT
+ Comment prepended to the build target output
+
+CHECKERS
+ list of checkers to be run by created build target
+
+DIE_ON_MATCH
+ Causes build failure on first clang-query match. Defaults to FALSE.S
+
+SRC_FILES
+ Source list that clang-query will be ran on
+
+Clang-query is a tool used for examining and matching the Clang AST. It is useful for enforcing
+coding standards and rules on your source code. A good primer on how to use clang-query can be
+found `here `_.
+
+Turning on DIE_ON_MATCH is useful if you're using this in CI to enforce rules about your code.
+
+CHECKERS are the static analysis passes to specifically run on the target. The following checker options
+can be given:
+
+ * (no value) : run all available static analysis checks found
+ * (checker1:checker2) : run checker1 and checker2
+ * (interpreter) : run the clang-query interpeter to interactively develop queries
+
+
+blt_add_cppcheck_target
+~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_cppcheck_target( NAME
+ WORKING_DIRECTORY
+ PREPEND_FLAGS
+ APPEND_FLAGS
+ COMMENT
+ SRC_FILES [source1 [source2 ...]] )
+
+Creates a new build target for running cppcheck
+
+NAME
+ Name of created build target
+
+WORKING_DIRECTORY
+ Directory in which the clang-query command is run. Defaults to where macro is called.
+
+PREPEND_FLAGS
+ Additional flags added to the front of the cppcheck flags
+
+APPEND_FLAGS
+ Additional flags added to the end of the cppcheck flags
+
+COMMENT
+ Comment prepended to the build target output
+
+SRC_FILES
+ Source list that cppcheck will be ran on
+
+Cppcheck is a static analysis tool for C/C++ code. More information about
+Cppcheck can be found `here `_.
+
+blt_add_uncrustify_target
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_uncrustify_target( NAME
+ MODIFY_FILES [TRUE | FALSE (default)]
+ CFG_FILE
+ PREPEND_FLAGS
+ APPEND_FLAGS
+ COMMENT
+ WORKING_DIRECTORY
+ SRC_FILES [source1 [source2 ...]] )
+
+Creates a new build target for running Uncrustify
+
+NAME
+ Name of created build target
+
+MODIFY_FILES
+ Modify the files in place. Defaults to FALSE.
+
+CFG_FILE
+ Path to Uncrustify config file
+
+PREPEND_FLAGS
+ Additional flags added to the front of the Uncrustify flags
+
+APPEND_FLAGS
+ Additional flags added to the end of the Uncrustify flags
+
+COMMENT
+ Comment prepended to the build target output
+
+WORKING_DIRECTORY
+ Directory in which the Uncrustify command is run. Defaults to where macro is called.
+
+SRC_FILES
+ Source list that Uncrustify will be ran on
+
+Uncrustify is a Source Code Beautifier for C/C++ code. More information about
+Uncrustify can be found `here `_.
+
+When MODIFY_FILES is set to TRUE, modifies the files in place and adds the created build
+target to the parent `style` build target. Otherwise the files are not modified and the
+created target is added to the parent `check` build target. This target will notify you
+which files do not conform to your style guide.
+.. Note::
+ Setting MODIFY_FILES to FALSE is only supported in Uncrustify v0.61 or greater.
+
+
+blt_add_astyle_target
+~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_astyle_target( NAME
+ MODIFY_FILES [TRUE | FALSE (default)]
+ CFG_FILE
+ PREPEND_FLAGS
+ APPEND_FLAGS
+ COMMENT
+ WORKING_DIRECTORY
+ SRC_FILES [FILE1 [FILE2 ...]] )
+
+Creates a new build target for running AStyle
+
+NAME
+ Name of created build target
+
+MODIFY_FILES
+ Modify the files in place. Defaults to FALSE.
+
+CFG_FILE
+ Path to AStyle config file
+
+PREPEND_FLAGS
+ Additional flags added to the front of the AStyle flags
+
+APPEND_FLAGS
+ Additional flags added to the end of the AStyle flags
+
+COMMENT
+ Comment prepended to the build target output
+
+WORKING_DIRECTORY
+ Directory in which the AStyle command is run. Defaults to where macro is called.
+
+SRC_FILES
+ Source list that AStyle will be ran on
+
+AStyle is a Source Code Beautifier for C/C++ code. More information about
+AStyle can be found `here `_.
+
+When MODIFY_FILES is set to TRUE, modifies the files in place and adds the created build
+target to the parent `style` build target. Otherwise the files are not modified and the
+created target is added to the parent `check` build target. This target will notify you
+which files do not conform to your style guide.
+.. Note::
+ Setting MODIFY_FILES to FALSE is only supported in AStyle v2.05 or greater.
diff --git a/docs/api/documentation.rst b/docs/api/documentation.rst
new file mode 100644
index 000000000..f1b521cd9
--- /dev/null
+++ b/docs/api/documentation.rst
@@ -0,0 +1,42 @@
+.. # Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+.. # other BLT Project Developers. See the top-level COPYRIGHT file for details
+.. #
+.. # SPDX-License-Identifier: (BSD-3-Clause)
+
+Documenation Macros
+===================
+
+
+blt_add_doxygen_target
+~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_doxygen_target(doxygen_target_name)
+
+Creates a build target for invoking doxygen to generate docs. Expects to
+find a Doxyfile.in in the directory the macro is called in.
+
+This macro sets up the doxygen paths so that the doc builds happen
+out of source. For ``make install``, this will place the resulting docs in
+docs/doxygen/.
+
+
+blt_add_sphinx_target
+~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_sphinx_target(sphinx_target_name)
+
+Creates a build target for invoking sphinx to generate docs. Expects to
+find a conf.py or conf.py.in in the directory the macro is called in.
+
+If conf.py is found, it is directly used as input to sphinx.
+
+If conf.py.in is found, this macro uses CMake's configure_file() command
+to generate a conf.py, which is then used as input to sphinx.
+
+This macro sets up the sphinx paths so that the doc builds happen
+out of source. For ``make install``, this will place the resulting docs in
+docs/sphinx/.
diff --git a/docs/api/git.rst b/docs/api/git.rst
new file mode 100644
index 000000000..dade2986d
--- /dev/null
+++ b/docs/api/git.rst
@@ -0,0 +1,183 @@
+.. # Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+.. # other BLT Project Developers. See the top-level COPYRIGHT file for details
+.. #
+.. # SPDX-License-Identifier: (BSD-3-Clause)
+
+Git Macros
+==========
+
+
+blt_git
+~~~~~~~
+
+.. code-block:: cmake
+
+ blt_git(SOURCE_DIR
+ GIT_COMMAND
+ OUTPUT_VARIABLE
+ RETURN_CODE
+ [QUIET] )
+
+Runs the supplied git command on the given Git repository.
+
+This macro runs the user-supplied Git command, given by GIT_COMMAND, on the
+given Git repository corresponding to SOURCE_DIR. The supplied GIT_COMMAND
+is just a string consisting of the Git command and its arguments. The
+resulting output is returned to the supplied CMake variable provided by
+the OUTPUT_VARIABLE argument.
+
+A return code for the Git command is returned to the caller via the CMake
+variable provided with the RETURN_CODE argument. A non-zero return code
+indicates that an error has occured.
+
+Note, this macro assumes FindGit() was invoked and was successful. It relies
+on the following variables set by FindGit():
+
+ * Git_FOUND flag that indicates if git is found
+ * GIT_EXECUTABLE points to the Git binary
+
+If Git_FOUND is "false" this macro will throw a FATAL_ERROR message.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ blt_git( SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+ GIT_COMMAND describe --tags master
+ OUTPUT_VARIABLE axom_tag
+ RETURN_CODE rc )
+ if (NOT ${rc} EQUAL 0)
+ message( FATAL_ERROR "blt_git failed!" )
+ endif()
+
+
+blt_is_git_repo
+~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_is_git_repo(OUTPUT_STATE
+ [SOURCE_DIR ] )
+
+Checks if we are working with a valid Git repository.
+
+This macro checks if the corresponding source directory is a valid Git repo.
+Nominally, the corresponding source directory that is used is set to
+${CMAKE_CURRENT_SOURCE_DIR}. A different source directory may be optionally
+specified using the SOURCE_DIR argument.
+
+The resulting state is stored in the CMake variable specified by the caller
+using the OUTPUT_STATE parameter.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ blt_is_git_repo( OUTTPUT_STATE is_git_repo )
+ if ( ${is_git_repo} )
+ message(STATUS "Pointing to a valid Git repo!")
+ else()
+ message(STATUS "Not a Git repo!")
+ endif()
+
+
+blt_git_tag
+~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_git_tag( OUTPUT_TAG
+ RETURN_CODE
+ [SOURCE_DIR ]
+ [ON_BRANCH ] )
+
+Returns the latest tag on a corresponding Git repository.
+
+This macro gets the latest tag from a Git repository that can be specified
+via the SOURCE_DIR argument. If SOURCE_DIR is not supplied, the macro will
+use ${CMAKE_CURRENT_SOURCE_DIR}. By default the macro will return the latest
+tag on the branch that is currently checked out. A particular branch may be
+specified using the ON_BRANCH option.
+
+The tag is stored in the CMake variable specified by the caller using the
+the OUTPUT_TAG parameter.
+
+A return code for the Git command is returned to the caller via the CMake
+variable provided with the RETURN_CODE argument. A non-zero return code
+indicates that an error has occured.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ blt_git_tag( OUTPUT_TAG tag RETURN_CODE rc ON_BRANCH master )
+ if ( NOT ${rc} EQUAL 0 )
+ message( FATAL_ERROR "blt_git_tag failed!" )
+ endif()
+ message( STATUS "tag=${tag}" )
+
+
+blt_git_branch
+~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_git_branch( BRANCH_NAME
+ RETURN_CODE
+ [SOURCE_DIR ] )
+
+Returns the name of the active branch in the checkout space.
+
+This macro gets the name of the current active branch in the checkout space
+that can be specified using the SOURCE_DIR argument. If SOURCE_DIR is not
+supplied by the caller, this macro will point to the checkout space
+corresponding to ${CMAKE_CURRENT_SOURCE_DIR}.
+
+A return code for the Git command is returned to the caller via the CMake
+variable provided with the RETURN_CODE argument. A non-zero return code
+indicates that an error has occured.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ blt_git_branch( BRANCH_NAME active_branch RETURN_CODE rc )
+ if ( NOT ${rc} EQUAL 0 )
+ message( FATAL_ERROR "blt_git_tag failed!" )
+ endif()
+ message( STATUS "active_branch=${active_branch}" )
+
+
+blt_git_hashcode
+~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_git_hashcode( HASHCODE
+ RETURN_CODE
+ [SOURCE_DIR ]
+ [ON_BRANCH ])
+
+Returns the SHA-1 hashcode at the tip of a branch.
+
+This macro returns the SHA-1 hashcode at the tip of a branch that may be
+specified with the ON_BRANCH argument. If the ON_BRANCH argument is not
+supplied, the macro will return the SHA-1 hash at the tip of the current
+branch. In addition, the caller may specify the target Git repository using
+the SOURCE_DIR argument. Otherwise, if SOURCE_DIR is not specified, the
+macro will use ${CMAKE_CURRENT_SOURCE_DIR}.
+
+A return code for the Git command is returned to the caller via the CMake
+variable provided with the RETURN_CODE argument. A non-zero return code
+indicates that an error has occured.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ blt_git_hashcode( HASHCODE sha1 RETURN_CODE rc )
+ if ( NOT ${rc} EQUAL 0 )
+ message( FATAL_ERROR "blt_git_hashcode failed!" )
+ endif()
+ message( STATUS "sha1=${sha1}" )
+
diff --git a/docs/api/index.rst b/docs/api/index.rst
new file mode 100644
index 000000000..cee8969f4
--- /dev/null
+++ b/docs/api/index.rst
@@ -0,0 +1,17 @@
+.. # Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+.. # other BLT Project Developers. See the top-level COPYRIGHT file for details
+.. #
+.. # SPDX-License-Identifier: (BSD-3-Clause)
+
+API Documentation
+=================
+
+.. toctree::
+ :maxdepth: 3
+
+ target
+ target_properties
+ utility
+ git
+ code_check
+ documentation
diff --git a/docs/api/target.rst b/docs/api/target.rst
new file mode 100644
index 000000000..cb0eb517c
--- /dev/null
+++ b/docs/api/target.rst
@@ -0,0 +1,283 @@
+.. # Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+.. # other BLT Project Developers. See the top-level COPYRIGHT file for details
+.. #
+.. # SPDX-License-Identifier: (BSD-3-Clause)
+
+Target Macros
+=============
+
+.. _blt_add_benchmark:
+
+blt_add_benchmark
+~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_benchmark( NAME [name]
+ COMMAND [command]
+ NUM_MPI_TASKS [n])
+
+Adds a benchmark to the project.
+
+NAME
+ Name that CTest reports.
+
+COMMAND
+ Command line that will be used to run the test and can include arguments.
+
+NUM_MPI_TASKS
+ Indicates this is an MPI test and how many MPI tasks to use.
+
+This macro adds a benchmark test to the ``Benchmark`` CTest configuration
+which can be run by the ``run_benchmarks`` build target. These tests are
+not run when you use the regular ``test`` build target.
+
+This macro is just a thin wrapper around :ref:`blt_add_test` and assists
+with building up the correct command line for running the benchmark. For more
+information see :ref:`blt_add_test`.
+
+The underlying executable should be previously added to the build system
+with :ref:`blt_add_executable`. It should include the necessary benchmarking
+library in its DEPENDS_ON list.
+
+Any calls to this macro should be guarded with ENABLE_BENCHMARKS unless this option
+is always on in your build project.
+
+.. note::
+ BLT provides a built-in Google Benchmark that is enabled by default if you set
+ ENABLE_BENCHMARKS=ON and can be turned off with the option ENABLE_GBENCHMARK.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ if(ENABLE_BENCHMARKS)
+ blt_add_executable(NAME component_benchmark
+ SOURCES my_benchmark.cpp
+ DEPENDS gbenchmark)
+ blt_add_benchmark(
+ NAME component_benchmark
+ COMMAND component_benchmark "--benchmark_min_time=0.0 --v=3 --benchmark_format=json")
+ endif()
+
+.. _blt_add_executable:
+
+blt_add_executable
+~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_executable( NAME
+ SOURCES [source1 [source2 ...]]
+ INCLUDES [dir1 [dir2 ...]]
+ DEFINES [define1 [define2 ...]]
+ DEPENDS_ON [dep1 [dep2 ...]]
+ OUTPUT_DIR [dir]
+ FOLDER [name])
+
+Adds an executable target, called , to be built from the given sources.
+
+The INCLUDES argument allows you to define what include directories are
+needed to compile this executable.
+
+The DEFINES argument allows you to add needed compiler definitions that are
+needed to compile this executable.
+
+If given a DEPENDS_ON argument, it will add the necessary includes and
+libraries if they are already registered with blt_register_library. If
+not it will add them as a cmake target dependency.
+
+The OUTPUT_DIR is used to control the build output directory of this
+executable. This is used to overwrite the default bin directory.
+
+If the first entry in SOURCES is a Fortran source file, the fortran linker
+is used. (via setting the CMake target property LINKER_LANGUAGE to Fortran )
+FOLDER is an optional keyword to organize the target into a folder in an IDE.
+
+This is available when ENABLE_FOLDERS is ON and when using a cmake generator
+that supports this feature and will otherwise be ignored.
+
+
+.. _blt_add_library:
+
+blt_add_library
+~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_library( NAME
+ SOURCES [source1 [source2 ...]]
+ HEADERS [header1 [header2 ...]]
+ INCLUDES [dir1 [dir2 ...]]
+ DEFINES [define1 [define2 ...]]
+ DEPENDS_ON [dep1 ...]
+ OUTPUT_NAME [name]
+ OUTPUT_DIR [dir]
+ SHARED [TRUE | FALSE]
+ OBJECT [TRUE | FALSE]
+ CLEAR_PREFIX [TRUE | FALSE]
+ FOLDER [name])
+
+Adds a library target, called , to be built from the given sources.
+
+This macro uses the BUILD_SHARED_LIBS, which is defaulted to OFF, to determine
+whether the library will be build as shared or static. The optional boolean
+SHARED argument can be used to override this choice.
+
+The OBJECT argument creates a CMake object library. Basically it is a collection
+of compiled source files that are not archived or linked. Unlike regular CMake
+object libraries you do not have to use the $> syntax,
+you can just use .
+
+Note: Object libraries do not follow CMake's transitivity rules until 3.12.
+BLT will add the various information provided in this macro and its
+dependencies in the order you provide them to help.
+
+The INCLUDES argument allows you to define what include directories are
+needed by any target that is dependent on this library. These will
+be inherited by CMake's target dependency rules.
+
+The DEFINES argument allows you to add needed compiler definitions that are
+needed by any target that is dependent on this library. These will
+be inherited by CMake's target dependency rules.
+
+If given a DEPENDS_ON argument, it will add the necessary includes and
+libraries if they are already registered with blt_register_library. If
+not it will add them as a CMake target dependency.
+
+In addition, this macro will add the associated dependencies to the given
+library target. Specifically, it will add the dependency for the CMake target
+and for copying the headers for that target as well.
+
+The OUTPUT_DIR is used to control the build output directory of this
+library. This is used to overwrite the default lib directory.
+OUTPUT_NAME is the name of the output file; the default is NAME.
+
+It's useful when multiple libraries with the same name need to be created
+by different targets. NAME is the target name, OUTPUT_NAME is the library name.
+CLEAR_PREFIX allows you to remove the automatically appended "lib" prefix
+from your built library. The created library will be foo.a instead of libfoo.a.
+FOLDER is an optional keyword to organize the target into a folder in an IDE.
+
+This is available when ENABLE_FOLDERS is ON and when the cmake generator
+supports this feature and will otherwise be ignored.
+
+Note: Do not use with header-only (INTERFACE) libraries, as this will generate
+a CMake configuration error.
+
+
+.. _blt_add_test:
+
+blt_add_test
+~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_test( NAME [name]
+ COMMAND [command]
+ NUM_MPI_TASKS [n]
+ NUM_OMP_THREADS [n]
+ CONFIGURATIONS [config1 [config2...]])
+
+Adds a test to the project.
+
+NAME
+ Name that CTest reports.
+
+COMMAND
+ Command line that will be used to run the test and can include arguments.
+
+NUM_MPI_TASKS
+ Indicates this is an MPI test and how many MPI tasks to use.
+
+NUM_OMP_THREADS
+ Indicates this test requires the defined environment variable OMP_NUM_THREADS set to the given variable.
+
+CONFIGURATIONS
+ Set the CTest configuration for this test. When not specified, the test
+ will be added to the default CTest configuration.
+
+This macro adds the named test to CTest, which is run by the build target ``test``. This macro
+does not build the executable and requires a prior call to :ref:`blt_add_executable`.
+
+This macro assists with building up the correct command line. It will prepend
+the RUNTIME_OUTPUT_DIRECTORY target property to the executable.
+
+If NUM_MPI_TASKS is given or ENABLE_WRAP_ALL_TESTS_WITH_MPIEXEC is set, the macro
+will appropiately use MPIEXEC, MPIEXEC_NUMPROC_FLAG, and BLT_MPI_COMMAND_APPEND
+to create the MPI run line.
+
+MPIEXEC and MPIEXEC_NUMPROC_FLAG are filled in by CMake's FindMPI.cmake but can
+be overwritten in your host-config specific to your platform. BLT_MPI_COMMAND_APPEND
+is useful on machines that require extra arguments to MPIEXEC.
+
+If NUM_OMP_THREADS is given, this macro will set the environment variable OMP_NUM_THREADS
+before running this test. This is done by appending to the CMake tests property.
+
+.. note::
+ If you do not require this macros command line assistance, you can call CMake's
+ ``add_test()`` directly. For example, you may have a script checked into your
+ repository you wish to run as a test instead of an executable you built as a part
+ of your build system.
+
+Any calls to this macro should be guarded with ENABLE_TESTS unless this option
+is always on in your build project.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ if (ENABLE_TESTS)
+ blt_add_executable(NAME my_test
+ SOURCES my_test.cpp)
+ blt_add_test(NAME my_test
+ COMMAND my_test --with-some-argument)
+ endif()
+
+
+.. _blt_register_library:
+
+blt_register_library
+~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_register_library( NAME
+ DEPENDS_ON [dep1 [dep2 ...]]
+ INCLUDES [include1 [include2 ...]]
+ TREAT_INCLUDES_AS_SYSTEM [ON|OFF]
+ FORTRAN_MODULES [path1 [path2 ..]]
+ LIBRARIES [lib1 [lib2 ...]]
+ COMPILE_FLAGS [flag1 [flag2 ..]]
+ LINK_FLAGS [flag1 [flag2 ..]]
+ DEFINES [def1 [def2 ...]] )
+
+Registers a library to the project to ease use in other BLT macro calls.
+
+Stores information about a library in a specific way that is easily recalled
+in other macros. For example, after registering gtest, you can add gtest to
+the DEPENDS_ON in your blt_add_executable call and it will add the INCLUDES
+and LIBRARIES to that executable.
+
+TREAT_INCLUDES_AS_SYSTEM informs the compiler to treat this library's include paths
+as system headers. Only some compilers support this. This is useful if the headers
+generate warnings you want to not have them reported in your build. This defaults
+to OFF.
+
+This does not actually build the library. This is strictly to ease use after
+discovering it on your system or building it yourself inside your project.
+
+Note: The OBJECT parameter is for internal BLT support for object libraries
+and is not for users. Object libraries are created using blt_add_library().
+
+Internally created variables (NAME = "foo"):
+ | BLT_FOO_IS_REGISTERED_LIBRARY
+ | BLT_FOO_IS_OBJECT_LIBRARY
+ | BLT_FOO_DEPENDS_ON
+ | BLT_FOO_INCLUDES
+ | BLT_FOO_TREAT_INCLUDES_AS_SYSTEM
+ | BLT_FOO_FORTRAN_MODULES
+ | BLT_FOO_LIBRARIES
+ | BLT_FOO_COMPILE_FLAGS
+ | BLT_FOO_LINK_FLAGS
+ | BLT_FOO_DEFINES
diff --git a/docs/api/target_properties.rst b/docs/api/target_properties.rst
new file mode 100644
index 000000000..be34158f6
--- /dev/null
+++ b/docs/api/target_properties.rst
@@ -0,0 +1,191 @@
+.. # Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+.. # other BLT Project Developers. See the top-level COPYRIGHT file for details
+.. #
+.. # SPDX-License-Identifier: (BSD-3-Clause)
+
+Target Property Macros
+======================
+
+
+blt_add_target_compile_flags
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_target_compile_flags( TO
+ SCOPE
+ FLAGS [FOO [BAR ...]])
+
+Appends compiler flags to a CMake target by appending to the target's existing flags.
+
+TO
+ Name of CMake target
+
+SCOPE
+ Defines the scope of the given flags. Defaults to PUBLIC and is case insensitive.
+
+FLAGS
+ List of compile flags
+
+This macro provides very similar functionality to CMake's native
+``add_compile_options`` and ``target_compile_options`` commands, but
+provides more fine-grained scoping for the compile flags on a
+per target basis.
+
+The given target must be added via CMake's ``add_executable`` or ``add_library`` commands
+or with the corresponding ``blt_add_executable`` and ``blt_add_library`` macros.
+
+PRIVATE flags are used for the given target. INTERFACE flags are inherited
+by any target that depends on this target. PUBLIC flags are both INTERFACE and PRIVATE.
+
+.. note::
+ This macro will strip away leading and trailing whitespace from each flag.
+
+
+blt_add_target_definitions
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_target_definitions( TO
+ SCOPE
+ TARGET_DEFINITIONS [FOO [BAR ...]])
+
+Appends pre-processor definitions to the given target's existing flags.
+
+TO
+ Name of CMake target
+
+SCOPE
+ Defines the scope of the given definitions. Defaults to PUBLIC and is case insensitive.
+
+FLAGS
+ List of definitions flags
+
+This macro provides very similar functionality to CMake's native
+``add_definitions`` and ``target_add_defintions`` commands, but provides
+more fine-grained scoping for the compile definitions on a per target basis.
+Given a list of definitions, e.g., FOO and BAR, this macro adds compiler
+definitions to the compiler command for the given target, i.e., it will pass
+-DFOO and -DBAR.
+
+The given target must be added via CMake's ``add_executable`` or ``add_library`` commands
+or with the corresponding ``blt_add_executable`` and ``blt_add_library`` macros.
+
+PRIVATE flags are used for the given target. INTERFACE flags are inherited
+by any target that depends on this target. PUBLIC flags are both INTERFACE and PRIVATE.
+
+.. note::
+ The target definitions can either include or omit the "-D" characters.
+ E.g. the following are all valid ways to add two compile definitions
+ (A=1 and B) to target 'foo'.
+
+.. note::
+ This macro will strip away leading and trailing whitespace from each definition.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ blt_add_target_definitions(TO foo TARGET_DEFINITIONS A=1 B)
+ blt_add_target_definitions(TO foo TARGET_DEFINITIONS -DA=1 -DB)
+ blt_add_target_definitions(TO foo TARGET_DEFINITIONS "A=1;-DB")
+ blt_add_target_definitions(TO foo TARGET_DEFINITIONS " " -DA=1;B)
+
+
+blt_add_target_link_flags
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_add_target_link_flags( TO
+ SCOPE
+ FLAGS [FOO [BAR ...]])
+
+Appends linker flags to a the given target's existing flags.
+
+TO
+ Name of CMake target
+
+SCOPE
+ Defines the scope of the given flags. Defaults to PUBLIC and is case insensitive.
+
+FLAGS
+ List of linker flags
+
+This macro provides very similar functionality to CMake's native
+``add_link_options`` and ``target_link_options`` commands, but provides
+more fine-grained scoping for the compile definitions on a per target basis.
+
+The given target must be added via CMake's ``add_executable`` or ``add_library`` commands
+or with the corresponding ``blt_add_executable`` and ``blt_add_library`` macros.
+
+PRIVATE flags are used for the given target. INTERFACE flags are inherited
+by any target that depends on this target. PUBLIC flags are both INTERFACE and PRIVATE.
+
+If `CUDA_LINK_WITH_NVCC` is set to ON, this macro will automatically convert
+"-Wl,-rpath," to "-Xlinker -rpath -Xlinker ".
+
+.. note::
+ This macro also handles the various changes that CMake made in 3.13. For example,
+ the target property LINK_FLAGS was changes to LINK_OPTIONS and was changed from a
+ string to a list. New versions now support Generator Expressions. Also pre-3.13,
+ there were no macros to add link flags to targets so we do this by setting the properties
+ directly.
+
+.. note::
+ In CMake versions prior to 3.13, this list is converted to a string internally
+ and any ; characters will be removed.
+
+.. note::
+ In CMake versions 3.13 and above, this list is prepended with "SHELL:" which stops
+ CMake from de-duplicating flags. This is especially bad when linking with NVCC when
+ you have groups of flags like "-Xlinker -rpath -Xlinker ".
+
+
+blt_print_target_properties
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_print_target_properties(TARGET )
+
+Prints out all properties of the given target.
+
+TARGET
+ Name of CMake target
+
+The given target must be added via ``add_executable`` or ``add_library`` or
+with the corresponding ``blt_add_executable``, ``blt_add_library``, or
+``blt_register_library`` macros.
+
+Output is of the form for each property:
+ | [ property] :
+
+
+blt_set_target_folder
+~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_set_target_folder( TARGET
+ FOLDER )
+
+Sets the FOLDER property of the given CMake target.
+
+TARGET
+ Name of CMake target
+
+FOLDER
+ Name of the folder
+
+This is used to organize properties in an IDE.
+
+This feature is only available when BLT's `ENABLE_FOLDERS` option is ON and
+in CMake generators that support folders (but is safe to call regardless
+of the generator or value of ENABLE_FOLDERS).
+
+.. note::
+ Do not use this macro on header-only (INTERFACE) library targets, since
+ this will generate a CMake configuration error.
+
diff --git a/docs/api/utility.rst b/docs/api/utility.rst
new file mode 100644
index 000000000..f462e00d7
--- /dev/null
+++ b/docs/api/utility.rst
@@ -0,0 +1,124 @@
+.. # Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+.. # other BLT Project Developers. See the top-level COPYRIGHT file for details
+.. #
+.. # SPDX-License-Identifier: (BSD-3-Clause)
+
+Utility Macros
+==============
+
+
+blt_append_custom_compiler_flag
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_append_custom_compiler_flag(
+ FLAGS_VAR flagsVar (required)
+ DEFAULT defaultFlag (optional)
+ GNU gnuFlag (optional)
+ CLANG clangFlag (optional)
+ HCC hccFlag (optional)
+ INTEL intelFlag (optional)
+ XL xlFlag (optional)
+ MSVC msvcFlag (optional)
+ MSVC_INTEL msvcIntelFlag (optional)
+ PGI pgiFlag (optional)
+ CRAY crayFlag (optional))
+
+Appends compiler-specific flags to a given variable of flags
+
+If a custom flag is given for the current compiler, we use that.
+Otherwise, we will use the DEFAULT flag (if present).
+
+If ENABLE_FORTRAN is On, any flagsVar with "fortran" (any capitalization)
+in its name will pick the compiler family (GNU,CLANG, INTEL, etc) based on
+the fortran compiler family type. This allows mixing C and Fortran compiler
+families, e.g. using Intel fortran compilers with clang C compilers.
+
+When using the Intel toolchain within visual studio, we use the
+MSVC_INTEL flag, when provided, with a fallback to the MSVC flag.
+
+
+blt_find_libraries
+~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_find_libraries( FOUND_LIBS
+ NAMES [libname1 [libname2 ...]]
+ REQUIRED [TRUE (default) | FALSE ]
+ PATHS [path1 [path2 ...]])
+
+This command is used to find a list of libraries.
+
+If the libraries are found the results are appended to the given FOUND_LIBS variable name.
+NAMES lists the names of the libraries that will be searched for in the given PATHS.
+
+If REQUIRED is set to TRUE, BLT will produce an error message if any of the
+given libraries are not found. The default value is TRUE.
+
+PATH lists the paths in which to search for NAMES. No system paths will be searched.
+
+
+blt_list_append
+~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_list_append(TO
+ ELEMENTS [...]
+ IF )
+
+Appends elements to a list if the specified bool evaluates to true.
+
+This macro is essentially a wrapper around CMake's ``list(APPEND ...)``
+command which allows inlining a conditional check within the same call
+for clarity and convenience.
+
+This macro requires specifying:
+
+ * The target list to append to by passing ``TO ``
+ * A condition to check by passing ``IF ``
+ * The list of elements to append by passing ``ELEMENTS [...]``
+
+Note, the argument passed to the IF option has to be a single boolean value
+and cannot be a boolean expression since CMake cannot evaluate those inline.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ set(mylist A B)
+
+ set(ENABLE_C TRUE)
+ blt_list_append( TO mylist ELEMENTS C IF ${ENABLE_C} ) # Appends 'C'
+
+ set(ENABLE_D TRUE)
+ blt_list_append( TO mylist ELEMENTS D IF ENABLE_D ) # Appends 'D'
+
+ set(ENABLE_E FALSE)
+ blt_list_append( TO mylist ELEMENTS E IF ENABLE_E ) # Does not append 'E'
+
+ unset(_undefined)
+ blt_list_append( TO mylist ELEMENTS F IF _undefined ) # Does not append 'F'
+
+
+blt_list_remove_duplicates
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: cmake
+
+ blt_list_remove_duplicates(TO )
+
+Removes duplicate elements from the given TO list.
+
+This macro is essentially a wrapper around CMake's ``list(REMOVE_DUPLICATES ...)``
+command but doesn't throw an error if the list is empty or not defined.
+
+.. code-block:: cmake
+ :caption: **Example**
+ :linenos:
+
+ set(mylist A B A)
+ blt_list_remove_duplicates( TO mylist )
+
diff --git a/docs/conf.py b/docs/conf.py
index 666b4bbae..1134ebf06 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -46,8 +46,8 @@
master_doc = 'index'
# General information about the project.
-project = u'BLT Tutorial Guide'
-copyright = u'2017, BLT Development Team'
+project = u'BLT: Build, Link, and Test'
+copyright = u'2017-2019, BLT Development Team'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -221,4 +221,4 @@
man_pages = [
('index', 'blttutorialguide', u'BLT Tutorial Guide',
[u'BLT Team'], 1)
-]
\ No newline at end of file
+]
diff --git a/docs/index.rst b/docs/index.rst
index 531639dad..aad69cf40 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -6,22 +6,23 @@
BLT
===
-**Build, Link and Test**
+**Build, Link, and Test**
-BLT is composition of CMake macros and several widely used open source tools assembled to simplify HPC software development.
+BLT is a composition of CMake macros and several widely used open source tools
+assembled to simplify HPC software development.
BLT was released by Lawrence Livermore National Laboratory (LLNL) under a BSD-style open source license.
It is developed on github under LLNL's github organization: https://github.com/llnl/blt
.. note::
BLT officially supports CMake 3.8 and above. However we only print a warning if you
- are below our this version. Some features may or may not work. Use at your own risk.
+ are below this version. Some features in earlier versions may or may not work. Use at your own risk.
BLT at a Glance
~~~~~~~~~~~~~~~~~~
-* Simplifies Setup
+* Simplifies setting up a CMake-based build system
* CMake macros for:
@@ -43,9 +44,8 @@ BLT at a Glance
* Runtime and static analysis, benchmarking
-BLT Developers
-~~~~~~~~~~~~~~~~~~~
-Developers include:
+Developers
+~~~~~~~~~~
* Chris White (white238@llnl.gov)
* Cyrus Harrison (harrison37@llnl.gov)
@@ -56,40 +56,14 @@ Developers include:
* David A. Beckingsale (beckingsale1@llnl.gov)
* Richard Hornung (hornung1@llnl.gov)
* Randolph Settgast (settgast1@llnl.gov)
- * Peter Robinson (robinson96@llnl.gov)
+ * Peter Robinson (robinson96@llnl.gov)
-BLT User Tutorial
-~~~~~~~~~~~~~~~~~~~
-This tutorial is aimed at getting BLT users up and running as quickly as possible.
-It provides instructions for:
-
- * Adding BLT to a CMake project
- * Setting up *host-config* files to handle multiple platform configurations
- * Building, linking, and installing libraries and executables
- * Setting up unit tests with GTest
- * Using external project dependencies
- * Creating documentation with Sphinx and Doxygen
-
-The tutorial provides several examples that calculate the value of :math:`\pi`
-by approximating the integral :math:`f(x) = \int_0^14/(1+x^2)` using numerical
-integration. The code is adapted from:
-https://www.mcs.anl.gov/research/projects/mpi/usingmpi/examples-usingmpi/simplempi/cpi_c.html.
-
-The tutorial requires a C++ compiler and CMake, we recommend using CMake 3.8.0 or newer. Parts of the tutorial also require MPI, CUDA, Sphinx and Doxygen.
-
-
-**Tutorial Contents**
+Documentation
+~~~~~~~~~~~~~
.. toctree::
- :maxdepth: 3
-
- setup_blt
- creating_execs_and_libs
- using_flags
- unit_testing
- external_dependencies
- creating_documentation
- recommendations
-
+ :maxdepth: 2
+ User Tutorial
+ API Documentation
diff --git a/docs/tutorial/blank_project/CMakeLists.txt b/docs/tutorial/blank_project/CMakeLists.txt
index 8e8ffd048..5cb199f71 100644
--- a/docs/tutorial/blank_project/CMakeLists.txt
+++ b/docs/tutorial/blank_project/CMakeLists.txt
@@ -1,16 +1,14 @@
-###############################################################################
-#
+#------------------------------------------------------------------------------
# BLT Tutorial Example: Blank Project.
-#
-###############################################################################
+#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.8)
-
project( blank )
-###############################################################################
+#------------------------------------------------------------------------------
# Setup BLT
-###############################################################################
+#------------------------------------------------------------------------------
+
# _blt_tutorial_include_blt_start
if (DEFINED BLT_SOURCE_DIR)
# Support having a shared BLT outside of the repository if given a BLT_SOURCE_DIR
diff --git a/docs/tutorial/calc_pi/CMakeLists.txt b/docs/tutorial/calc_pi/CMakeLists.txt
index f1f8d070a..6ac7a8563 100644
--- a/docs/tutorial/calc_pi/CMakeLists.txt
+++ b/docs/tutorial/calc_pi/CMakeLists.txt
@@ -1,15 +1,14 @@
-###############################################################################
+#------------------------------------------------------------------------------
# BLT Tutorial Example: Calc Pi.
-#
-###############################################################################
+#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.8)
project( pi_playground )
-###############################################################################
+#------------------------------------------------------------------------------
# Setup BLT
-###############################################################################
+#------------------------------------------------------------------------------
# Set BLT_SOURCE_DIR to default location, if not set by user
if(NOT BLT_SOURCE_DIR)
set(BLT_SOURCE_DIR "blt")
@@ -17,17 +16,17 @@ endif()
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
-###############################################################################
+#------------------------------------------------------------------------------
# Example 1: Creating a simple executable.
-###############################################################################
+#------------------------------------------------------------------------------
# _blt_tutorial_example_executable_start
blt_add_executable( NAME example_1
SOURCES example_1.cpp )
# _blt_tutorial_example_executable_end
-###############################################################################
+#------------------------------------------------------------------------------
# Example 2: Creating a library and an executable using our library.
-###############################################################################
+#------------------------------------------------------------------------------
# _blt_tutorial_calcpi_library_start
blt_add_library( NAME calc_pi
HEADERS calc_pi.hpp calc_pi_exports.h
@@ -44,9 +43,9 @@ blt_add_executable( NAME example_2
DEPENDS_ON calc_pi)
# _blt_tutorial_calcpi_example2_end
-###############################################################################
+#------------------------------------------------------------------------------
# Test 1: Creating an executable using gtest, using the executable via ctest.
-###############################################################################
+#------------------------------------------------------------------------------
# _blt_tutorial_calcpi_test1_executable_start
blt_add_executable( NAME test_1
SOURCES test_1.cpp
@@ -56,14 +55,12 @@ blt_add_executable( NAME test_1
# _blt_tutorial_calcpi_test1_test_start
blt_add_test( NAME test_1
COMMAND test_1)
-# _blt_tutorial_calcpi_test1_test_start
+# _blt_tutorial_calcpi_test1_test_end
-###############################################################################
-#
+#------------------------------------------------------------------------------
# Test 2: Add mpi version of calc_pi, and expand test 1 to also test
# the mpi version.
-#
-###############################################################################
+#------------------------------------------------------------------------------
if(MPI_FOUND)
# _blt_tutorial_calcpi_test2_executable_start
blt_add_library( NAME calc_pi_mpi
@@ -87,12 +84,10 @@ if(MPI_FOUND)
# _blt_tutorial_calcpi_test2_test_end
endif()
-###############################################################################
-#
+#------------------------------------------------------------------------------
# Test 3: Add cuda version of calc_pi, and expand test 1 to also test
# the cuda version.
-#
-###############################################################################
+#------------------------------------------------------------------------------
if(CUDA_FOUND)
# _blt_tutorial_calcpi_cuda_start
# avoid warnings about sm_20 deprecated
@@ -119,9 +114,9 @@ if(CUDA_FOUND)
endif()
-###############################################################################
+#------------------------------------------------------------------------------
# Add Documentation Examples
-###############################################################################
+#------------------------------------------------------------------------------
add_subdirectory(docs)
diff --git a/docs/tutorial/calc_pi/docs/doxygen/CMakeLists.txt b/docs/tutorial/calc_pi/docs/doxygen/CMakeLists.txt
index 7dc4eff95..be6c9e1a1 100644
--- a/docs/tutorial/calc_pi/docs/doxygen/CMakeLists.txt
+++ b/docs/tutorial/calc_pi/docs/doxygen/CMakeLists.txt
@@ -1,6 +1,6 @@
-#######################################################
+#------------------------------------------------------------------------------
# add a target to generate documentation with Doxygen
-#######################################################
+#------------------------------------------------------------------------------
if(DOXYGEN_FOUND)
blt_add_doxygen_target( calc_pi_doxygen )
diff --git a/docs/tutorial/calc_pi/docs/doxygen/Doxyfile.in b/docs/tutorial/calc_pi/docs/doxygen/Doxyfile.in
index 7bd7652db..a4e608236 100644
--- a/docs/tutorial/calc_pi/docs/doxygen/Doxyfile.in
+++ b/docs/tutorial/calc_pi/docs/doxygen/Doxyfile.in
@@ -1,6 +1,6 @@
-##########################################
+#---------------------------------------
# Doxygen Config for Calc Pi Example
-##########################################
+#---------------------------------------
PROJECT_NAME = Calc Pi
PROJECT_BRIEF = "Calc Pi"
@@ -11,4 +11,4 @@ GENERATE_XML = NO
GENERATE_LATEX = NO
RECURSIVE = NO
-STRIP_CODE_COMMENTS = NO
\ No newline at end of file
+STRIP_CODE_COMMENTS = NO
diff --git a/docs/tutorial/calc_pi/docs/sphinx/CMakeLists.txt b/docs/tutorial/calc_pi/docs/sphinx/CMakeLists.txt
index 0ad620fa7..3f96021f2 100644
--- a/docs/tutorial/calc_pi/docs/sphinx/CMakeLists.txt
+++ b/docs/tutorial/calc_pi/docs/sphinx/CMakeLists.txt
@@ -1,6 +1,6 @@
-#######################################################
+#------------------------------------------------------------------------------
# add a target to generate documentation with sphinx
-#######################################################
+#------------------------------------------------------------------------------
if(SPHINX_FOUND)
blt_add_sphinx_target( calc_pi_sphinx )
diff --git a/docs/tutorial/calc_pi/docs/sphinx/conf.py b/docs/tutorial/calc_pi/docs/sphinx/conf.py
index 1b00fda1d..7b35c555d 100644
--- a/docs/tutorial/calc_pi/docs/sphinx/conf.py
+++ b/docs/tutorial/calc_pi/docs/sphinx/conf.py
@@ -52,7 +52,7 @@
# General information about the project.
project = u'Calc Pi'
-copyright = u'2017, Calc Pi Developers'
+copyright = u'Calc Pi Developers'
author = u'Calc Pi Developers'
# The version info for the project you're documenting, acts as replacement for
diff --git a/docs/creating_documentation.rst b/docs/tutorial/creating_documentation.rst
similarity index 83%
rename from docs/creating_documentation.rst
rename to docs/tutorial/creating_documentation.rst
index cfd801d0f..fa1068d7f 100644
--- a/docs/creating_documentation.rst
+++ b/docs/tutorial/creating_documentation.rst
@@ -10,23 +10,24 @@ BLT provides macros to build documentation using `Sphinx `_.
-Sphinx is the documentation system used for the Python programming language (and many other projects).
+Sphinx is the documentation system used by the Python programming
+language project (among many others).
Doxygen is a widely used system that generates documentation from annotated source code.
Doxygen is heavily used for documenting C++ software.
Sphinx and Doxygen are not built into BLT, so the ``sphinx-build`` and ``doxygen`` executables
-must be available via a users ``PATH`` at configuration time, or explicitly specified using the
-CMake variables ``SPHINX_EXECUTABLE`` and ``DOXYGEN_EXECUTABLE`` .
+must be available via a user's ``PATH`` at configuration time, or explicitly specified using the
+CMake variables ``SPHINX_EXECUTABLE`` and ``DOXYGEN_EXECUTABLE``.
Here is an example of setting ``sphinx-build`` and ``doxygen`` paths in a host-config file:
.. code-block:: cmake
- set(SPHINX_EXECUTABLE "/usr/bin/sphinx-build" CACHE PATH "")
+ set(SPHINX_EXECUTABLE "/usr/bin/sphinx-build" CACHE FILEPATH "")
- set(DOXYGEN_EXECUTABLE "/usr/bin/doxygen" CACHE PATH "")
+ set(DOXYGEN_EXECUTABLE "/usr/bin/doxygen" CACHE FILEPATH "")
The ``calc_pi`` example provides examples of both Sphinx and Doxygen documentation.
@@ -36,9 +37,9 @@ Calc Pi Sphinx Example
~~~~~~~~~~~~~~~~~~~~~~~~~
Sphinx is a python package that depends on several other packages.
-It can be installed via spack, pip, anaconda, etc.
+It can be installed via `spack `_, pip, anaconda, etc...
-``sphinx-build`` process a ``config.py`` file which includes a tree of reStructuredText files.
+``sphinx-build`` processes a ``config.py`` file which includes a tree of `reStructuredText` files.
The Sphinx ``sphinx-quickstart`` utility helps you generate a new sphinx project, including
selecting common settings for the ``config.py``.
@@ -57,20 +58,20 @@ CMake target.
Here is an example of using ``blt_add_sphinx_target()`` in a CMakeLists.txt file:
-.. literalinclude:: tutorial/calc_pi/docs/sphinx/CMakeLists.txt
+.. literalinclude:: calc_pi/docs/sphinx/CMakeLists.txt
:language: rst
Here is the example reStructuredText file that contains documentation for the *calc_pi* example.
-.. literalinclude:: tutorial/calc_pi/docs/sphinx/index.rst
+.. literalinclude:: calc_pi/docs/sphinx/index.rst
:language: rst
Calc Pi Doxygen Example
~~~~~~~~~~~~~~~~~~~~~~~~~
-Doxygen is a compiled executable that can be installed via spack, built-by-hand, etc.
+Doxygen is a compiled executable that can be installed via spack, built-by-hand, etc...
``doxygen`` processes a ``Doxyfile`` which specifies options, including where to look for
annotated source files.
@@ -89,13 +90,13 @@ and add a command to build the Doxygen docs using this file to the ``docs`` CMak
Here is an example of using ``blt_add_doxygen_target()`` in a CMakeLists.txt file:
-.. literalinclude:: tutorial/calc_pi/docs/doxygen/CMakeLists.txt
+.. literalinclude:: calc_pi/docs/doxygen/CMakeLists.txt
:language: rst
Here is the example ``Doxyfile.in`` file that is configured by CMake and passed to ``doxygen``.
-.. literalinclude:: tutorial/calc_pi/docs/doxygen/Doxyfile.in
+.. literalinclude:: calc_pi/docs/doxygen/Doxyfile.in
:language: rst
diff --git a/docs/creating_execs_and_libs.rst b/docs/tutorial/creating_execs_and_libs.rst
similarity index 89%
rename from docs/creating_execs_and_libs.rst
rename to docs/tutorial/creating_execs_and_libs.rst
index ce2fef590..6f02cfa39 100644
--- a/docs/creating_execs_and_libs.rst
+++ b/docs/tutorial/creating_execs_and_libs.rst
@@ -12,9 +12,9 @@ In the previous section, we learned the basics about how to create a CMake
project with BLT, how to configure the project and how to build and test BLT's built-in third party libraries.
We now move on to creating libraries and executables
-using two of BLT's core macros: ``blt_add_library`` and ``blt_add_executable``.
+using two of BLT's core macros: ``blt_add_library()`` and ``blt_add_executable()``.
-We begin with a simple executable that calculates pi by numerical integration
+We begin with a simple executable that calculates :math:`\pi` by numerical integration
(``example_1``). We will then extract that code into a library, which we link
into a new executable (``example_2``).
@@ -26,7 +26,7 @@ This example is as basic as it gets. After setting up a BLT CMake project,
like ``blank_project`` in the previous section, we can start using BLT's macros.
Creating an executable is as simple as calling the following macro:
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_example_executable_start
:end-before: _blt_tutorial_example_executable_end
:language: cmake
@@ -49,9 +49,10 @@ create the executable ``/bin/example_1``:
.. admonition:: blt_add_executable
:class: hint
+
This is one of the core macros that enables BLT to simplify our CMake-based
project. It unifies many CMake calls into one easy to use macro.
- ``blt_add_executable`` creates a CMake executable target with the
+ ``blt_add_executable()`` creates a CMake executable target with the
given sources, sets the output directory to ``/bin``
(unless overridden with the macro parameter ``OUTPUT_DIR``) and handles
internal and external dependencies in a greatly simplified manner. There
@@ -62,11 +63,11 @@ Example 2: One library, one executable
--------------------------------------
This example is a bit more exciting. This time we are creating a library
-that calculates pi and then linking that library into an executable.
+that calculates the value of pi and then linking that library into an executable.
First, we create the library with the following BLT code:
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_calcpi_library_start
:end-before: _blt_tutorial_calcpi_library_end
:language: cmake
@@ -77,7 +78,7 @@ Just like before, this creates a CMake library target that will get built to
Next, we create an executable named ``example_2`` and link in the previously
created library target:
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_calcpi_example2_start
:end-before: _blt_tutorial_calcpi_example2_end
:language: cmake
@@ -103,7 +104,8 @@ BLT has simplified the use of CMake object libraries through the
``blt_add_library`` macro. Object libraries are a collection of object files
that are not linked or archived into a library. They are used in other libraries
or executables through the ``DEPENDS_ON`` macro argument. This is generally
-useful for combining smaller libraries into a larger library without the linker removing unused symbols in the larger library.
+useful for combining smaller libraries into a larger library without
+the linker removing unused symbols in the larger library.
.. code-block:: cmake
diff --git a/docs/external_dependencies.rst b/docs/tutorial/external_dependencies.rst
similarity index 75%
rename from docs/external_dependencies.rst
rename to docs/tutorial/external_dependencies.rst
index 3fa502b03..9f3d30c3d 100644
--- a/docs/external_dependencies.rst
+++ b/docs/tutorial/external_dependencies.rst
@@ -9,9 +9,10 @@ External Dependencies
One key goal for BLT is to simplify the use of external dependencies when building your libraries and executables.
To accomplish this BLT provides a ``DEPENDS_ON`` option for the
-``blt_add_library`` and ``blt_add_executable`` macros that supports both CMake targets and external dependencies registered using the ``blt_register_library`` macro.
+``blt_add_library()`` and ``blt_add_executable()`` macros that supports both CMake targets
+and external dependencies registered using the ``blt_register_library()`` macro.
-The ``blt_register_library`` macro allows you to reuse all information needed
+The ``blt_register_library()`` macro allows you to reuse all information needed
for an external dependency under a single name. This includes any include
directories, libraries, compile flags, link flags, defines, etc. You can also
hide any warnings created by their headers by setting the
@@ -31,34 +32,39 @@ For example, to find and register the external dependency *axom* as a BLT regist
LIBRARIES ${AXOM_LIBRARIES})
Then *axom* is available to be used in the DEPENDS_ON list in the following
-``blt_add_executable`` or ``blt_add_library`` calls.
+``blt_add_executable()`` or ``blt_add_library()`` calls.
This is especially helpful for external libraries that are not built with CMake
-and don't provide CMake friendly imported targets. Our ultimate goal is to use ``blt_register_library`` to import all external dependencies as first-class imported CMake targets to take full advanced of CMake's dependency lattice.
+and don't provide CMake-friendly imported targets. Our ultimate goal is to use ``blt_register_library()``
+to import all external dependencies as first-class imported CMake targets to take full advanced of CMake's dependency lattice.
-MPI, CUDA, and OpenMP are all registered via ``blt_register_library``. You can see how these registered via ``blt_register_library`` in ``blt/thirdparty_builtin/CMakelists.txt``.
+MPI, CUDA, and OpenMP are all registered via ``blt_register_library()``.
+You can see how in ``blt/thirdparty_builtin/CMakelists.txt``.
-BLT also supports using ``blt_register_library`` to provide additional options for existing CMake targets. The implementation doesn't modify the properties of the existing targets, it just exposes these options via BLT's support for ``DEPENDS_ON``.
+BLT also supports using ``blt_register_library()`` to provide additional options for existing CMake targets.
+The implementation doesn't modify the properties of the existing targets,
+it just exposes these options via BLT's support for ``DEPENDS_ON``.
.. admonition:: blt_register_library
:class: hint
A macro to register external libraries and dependencies with BLT.
- The named target can be added to the ``DEPENDS_ON`` argument of other BLT macros, like ``blt_add_library`` and ``blt_add_executable``.
+ The named target can be added to the ``DEPENDS_ON`` argument of other BLT macros,
+ like ``blt_add_library()`` and ``blt_add_executable()``.
You have already seen one use of ``DEPENDS_ON`` for a BLT
registered dependency in test_1: ``gtest``
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_calcpi_test1_executable_start
:end-before: _blt_tutorial_calcpi_test1_executable_end
:language: cmake
``gtest`` is the name for the Google Test dependency in BLT registered via
-``blt_register_library``. Even though Google Test is built-in and uses CMake,
-``blt_register_library`` allows us to easily set defines needed by all dependent
+``blt_register_library()``. Even though Google Test is built-in and uses CMake,
+``blt_register_library()`` allows us to easily set defines needed by all dependent
targets.
@@ -71,7 +77,7 @@ which uses MPI to parallelize the calculation over the integration intervals.
To enable MPI, we set ``ENABLE_MPI``, ``MPI_C_COMPILER``, and ``MPI_CXX_COMPILER`` in our host config file. Here is a snippet with these settings for LLNL's Surface Cluster:
-.. literalinclude:: ../host-configs/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
+.. literalinclude:: ../../host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
:start-after: _blt_tutorial_surface_mpi_config_start
:end-before: _blt_tutorial_surface_mpi_config_end
:language: cmake
@@ -79,16 +85,16 @@ To enable MPI, we set ``ENABLE_MPI``, ``MPI_C_COMPILER``, and ``MPI_CXX_COMPILER
Here, you can see how ``calc_pi_mpi`` and ``test_2`` use ``DEPENDS_ON``:
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_calcpi_test2_executable_start
:end-before: _blt_tutorial_calcpi_test2_executable_end
:language: cmake
For MPI unit tests, you also need to specify the number of MPI Tasks
-to launch. We use the ``NUM_MPI_TASKS`` argument to ``blt_add_test`` macro.
+to launch. We use the ``NUM_MPI_TASKS`` argument to ``blt_add_test()`` macro.
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_calcpi_test2_test_start
:end-before: _blt_tutorial_calcpi_test2_test_end
:language: cmake
@@ -99,7 +105,7 @@ driver that will execute all unit tests defined in the source. To test MPI code,
we need to create a main that initializes and finalizes MPI in addition to Google
Test. ``test_2.cpp`` provides an example driver for MPI with Google Test.
-.. literalinclude:: tutorial/calc_pi/test_2.cpp
+.. literalinclude:: calc_pi/test_2.cpp
:start-after: _blt_tutorial_calcpi_test2_main_start
:end-before: _blt_tutorial_calcpi_test2_main_end
:language: cpp
@@ -108,8 +114,13 @@ Test. ``test_2.cpp`` provides an example driver for MPI with Google Test.
While we have tried to ensure that BLT chooses the correct setup information
for MPI, there are several niche cases where the default behavior is
insufficient. We have provided several available override variables:
- BLT_MPI_COMPILE_FLAGS, BLT_MPI_INCLUDES, BLT_MPI_LIBRARIES, and BLT_MPI_LINK_FLAGS.
- BLT also has the variable ENABLE_FIND_MPI which turns off all CMake's FindMPI
+
+ * ``BLT_MPI_COMPILE_FLAGS``
+ * ``BLT_MPI_INCLUDES``
+ * ``BLT_MPI_LIBRARIES``
+ * ``BLT_MPI_LINK_FLAGS``
+
+ BLT also has the variable ``ENABLE_FIND_MPI`` which turns off all CMake's ``FindMPI``
logic and then uses the MPI wrapper directly when you provide them as the default
compilers.
@@ -129,14 +140,14 @@ for you and enable the CUDA language.
Here is a snippet with these settings for LLNL's Surface Cluster:
-.. literalinclude:: ../host-configs/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
+.. literalinclude:: ../../host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
:start-after: _blt_tutorial_surface_cuda_config_start
:end-before: _blt_tutorial_surface_cuda_config_end
:language: cmake
Here, you can see how ``calc_pi_cuda`` and ``test_3`` use ``DEPENDS_ON``:
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_calcpi_cuda_start
:end-before: _blt_tutorial_calcpi_cuda_end
:language: cmake
@@ -170,7 +181,7 @@ executable's ``DEPENDS_ON`` list.
Here is an example of how to add an OpenMP enabled executable:
- .. literalinclude:: ../tests/smoke/CMakeLists.txt
+ .. literalinclude:: ../../tests/smoke/CMakeLists.txt
:start-after: _blt_tutorial_openmp_executable_start
:end-before: _blt_tutorial_openmp_executable_end
:language: cmake
@@ -180,9 +191,18 @@ Here is an example of how to add an OpenMP enabled executable:
OpenMP, there are several niche cases where the default options are insufficient.
For example, linking with NVCC requires to link in the OpenMP libraries directly instead
of relying on the compile and link flags returned by CMake's FindOpenMP package. An
- example of this is in ``host-configs/llnl-ray-blue_os-clang-coral@2018.08.08.cmake``.
- We provide two variables to override BLT's OpenMP flag logic: ``BLT_OPENMP_COMPILE_FLAGS``
- and ``BLT_OPENMP_LINK_FLAGS``.
+ example of this is in ``host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_link_with_nvcc.cmake``.
+ We provide two variables to override BLT's OpenMP flag logic:
+
+ * ``BLT_OPENMP_COMPILE_FLAGS``
+ * ``BLT_OPENMP_LINK_FLAGS``
+
+Here is an example of how to add an OpenMP enabled test that sets the amount of threads used:
+
+ .. literalinclude:: ../../tests/smoke/CMakeLists.txt
+ :start-after: _blt_tutorial_openmp_test_start
+ :end-before: _blt_tutorial_openmp_test_end
+ :language: cmake
Example Host-configs
@@ -190,17 +210,17 @@ Example Host-configs
Here are the full example host-config files that use gcc 4.9.3 for LLNL's Surface, Ray and Quartz Clusters.
-:download:`llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake <../host-configs/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake>`
+:download:`llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake <../../host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake>`
-:download:`llnl-ray-blue_os-clang-coral@2018.08.08.cmake <../host-configs/llnl-ray-blue_os-clang-coral@2018.08.08.cmake>`
+:download:`llnl/blueos_3_ppc64le_ib_p9/clang@upstream_nvcc_xlf <../../host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_nvcc_xlf.cmake>`
-:download:`llnl-quartz-toss3-gcc@4.9.3.cmake <../host-configs/llnl-quartz-toss3-gcc@4.9.3.cmake>`
+:download:`llnl/toss_3_x86_64_ib/gcc@4.9.3.cmake <../../host-configs/llnl/toss_3_x86_64_ib/gcc@4.9.3.cmake>`
.. note:: Quartz does not have GPUs, so CUDA is not enabled in the Quartz host-config.
Here is a full example host-config file for an OSX laptop, using a set of dependencies built with spack.
-:download:`llnl-naples-darwin-10.11-clang@7.3.0.cmake <../host-configs/llnl-naples-darwin-10.11-clang@7.3.0.cmake>`
+:download:`darwin/elcapitan-x86_64/naples-clang@7.3.0.cmake <../../host-configs/darwin/elcapitan-x86_64/naples-clang@7.3.0.cmake>`
Building and testing on Surface
@@ -211,14 +231,16 @@ Here is how you can use the host-config file to configure a build of the ``calc_
.. code-block:: bash
# load new cmake b/c default on surface is too old
- use cmake-3.5.2
+ ml cmake/3.9.2
# create build dir
mkdir build
cd build
# configure using host-config
- cmake -C ../../host-configs/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake -DBLT_SOURCE_DIR=../../../../blt ..
+ cmake -C ../../host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake \
+ -DBLT_SOURCE_DIR=../../../../blt ..
-After building (``make``), you can run ``make test`` on a batch node (where the GPUs reside) to run the unit tests that are using MPI and CUDA:
+After building (``make``), you can run ``make test`` on a batch node (where the GPUs reside)
+to run the unit tests that are using MPI and CUDA:
.. code-block:: console
@@ -264,13 +286,14 @@ enabled on the blue_os Ray cluster:
mkdir build
cd build
# configure using host-config
- cmake -C ../../host-configs/llnl-ray-blue_os-gcc@4.9.3.cmake -DBLT_SOURCE_DIR=../../../../blt ..
+ cmake -C ../../host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_nvcc_xlf.cmake \
+ -DBLT_SOURCE_DIR=../../../../blt ..
And here is how to build and test the code on Ray:
.. code-block:: console
- bash-4.2$ bsub -Is -n20 -G bash
+ bash-4.2$ lalloc 1 -G
bash-4.2$ make
bash-4.2$ make test
diff --git a/docs/tutorial/index.rst b/docs/tutorial/index.rst
new file mode 100644
index 000000000..3ed60f49d
--- /dev/null
+++ b/docs/tutorial/index.rst
@@ -0,0 +1,37 @@
+.. # Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+.. # other BLT Project Developers. See the top-level COPYRIGHT file for details
+.. #
+.. # SPDX-License-Identifier: (BSD-3-Clause)
+
+User Tutorial
+=============
+
+This tutorial provides instructions for:
+
+ * Adding BLT to a CMake project
+ * Setting up *host-config* files to handle multiple platform configurations
+ * Building, linking, and installing libraries and executables
+ * Setting up unit tests with GTest
+ * Using external project dependencies
+ * Creating documentation with Sphinx and Doxygen
+
+The tutorial provides several examples that calculate the value of :math:`\pi`
+by approximating the integral :math:`f(x) = \int_0^14/(1+x^2)` using numerical
+integration. The code is adapted from:
+https://www.mcs.anl.gov/research/projects/mpi/usingmpi/examples-usingmpi/simplempi/cpi_c.html.
+
+The tutorial requires a C++ compiler and CMake, we recommend using CMake 3.8.0 or newer.
+Parts of the tutorial also require MPI, CUDA, Sphinx and Doxygen.
+
+
+.. toctree::
+ :maxdepth: 3
+ :caption: Tutorial Contents
+
+ setup_blt
+ creating_execs_and_libs
+ using_flags
+ unit_testing
+ external_dependencies
+ creating_documentation
+ recommendations
diff --git a/docs/recommendations.rst b/docs/tutorial/recommendations.rst
similarity index 57%
rename from docs/recommendations.rst
rename to docs/tutorial/recommendations.rst
index 8b8ad94e9..6f55becdf 100644
--- a/docs/recommendations.rst
+++ b/docs/tutorial/recommendations.rst
@@ -8,7 +8,8 @@
CMake Recommendations
======================
-This section includes several recommendations for how to wield CMake. Some of them are embodied in BLT, others are broader suggestions for CMake bliss.
+This section includes several recommendations for how to wield CMake.
+Some of them are embodied in BLT, others are broader suggestions for CMake bliss.
.. rubric:: Disable in-source builds
@@ -16,11 +17,13 @@ This section includes several recommendations for how to wield CMake. Some of th
*BLT Enforces This*
-In-source builds clutter source code with temporary build files and prevent other out-of-source builds from being created. Disabling in-source builds avoids clutter and accidental checkins of temporary build files.
+In-source builds clutter source code with temporary build files and prevent other out-of-source builds
+from being created. Disabling in-source builds avoids clutter and accidental checkins of temporary build files.
.. rubric:: Avoid using globs to identify source files
-Globs are evaluated at CMake configure time - not build time. This means CMake will not detect new source files when they are added to the file system unless there are other changes that trigger CMake to reconfigure.
+Globs are evaluated at CMake configure time - not build time. This means CMake will not detect new source files
+when they are added to the file system unless there are other changes that trigger CMake to reconfigure.
The CMake documentation also warns against this:
https://cmake.org/cmake/help/v3.10/command/file.html?highlight=glob#file
@@ -28,7 +31,9 @@ https://cmake.org/cmake/help/v3.10/command/file.html?highlight=glob#file
.. rubric:: Use arguments instead of options in CMake Macros and Functions
-``CMAKE_PARSE_ARGUMENTS`` allows Macros or Functions to support options. Options are enabled by passing them by name when calling a Macro or Function. Because of this, wrapping an existing Macro or Function in a way that passes through options requires if tests and multiple copies of the call. For example:
+``CMAKE_PARSE_ARGUMENTS`` allows Macros or Functions to support options. Options are enabled by passing them
+by name when calling a Macro or Function. Because of this, wrapping an existing Macro or Function in a way
+that passes through options requires if tests and multiple copies of the call. For example:
.. code-block:: cmake
@@ -53,37 +58,47 @@ To simplify calling logic, we recommend using an argument instead of an option.
.. rubric:: Prefer explicit paths to locate third-party dependencies
-Require passing explicit paths (ex: ``ZZZ_DIR``) for third-party dependency locations. This avoids surprises with incompatible installs sprinkled in various system locations. If you are using off-the-shelf *FindZZZ* logic, also consider adding CMake checks to verify that *FindZZZ* logic actually found the dependencies at the location specified.
+Require passing explicit paths (ex: ``ZZZ_DIR``) for third-party dependency locations.
+This avoids surprises with incompatible installs sprinkled in various system locations.
+If you are using off-the-shelf *FindZZZ* logic, also consider adding CMake checks
+to verify that *FindZZZ* logic actually found the dependencies at the location specified.
.. rubric:: Emit a configure error if an explicitly identified third-party dependency is not found or an incorrect version is found.
If an explicit path to a dependency is given (ex: ``ZZZ_DIR``) it should be valid or result in a CMake configure error.
-In contrast, if you only issue a warning and automatically disable a feature when a third-party dependency is bad, the warning often goes unnoticed and may not be caught until folks using your software are surprised. Emitting a configure error stops CMake and draws attention to the fact that something is wrong. Optional dependencies are still supported by including them only if an explicit path to the dependency is given (ex: ``ZZZ_DIR``).
-
+In contrast, if you only issue a warning and automatically disable a feature when a third-party dependency is bad,
+the warning often goes unnoticed and may not be caught until folks using your software are surprised.
+Emitting a configure error stops CMake and draws attention to the fact that something is wrong.
+Optional dependencies are still supported by including them only if an explicit path
+to the dependency is provided (ex: ``ZZZ_DIR``).
.. rubric:: Add headers as source files to targets
*BLT Macros Support This*
-This ensures headers are tracked as dependencies and are included in the projects created by CMake's IDE generators, like Xcode or Eclipse.
+This ensures headers are tracked as dependencies and are included in the projects
+created by CMake's IDE generators, like Xcode or Eclipse.
.. rubric:: Always support `make install`
-This allows CMake to do the right thing based on ``CMAKE_INSTALL_PREFIX``, and also helps support CPack create release packages. This is especially important for libraries. In addition to targets, header files require an explicit install command.
+This allows CMake to do the right thing based on ``CMAKE_INSTALL_PREFIX``,
+and also helps support CPack create release packages. This is especially important for libraries.
+In addition to targets, header files require an explicit install command.
Here is an example that installs a target and its headers:
.. code-block:: cmake
- ##################################
+ #--------------------------------------------------------
# Install Targets for example lib
- ##################################
+ #--------------------------------------------------------
install(FILES ${example_headers} DESTINATION include)
install(TARGETS example
EXPORT example
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
+
diff --git a/docs/setup_blt.rst b/docs/tutorial/setup_blt.rst
similarity index 93%
rename from docs/setup_blt.rst
rename to docs/tutorial/setup_blt.rst
index 14b21c481..645db8b2f 100644
--- a/docs/setup_blt.rst
+++ b/docs/tutorial/setup_blt.rst
@@ -67,27 +67,27 @@ This enables all of BLT's features in your project.
However if your project is likely to be used by other projects. The following
is recommended:
-.. literalinclude:: tutorial/blank_project/CMakeLists.txt
+.. literalinclude:: blank_project/CMakeLists.txt
:start-after: _blt_tutorial_include_blt_start
:end-before: _blt_tutorial_include_blt_end
:language: cmake
This is a robust way of setting up BLT and supports an optional external BLT source
directory. This allows the use of a common BLT across large projects. There are some
-helpful error messages for if the BLT submodule is missing and the commands to solve
+helpful error messages if the BLT submodule is missing as well as the commands to solve
it.
.. note::
Throughout this tutorial, we pass the path to BLT using ``BLT_SOURCE_DIR`` since
our tutorial is part of the blt repository and we want this project to be
- automatically tested by just a single check-out of our repository.
+ automatically tested using a single clone of our repository.
Running CMake
-------------
-To configure a project with CMake, first create a build directory and cd into it.
+To configure a project with CMake, first create a build directory and ``cd`` into it.
Then run cmake with the path to your project.
.. code-block:: bash
@@ -114,7 +114,7 @@ features. It demonstrates the bare minimum required for testing purposes.
Here is the entire CMakeLists.txt file for ``blank_project``:
-.. literalinclude:: tutorial/blank_project/CMakeLists.txt
+.. literalinclude:: blank_project/CMakeLists.txt
:language: cmake
BLT also enforces some best practices for building, such as not allowing
@@ -207,7 +207,7 @@ You can pass initial-cache files to cmake via the ``-C`` command line option.
We call these initial-cache files ``host-config`` files since we typically create
-a file for each platform or specific hosts, if necessary.
+a file for each platform or for specific hosts, if necessary.
These files use standard CMake commands. CMake ``set()`` commands need to specify
``CACHE`` as follows:
@@ -219,7 +219,7 @@ These files use standard CMake commands. CMake ``set()`` commands need to specif
Here is a snippet from a host-config file that specifies compiler details for
using gcc 4.9.3 on LLNL's surface cluster.
-.. literalinclude:: ../host-configs/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
+.. literalinclude:: ../../host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
:start-after: _blt_tutorial_surface_compiler_config_start
:end-before: _blt_tutorial_surface_compiler_config_end
:language: cmake
diff --git a/docs/unit_testing.rst b/docs/tutorial/unit_testing.rst
similarity index 97%
rename from docs/unit_testing.rst
rename to docs/tutorial/unit_testing.rst
index a9c142133..5a4d1a3b7 100644
--- a/docs/unit_testing.rst
+++ b/docs/tutorial/unit_testing.rst
@@ -18,7 +18,7 @@ Each Google Test or FRUIT file may contain multiple tests and is compiled into
its own executable that can be run directly or as a ``make`` target.
In this section, we give a brief overview of GTest and discuss how to add unit
-tests using the ``blt_add_test`` macro.
+tests using the ``blt_add_test()`` macro.
Configuring tests within BLT
@@ -186,14 +186,14 @@ We add a simple unit test that invokes ``calc_pi()``
and compares the result to :math:`\pi`, within a given tolerance (``1e-6``).
Here is the test code:
-.. literalinclude:: tutorial/calc_pi/test_1.cpp
+.. literalinclude:: calc_pi/test_1.cpp
:start-after: _blt_tutorial_calpi_test1_start
:end-before: _blt_tutorial_calpi_test1_end
:language: cpp
To add this test to the build system, we first generate a test executable:
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_calcpi_test1_executable_start
:end-before: _blt_tutorial_calcpi_test1_executable_end
:language: cmake
@@ -202,7 +202,7 @@ Note that this test executable depends on two targets: ``calc_pi`` and ``gtest``
We then register this executable as a test:
-.. literalinclude:: tutorial/calc_pi/CMakeLists.txt
+.. literalinclude:: calc_pi/CMakeLists.txt
:start-after: _blt_tutorial_calcpi_test1_test_start
:end-before: _blt_tutorial_calcpi_test1_test_end
:language: cmake
diff --git a/docs/using_flags.rst b/docs/tutorial/using_flags.rst
similarity index 92%
rename from docs/using_flags.rst
rename to docs/tutorial/using_flags.rst
index 683144f52..787692603 100644
--- a/docs/using_flags.rst
+++ b/docs/tutorial/using_flags.rst
@@ -6,7 +6,7 @@
Portable compiler flags
=========================
-To ease with the development of code that is portable across different architectures
+To simplify the development of code that is portable across different architectures
and compilers, BLT provides the ``blt_append_custom_compiler_flag()`` macro,
which allows users to easily place a compiler dependent flag into a CMake variable.
@@ -23,6 +23,9 @@ which allows users to easily place a compiler dependent flag into a CMake variab
* XL (IBM compiler)
* INTEL (Intel compiler)
* MSVC (Microsoft Visual Studio)
+ * MSVC_INTEL (Intel toolchain in Microsoft Visual Studio)
+ * PGI
+ * HCC (AMD GPU)
Here is an example for setting the appropriate flag to treat warnings as errors:
diff --git a/host-configs/llnl-naples-darwin-10.11-clang@7.3.0.cmake b/host-configs/darwin/elcapitan-x86_64/naples-clang@7.3.0.cmake
similarity index 100%
rename from host-configs/llnl-naples-darwin-10.11-clang@7.3.0.cmake
rename to host-configs/darwin/elcapitan-x86_64/naples-clang@7.3.0.cmake
diff --git a/host-configs/llnl-quartz-toss3-gcc@4.9.3.cmake b/host-configs/llnl-quartz-toss3-gcc@4.9.3.cmake
deleted file mode 100644
index 0c1344da8..000000000
--- a/host-configs/llnl-quartz-toss3-gcc@4.9.3.cmake
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
-# other BLT Project Developers. See the top-level COPYRIGHT file for details
-#
-# SPDX-License-Identifier: (BSD-3-Clause)
-
-###########################################################
-# Example host-config file for the quartz cluster at LLNL
-###########################################################
-#
-# This file provides CMake with paths / details for:
-# C,C++, & Fortran compilers + MPI
-#
-###########################################################
-
-###########################################################
-# gcc@4.9.3 compilers
-###########################################################
-
-# c compiler
-set(CMAKE_C_COMPILER "/usr/tce/packages/gcc/gcc-4.9.3/bin/gcc" CACHE PATH "")
-
-# cpp compiler
-set(CMAKE_CXX_COMPILER "/usr/tce/packages/gcc/gcc-4.9.3/bin/g++" CACHE PATH "")
-
-# fortran support
-set(ENABLE_FORTRAN ON CACHE BOOL "")
-
-# fortran compiler
-set(CMAKE_Fortran_COMPILER "/usr/tce/packages/gcc/gcc-4.9.3/bin/gfortran" CACHE PATH "")
-
-###########################################################
-# MPI Support
-###########################################################
-set(ENABLE_MPI ON CACHE BOOL "")
-
-set(MPI_C_COMPILER "/usr/tce/packages/mvapich2/mvapich2-2.2-gcc-4.9.3/bin/mpicc" CACHE PATH "")
-
-set(MPI_CXX_COMPILER "/usr/tce/packages/mvapich2/mvapich2-2.2-gcc-4.9.3/bin/mpicxx" CACHE PATH "")
-
-set(MPI_Fortran_COMPILER "/usr/tce/packages/mvapich2/mvapich2-2.2-gcc-4.9.3/bin/mpif90" CACHE PATH "")
-
-set(MPIEXEC "/usr/bin/srun" CACHE PATH "")
-
-set(MPIEXEC_NUMPROC_FLAG "-n" CACHE PATH "")
diff --git a/host-configs/llnl-bgq-clang@4.0.0_xlf.cmake b/host-configs/llnl/bgqos_0/clang@4.0.0_xlf.cmake
similarity index 100%
rename from host-configs/llnl-bgq-clang@4.0.0_xlf.cmake
rename to host-configs/llnl/bgqos_0/clang@4.0.0_xlf.cmake
diff --git a/host-configs/llnl-ray-blue_os-clang-coral@2018.08.08.cmake b/host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_link_with_nvcc.cmake
similarity index 60%
rename from host-configs/llnl-ray-blue_os-clang-coral@2018.08.08.cmake
rename to host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_link_with_nvcc.cmake
index 4ca095eb6..13e109399 100644
--- a/host-configs/llnl-ray-blue_os-clang-coral@2018.08.08.cmake
+++ b/host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_link_with_nvcc.cmake
@@ -4,28 +4,33 @@
# SPDX-License-Identifier: (BSD-3-Clause)
#------------------------------------------------------------------------------
-# Example host-config file for the blue_os ray cluster at LLNL
+# Example host-config file for the blue_os cluster at LLNL
#------------------------------------------------------------------------------
#
# This file provides CMake with paths / details for:
# C/C++, OpenMP, MPI, and Cuda
#
+# It demonstrates a more complex build, where the code is linked with nvcc.
+#------------------------------------------------------------------------------
+# Warning: This host-config does not currently work with CMake@3.13 or above
+# due to a linking error.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Compilers
#------------------------------------------------------------------------------
-set(ENABLE_FORTRAN OFF CACHE BOOL "")
-
-set(CLANG_VERSION "clang-coral-2018.08.08" CACHE STRING "")
-
-set(COMPILER_HOME "/usr/tce/packages/clang/${CLANG_VERSION}")
-set(CMAKE_C_COMPILER "${COMPILER_HOME}/bin/clang" CACHE PATH "")
-set(CMAKE_CXX_COMPILER "${COMPILER_HOME}/bin/clang++" CACHE PATH "")
+# Use Clang compilers for C/C++
+set(CLANG_VERSION "clang-upstream-2019.08.15" CACHE STRING "")
+set(CLANG_HOME "/usr/tce/packages/clang/${CLANG_VERSION}")
+set(CMAKE_C_COMPILER "${CLANG_HOME}/bin/clang" CACHE PATH "")
+set(CMAKE_CXX_COMPILER "${CLANG_HOME}/bin/clang++" CACHE PATH "")
set(BLT_CXX_STD "c++11" CACHE STRING "")
+# Disable Fortran
+set(ENABLE_FORTRAN OFF CACHE BOOL "")
+
#------------------------------------------------------------------------------
# MPI Support
#------------------------------------------------------------------------------
@@ -35,38 +40,33 @@ set(MPI_HOME "/usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-
set(MPI_C_COMPILER "${MPI_HOME}/bin/mpicc" CACHE PATH "")
set(MPI_CXX_COMPILER "${MPI_HOME}/bin/mpicxx" CACHE PATH "")
-set(MPIEXEC "mpirun" CACHE PATH "")
+set(MPIEXEC "${MPI_HOME}/bin/mpirun" CACHE PATH "")
set(MPIEXEC_NUMPROC_FLAG "-np" CACHE PATH "")
set(BLT_MPI_COMMAND_APPEND "mpibind" CACHE PATH "")
-
#------------------------------------------------------------------------------
# OpenMP support
#------------------------------------------------------------------------------
set(ENABLE_OPENMP ON CACHE BOOL "")
# Override default link flags because linking with nvcc
-set(BLT_OPENMP_LINK_FLAGS "-Xlinker -rpath -Xlinker /usr/tce/packages/clang/${CLANG_VERSION}/ibm/omprtl/lib -L/usr/tce/packages/clang/${CLANG_VERSION}/ibm/omprtl/lib -lomp -lomptarget-nvptx" CACHE STRING "")
-
+set(OMP_HOME ${CLANG_HOME}/release)
+set(BLT_OPENMP_LINK_FLAGS "-Xlinker -rpath -Xlinker ${OMP_HOME}/lib -L${OMP_HOME}/lib -lomp -lomptarget-nvptx" CACHE STRING "")
#------------------------------------------------------------------------------
# CUDA support
#------------------------------------------------------------------------------
set(ENABLE_CUDA ON CACHE BOOL "")
-set(CUDA_TOOLKIT_ROOT_DIR "/usr/tce/packages/cuda/cuda-9.2.88" CACHE PATH "")
+set(CUDA_TOOLKIT_ROOT_DIR "/usr/tce/packages/cuda/cuda-10.1.168" CACHE PATH "")
set(CMAKE_CUDA_COMPILER "${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc" CACHE PATH "")
-set(CMAKE_CUDA_HOST_COMPILER ${MPI_CXX_COMPILER} CACHE PATH "")
+set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} CACHE PATH "")
-set (CUDA_ARCH "sm_60" CACHE PATH "")
-set (CMAKE_CUDA_FLAGS "-restrict -arch ${CUDA_ARCH} -std=c++11 --expt-extended-lambda -G" CACHE STRING "" )
+set (_cuda_arch "sm_70")
+set (CMAKE_CUDA_FLAGS "-restrict -arch ${_cuda_arch} -std=c++11 --expt-extended-lambda -G" CACHE STRING "" )
set (CUDA_SEPARABLE_COMPILATION ON CACHE BOOL "" )
set (CUDA_LINK_WITH_NVCC ON CACHE BOOL "")
-# set the link flags manually since nvcc will link (and not have the wrappers knowledge)
-# on ray - can figure out your equivalant flags by doing mpicc -vvvv
-set (SPECTRUM_ROLLING "/usr/tce/packages/spectrum-mpi/ibm/spectrum-mpi-rolling-release")
-set (CMAKE_CUDA_LINK_FLAGS "-Xlinker -rpath -Xlinker ${SPECTRUM_ROLLING}/lib -Xlinker -rpath -Xlinker ${COMPILER_HOME}/ibm/lib:/usr/tce/packages/gcc/gcc-4.9.3/lib64 -L${SPECTRUM_ROLLING}/lib/ -lmpi_ibm" CACHE STRING "")
# nvcc does not like gtest's 'pthreads' flag
set(gtest_disable_pthreads ON CACHE BOOL "")
diff --git a/host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_nvcc_xlf.cmake b/host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_nvcc_xlf.cmake
new file mode 100644
index 000000000..478393d07
--- /dev/null
+++ b/host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_nvcc_xlf.cmake
@@ -0,0 +1,77 @@
+# Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+# other BLT Project Developers. See the top-level COPYRIGHT file for details
+#
+# SPDX-License-Identifier: (BSD-3-Clause)
+
+#------------------------------------------------------------------------------
+# Example host-config file for the blue_os cluster at LLNL
+#------------------------------------------------------------------------------
+#
+# This file provides CMake with paths / details for:
+# C/C++: Clang
+# Fortran: XLF
+# MPI
+# Cuda
+#
+#------------------------------------------------------------------------------
+
+#------------------------------------------------------------------------------
+# Compilers
+#------------------------------------------------------------------------------
+
+# Use Clang compilers for C/C++
+set(CLANG_VERSION "clang-upstream-2019.08.15" CACHE STRING "")
+set(CLANG_HOME "/usr/tce/packages/clang/${CLANG_VERSION}")
+
+set(CMAKE_C_COMPILER "${CLANG_HOME}/bin/clang" CACHE PATH "")
+set(CMAKE_CXX_COMPILER "${CLANG_HOME}/bin/clang++" CACHE PATH "")
+set(BLT_CXX_STD "c++11" CACHE STRING "")
+
+# Use XL compiler for Fortran
+set(ENABLE_FORTRAN ON CACHE BOOL "")
+set(XL_VERSION "xl-2019.06.12")
+set(XL_HOME "/usr/tce/packages/xl/${XL_VERSION}")
+set(CMAKE_Fortran_COMPILER "${XL_HOME}/bin/xlf2003" CACHE PATH "")
+
+#------------------------------------------------------------------------------
+# MPI Support
+#------------------------------------------------------------------------------
+
+set(ENABLE_MPI ON CACHE BOOL "")
+
+set(MPI_HOME "/usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-${CLANG_VERSION}")
+set(MPI_Fortran_HOME "/usr/tce/packages/spectrum-mpi/spectrum-mpi-rolling-release-${XL_VERSION}")
+
+set(MPI_C_COMPILER "${MPI_HOME}/bin/mpicc" CACHE PATH "")
+set(MPI_CXX_COMPILER "${MPI_HOME}/bin/mpicxx" CACHE PATH "")
+set(MPI_Fortran_COMPILER "${MPI_Fortran_HOME}/bin/mpif90" CACHE PATH "")
+
+set(MPIEXEC "${MPI_HOME}/bin/mpirun" CACHE PATH "")
+set(MPIEXEC_NUMPROC_FLAG "-np" CACHE PATH "")
+set(BLT_MPI_COMMAND_APPEND "mpibind" CACHE PATH "")
+
+#------------------------------------------------------------------------------
+# Other machine specifics
+#------------------------------------------------------------------------------
+
+set(CMAKE_Fortran_COMPILER_ID "XL" CACHE PATH "All of BlueOS compilers report clang due to nvcc, override to proper compiler family")
+set(BLT_FORTRAN_FLAGS "-WF,-C!" CACHE PATH "Converts C-style comments to Fortran style in preprocessed files")
+
+#------------------------------------------------------------------------------
+# CUDA support
+#------------------------------------------------------------------------------
+
+set(ENABLE_CUDA ON CACHE BOOL "")
+
+set(CUDA_TOOLKIT_ROOT_DIR "/usr/tce/packages/cuda/cuda-10.1.168" CACHE PATH "")
+set(CMAKE_CUDA_COMPILER "${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc" CACHE PATH "")
+set(CMAKE_CUDA_HOST_COMPILER "${MPI_CXX_COMPILER}" CACHE PATH "")
+
+set(_cuda_arch "sm_70")
+set(CMAKE_CUDA_FLAGS "-restrict -arch ${_cuda_arch} -std=c++11 --expt-extended-lambda -G" CACHE STRING "")
+
+set(CUDA_SEPARABLE_COMPILATION ON CACHE BOOL "" )
+
+# nvcc does not like gtest's 'pthreads' flag
+set(gtest_disable_pthreads ON CACHE BOOL "")
+
diff --git a/host-configs/llnl-quartz-toss3-clang@4.0.0-libcxx.cmake b/host-configs/llnl/toss_3_x86_64_ib/clang@4.0.0-libcxx.cmake
similarity index 100%
rename from host-configs/llnl-quartz-toss3-clang@4.0.0-libcxx.cmake
rename to host-configs/llnl/toss_3_x86_64_ib/clang@4.0.0-libcxx.cmake
diff --git a/host-configs/llnl-quartz-toss3-clang@6.0.0-static-analysis.cmake b/host-configs/llnl/toss_3_x86_64_ib/clang@6.0.0-static-analysis.cmake
similarity index 100%
rename from host-configs/llnl-quartz-toss3-clang@6.0.0-static-analysis.cmake
rename to host-configs/llnl/toss_3_x86_64_ib/clang@6.0.0-static-analysis.cmake
diff --git a/host-configs/llnl/toss_3_x86_64_ib/gcc@4.9.3.cmake b/host-configs/llnl/toss_3_x86_64_ib/gcc@4.9.3.cmake
new file mode 100644
index 000000000..061a12928
--- /dev/null
+++ b/host-configs/llnl/toss_3_x86_64_ib/gcc@4.9.3.cmake
@@ -0,0 +1,46 @@
+# Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+# other BLT Project Developers. See the top-level COPYRIGHT file for details
+#
+# SPDX-License-Identifier: (BSD-3-Clause)
+
+#------------------------------------------------------------------------------
+# Example host-config file for the quartz cluster at LLNL
+#------------------------------------------------------------------------------
+#
+# This file provides CMake with paths / details for:
+# C,C++, & Fortran compilers + MPI
+#
+#------------------------------------------------------------------------------
+
+#------------------------------------------------------------------------------
+# gcc@4.9.3 compilers
+#------------------------------------------------------------------------------
+
+set(GCC_VERSION "gcc-4.9.3")
+set(GCC_HOME "/usr/tce/packages/gcc/${GCC_VERSION}")
+
+# c compiler
+set(CMAKE_C_COMPILER "${GCC_HOME}/bin/gcc" CACHE PATH "")
+
+# cpp compiler
+set(CMAKE_CXX_COMPILER "${GCC_HOME}/bin/g++" CACHE PATH "")
+
+# fortran support
+set(ENABLE_FORTRAN ON CACHE BOOL "")
+
+# fortran compiler
+set(CMAKE_Fortran_COMPILER "${GCC_HOME}/bin/gfortran" CACHE PATH "")
+
+#------------------------------------------------------------------------------
+# MPI Support
+#------------------------------------------------------------------------------
+set(ENABLE_MPI ON CACHE BOOL "")
+
+set(MPI_HOME "/usr/tce/packages/mvapich2/mvapich2-2.3-${GCC_VERSION}" CACHE PATH "")
+
+set(MPI_C_COMPILER "${MPI_HOME}/bin/mpicc" CACHE PATH "")
+set(MPI_CXX_COMPILER "${MPI_HOME}/bin/mpicxx" CACHE PATH "")
+set(MPI_Fortran_COMPILER "${MPI_HOME}/bin/mpif90" CACHE PATH "")
+
+set(MPIEXEC "/usr/bin/srun" CACHE PATH "")
+set(MPIEXEC_NUMPROC_FLAG "-n" CACHE PATH "")
diff --git a/host-configs/llnl-quartz-toss3-pgi@18.5.cmake b/host-configs/llnl/toss_3_x86_64_ib/pgi@18.5.cmake
similarity index 100%
rename from host-configs/llnl-quartz-toss3-pgi@18.5.cmake
rename to host-configs/llnl/toss_3_x86_64_ib/pgi@18.5.cmake
diff --git a/host-configs/llnl-sqa-uno-windows-msvc@15.cmake b/host-configs/llnl/windows/sqa-uno-msvc@15.cmake
similarity index 100%
rename from host-configs/llnl-sqa-uno-windows-msvc@15.cmake
rename to host-configs/llnl/windows/sqa-uno-msvc@15.cmake
diff --git a/host-configs/hcc.cmake b/host-configs/other/hcc.cmake
similarity index 100%
rename from host-configs/hcc.cmake
rename to host-configs/other/hcc.cmake
diff --git a/host-configs/hip.cmake b/host-configs/other/hip.cmake
similarity index 100%
rename from host-configs/hip.cmake
rename to host-configs/other/hip.cmake
diff --git a/host-configs/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake b/host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
similarity index 65%
rename from host-configs/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
rename to host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
index c5084c71c..0cb0a2623 100644
--- a/host-configs/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
+++ b/host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
@@ -3,17 +3,17 @@
#
# SPDX-License-Identifier: (BSD-3-Clause)
-###########################################################
+#------------------------------------------------------------------------------
# Example host-config file for the surface cluster at LLNL
-###########################################################
+#------------------------------------------------------------------------------
#
# This file provides CMake with paths / details for:
# C,C++, & Fortran compilers + MPI & CUDA
-###########################################################
+#------------------------------------------------------------------------------
-###########################################################
+#------------------------------------------------------------------------------
# gcc@4.9.3 compilers
-###########################################################
+#------------------------------------------------------------------------------
# _blt_tutorial_surface_compiler_config_start
set(CMAKE_C_COMPILER "/usr/apps/gnu/4.9.3/bin/gcc" CACHE PATH "")
set(CMAKE_CXX_COMPILER "/usr/apps/gnu/4.9.3/bin/g++" CACHE PATH "")
@@ -23,9 +23,9 @@ set(ENABLE_FORTRAN ON CACHE BOOL "")
set(CMAKE_Fortran_COMPILER "/usr/apps/gnu/4.9.3/bin/gfortran" CACHE PATH "")
# _blt_tutorial_surface_compiler_config_end
-###########################################################
+#------------------------------------------------------------------------------
# MPI Support
-###########################################################
+#------------------------------------------------------------------------------
# _blt_tutorial_surface_mpi_config_start
set(ENABLE_MPI ON CACHE BOOL "")
@@ -36,9 +36,9 @@ set(MPI_CXX_COMPILER "/usr/local/tools/mvapich2-gnu-2.0/bin/mpicc" CACHE PATH ""
set(MPI_Fortran_COMPILER "/usr/local/tools/mvapich2-gnu-2.0/bin/mpif90" CACHE PATH "")
# _blt_tutorial_surface_mpi_config_end
-###########################################################
+#------------------------------------------------------------------------------
# CUDA support
-###########################################################
+#------------------------------------------------------------------------------
# _blt_tutorial_surface_cuda_config_start
set(ENABLE_CUDA ON CACHE BOOL "")
@@ -46,5 +46,5 @@ set(CUDA_TOOLKIT_ROOT_DIR "/opt/cudatoolkit-8.0" CACHE PATH "")
set(CMAKE_CUDA_COMPILER "/opt/cudatoolkit-8.0/bin/nvcc" CACHE PATH "")
set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}" CACHE PATH "")
set(CUDA_SEPARABLE_COMPILATION ON CACHE BOOL "")
-# _blt_tutorial_surface_cuda_config_start
+# _blt_tutorial_surface_cuda_config_end
diff --git a/tests/internal/CMakeLists.txt b/tests/internal/CMakeLists.txt
index 107d4d260..517091c26 100644
--- a/tests/internal/CMakeLists.txt
+++ b/tests/internal/CMakeLists.txt
@@ -3,17 +3,17 @@
#
# SPDX-License-Identifier: (BSD-3-Clause)
-################################
+#------------------------------------------------------------------------------
# BLT Internal Testing Project
-################################
+#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.8)
project(blt-example LANGUAGES C CXX)
-###############################################################################
+#------------------------------------------------------------------------------
# Setup BLT
-###############################################################################
+#------------------------------------------------------------------------------
# Set BLT_SOURCE_DIR to default location, if not set by user
if(NOT BLT_SOURCE_DIR)
set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../..")
@@ -21,19 +21,19 @@ endif()
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
-################################
+#------------------------------------------------------------------------------
# Project options
-################################
+#------------------------------------------------------------------------------
option(TEST_GIT_MACROS
"Toggle smoke tests for git macros. Off by default since it requires a modified git repo."
OFF)
-################################
+#------------------------------------------------------------------------------
# Add a library
-################################
+#------------------------------------------------------------------------------
-blt_add_library( NAME example
+blt_add_library( NAME example
SOURCES "src/Example.cpp"
HEADERS "src/Example.hpp"
)
@@ -43,25 +43,25 @@ if(WIN32 AND BUILD_SHARED_LIBS)
endif()
if(ENABLE_GTEST)
- ################################
+ #------------------------------------------------------
# Add an executable
# (which happens to be a test)
- ################################
+ #------------------------------------------------------
blt_add_executable(
NAME t_example_smoke
SOURCES "src/t_example_smoke.cpp"
DEPENDS_ON example gtest)
- ################################
+ #------------------------------------------------------
# Register our test w/ ctest
- ################################
+ #------------------------------------------------------
blt_add_test(NAME t_example_smoke
COMMAND t_example_smoke)
- ####################
+ #------------------------------------------------------
# Header-only test
- ####################
+ #------------------------------------------------------
blt_add_library(NAME blt_header_only
HEADERS "src/HeaderOnly.hpp")
@@ -76,10 +76,10 @@ if(ENABLE_GTEST)
blt_add_test(NAME t_header_only_smoke
COMMAND t_header_only_smoke)
- ####################################################
+ #------------------------------------------------------
# Tests blt_combine_static_libs macro
# Note: Does not currently work on Windows or BGQ
- ####################################################
+ #------------------------------------------------------
set(_try_combine_static_libs ON)
if(CMAKE_HOST_WIN32)
@@ -94,9 +94,9 @@ if(ENABLE_GTEST)
add_subdirectory( src/combine_static_library_test )
endif ()
- ####################
+ #------------------------------------------------------
# Git Macros test
- ####################
+ #------------------------------------------------------
if ( GIT_FOUND AND TEST_GIT_MACROS)
blt_is_git_repo( OUTPUT_STATE is_git_repo
@@ -140,33 +140,34 @@ if(ENABLE_GTEST)
${CMAKE_BINARY_DIR}/t_git_macros_smoke.cpp )
blt_add_executable(
- NAME t_git_macros_smoke
- SOURCES "${CMAKE_BINARY_DIR}/t_git_macros_smoke.cpp"
+ NAME t_git_macros_smoke
+ SOURCES ${CMAKE_BINARY_DIR}/t_git_macros_smoke.cpp
DEPENDS_ON gtest
)
- blt_add_test( NAME t_git_macros_smoke
+ blt_add_test( NAME t_git_macros_smoke
COMMAND t_git_macros_smoke )
endif() # endif is_git_repo
endif() # endif Git_FOUND
- ################
+ #------------------------------------------------------
# CUDA tests
- #################
+ #------------------------------------------------------
if (ENABLE_CUDA)
add_subdirectory(src/test_cuda_device_call_from_kernel)
endif()
- ########################################################
+ #------------------------------------------------------
# Tests blt_add_target_definitions macro
+ #
# Four variants of a test with a list of two definitions
- ########################################################
- set(_variant_1 A=1 B) # neither use '-D'
- set(_variant_2 -DA=1 -DB) # both uses '-D'
- set(_variant_3 "A=1;-DB") # list passed in as string
- set(_variant_4 " " "-DA=1;B") # list can contain empty strings
+ #------------------------------------------------------
+ set(_variant_1 BLT_A=1 BLT_B) # neither use '-D'
+ set(_variant_2 -DBLT_A=1 -DBLT_B) # both uses '-D'
+ set(_variant_3 "BLT_A=1;-DBLT_B") # list passed in as string
+ set(_variant_4 " " "-DBLT_A=1;BLT_B") # list can contain empty strings
foreach(i RANGE 1 4)
set(_casename "_variant_${i}")
set(_testname "t_example_compile_definitions_test${_casename}")
@@ -185,8 +186,69 @@ if(ENABLE_GTEST)
COMMAND ${_testname})
endforeach()
+ #------------------------------------------------------
+ # Tests the IF clause of the blt_list_append macro
+ #
+ # We expect variables that are not defined to be omitted.
+ # For defined variables, we expect them to be added when
+ # they evaluate to TRUE, whether or not they are escaped.
+ #------------------------------------------------------
+
+ unset(_existing_true_var)
+ unset(_existing_false_var)
+
+ set(_existing_true_var TRUE)
+ set(_existing_false_var FALSE)
+ set(_defined_empty_var "")
+ set(_defined_nonempty_var "")
+ unset(_undefined_var)
+
+ unset(_actual_list) # blt_list_append can work on an initially undefined list
+
+ # The following will be added to the list
+ blt_list_append(TO _actual_list ELEMENTS "true_literal" IF TRUE)
+ blt_list_append(TO _actual_list ELEMENTS "true_nonescaped" IF _existing_true_var)
+ blt_list_append(TO _actual_list ELEMENTS "true_escaped" IF ${_existing_true_var})
+ blt_list_append(TO _actual_list ELEMENTS "nonempty_nonescaped" IF _defined_nonempty_var)
+ set(_expected_list "true_literal" "true_nonescaped" "true_escaped" "nonempty_nonescaped")
+ set(_expected_size 4)
+
+ # The following will not be added to the list
+ blt_list_append(TO _actual_list ELEMENTS "false_literal" IF FALSE)
+ blt_list_append(TO _actual_list ELEMENTS "false_nonescaped" IF _existing_false_var)
+ blt_list_append(TO _actual_list ELEMENTS "false_escaped" IF ${_existing_false_var})
+ blt_list_append(TO _actual_list ELEMENTS "undefined_nonescaped" IF _nonexisting_var)
+ blt_list_append(TO _actual_list ELEMENTS "undefined_escaped" IF ${_nonexisting_var})
+ blt_list_append(TO _actual_list ELEMENTS "empty_nonescaped" IF _defined_empty_var)
+ blt_list_append(TO _actual_list ELEMENTS "empty_escaped" IF ${_defined_empty_var})
+ blt_list_append(TO _actual_list ELEMENTS "nonempty_escaped" IF ${_defined_nonempty_var})
+
+ # Check the results
+ list(LENGTH _actual_list _actual_size)
+ if(NOT "${_actual_list}" STREQUAL "${_expected_list}"
+ OR NOT ${_actual_size} EQUAL ${_expected_size})
+ message(FATAL_ERROR "[blt_list_append] Unexpected evaluation: "
+ "\n\t" "Expected: '${_expected_list}'"
+ "\n\t" "Got: '${_actual_list}'" )
+ endif()
+
endif() # endif ENABLE_GTEST
+if (ENABLE_CUDA AND ENABLE_MPI AND
+ "${BLT_CXX_STD}" MATCHES c\\+\\+1)
+ blt_add_executable(
+ NAME test_cuda_mpi
+ SOURCES src/test_cuda_mpi.cpp
+ DEPENDS_ON cuda mpi hwloc)
+
+ # Tests on a 2^24 elements array.
+ # It can go much bigger, but will not
+ # exceed memory capacity in most computers.
+ blt_add_test(NAME test_cuda_mpi
+ COMMAND test_cuda_mpi 24
+ NUM_MPI_TASKS 4)
+endif()
+
message(STATUS "Exercising blt_print_target_properties macro on some targets and non-targets.")
message(STATUS "")
foreach(_target gtest example t_example_smoke not-a-target blt_header_only mpi)
@@ -198,3 +260,78 @@ add_subdirectory(src/object_library_test)
if(ENABLE_CLANGQUERY)
add_subdirectory(src/static_analysis)
endif()
+
+#------------------------------------------------------------------------------
+# Format the testing code using AStyle
+#------------------------------------------------------------------------------
+if(ASTYLE_FOUND)
+
+ set(smoke_tests_srcs
+ ../smoke/blt_cuda_mpi_smoke.cpp
+ ../smoke/blt_cuda_openmp_smoke.cpp
+ ../smoke/blt_cuda_runtime_smoke.cpp
+ ../smoke/blt_cuda_smoke.cpp
+ ../smoke/blt_fruit_smoke.f90
+ ../smoke/blt_gbenchmark_smoke.cpp
+ ../smoke/blt_gmock_smoke.cpp
+ ../smoke/blt_gtest_smoke.cpp
+ ../smoke/blt_hcc_runtime_smoke.cpp
+ ../smoke/blt_hcc_smoke.cpp
+ ../smoke/blt_hip_runtime_smoke.cpp
+ ../smoke/blt_hip_smoke.cpp
+ ../smoke/blt_mpi_smoke.cpp
+ ../smoke/blt_openmp_smoke.cpp
+ ../smoke/fortran_driver.cpp
+ )
+
+ set(internal_tests_srcs
+ src/Example.cpp
+ src/Example.hpp
+ src/Example_Exports.h
+ src/HeaderOnly.hpp
+
+ src/combine_static_library_test/Foo1.cpp
+ src/combine_static_library_test/Foo1.hpp
+ src/combine_static_library_test/Foo2.cpp
+ src/combine_static_library_test/Foo2.hpp
+ src/combine_static_library_test/Foo3.cpp
+ src/combine_static_library_test/Foo3.hpp
+ src/combine_static_library_test/blt_combine_static_libraries_shared_smoke.cpp
+ src/combine_static_library_test/blt_combine_static_libraries_static_smoke.cpp
+ src/combine_static_library_test/dummy.cpp
+ src/combine_static_library_test/main.cpp
+
+ src/object_library_test/base_object.cpp
+ src/object_library_test/base_object.hpp
+
+ src/object_library_test/inherited_base/inherited_base.cpp
+ src/object_library_test/inherited_base/inherited_base.hpp
+ src/object_library_test/main.cpp
+ src/object_library_test/object.cpp
+ src/object_library_test/object.hpp
+
+ src/static_analysis/well_analyzed_source.cpp
+ src/t_example_compile_definitions.cpp
+ src/t_example_smoke.cpp
+ src/t_header_only_smoke.cpp
+ src/test_cuda_mpi.cpp
+
+ src/test_cuda_device_call_from_kernel/Child.cpp
+ src/test_cuda_device_call_from_kernel/Child.hpp
+ src/test_cuda_device_call_from_kernel/CudaTests.cpp
+ src/test_cuda_device_call_from_kernel/Parent.cpp
+ src/test_cuda_device_call_from_kernel/Parent.hpp
+ )
+
+ blt_add_code_checks(
+ PREFIX smoke_tests
+ SOURCES ${smoke_tests_srcs}
+ ASTYLE_CFG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/astyle.cfg )
+
+ blt_add_code_checks(
+ PREFIX internal_tests
+ SOURCES ${internal_tests_srcs}
+ ASTYLE_CFG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/astyle.cfg )
+
+
+endif()
diff --git a/tests/internal/astyle.cfg b/tests/internal/astyle.cfg
new file mode 100644
index 000000000..2cf713b87
--- /dev/null
+++ b/tests/internal/astyle.cfg
@@ -0,0 +1,13 @@
+--style=allman
+--indent=spaces=2
+--max-code-length=80
+--keep-one-line-statements
+--keep-one-line-blocks
+--indent-preproc-block
+--indent-preproc-cond
+--indent-preproc-define
+--indent-col1-comments
+--indent-labels
+--add-brackets
+--convert-tabs
+--preserve-date
diff --git a/tests/internal/src/Example.cpp b/tests/internal/src/Example.cpp
index 0286a61e7..0aa0b2070 100644
--- a/tests/internal/src/Example.cpp
+++ b/tests/internal/src/Example.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "Example.hpp"
@@ -8,19 +8,18 @@
//------------------------------------------------------------------------------
Example::Example()
{
- // empty
+ // empty
}
//------------------------------------------------------------------------------
Example::~Example()
{
- // empty
+ // empty
}
//------------------------------------------------------------------------------
-bool
-Example::ReturnTrue()
+bool Example::ReturnTrue()
{
- return true;
+ return true;
}
diff --git a/tests/internal/src/Example.hpp b/tests/internal/src/Example.hpp
index 2a4a9812c..d39936e64 100644
--- a/tests/internal/src/Example.hpp
+++ b/tests/internal/src/Example.hpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef _EXAMPLE_HPP_
@@ -11,10 +11,10 @@
//------------------------------------------------------------------------------
class EXAMPLE_API Example
{
- public:
- Example();
- ~Example();
-
- bool ReturnTrue();
+public:
+ Example();
+ ~Example();
+
+ bool ReturnTrue();
};
#endif
diff --git a/tests/internal/src/Example_Exports.h b/tests/internal/src/Example_Exports.h
index 8eade9102..6c5c9413c 100644
--- a/tests/internal/src/Example_Exports.h
+++ b/tests/internal/src/Example_Exports.h
@@ -1,38 +1,38 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef _EXAMPLE_EXPORTS_H_
#define _EXAMPLE_EXPORTS_H_
//-----------------------------------------------------------------------------
-// -- define proper lib exports for various platforms --
+// -- define proper lib exports for various platforms --
//-----------------------------------------------------------------------------
#if defined(_WIN32)
- #if defined(WIN32_SHARED_LIBS)
- #if defined(EXAMPLE_EXPORTS) || defined(example_EXPORTS)
- #define EXAMPLE_API __declspec(dllexport)
- #else
- #define EXAMPLE_API __declspec(dllimport)
- #endif
+ #if defined(WIN32_SHARED_LIBS)
+ #if defined(EXAMPLE_EXPORTS) || defined(example_EXPORTS)
+ #define EXAMPLE_API __declspec(dllexport)
#else
- #define EXAMPLE_API /* not needed for static on windows */
- #endif
- #if defined(_MSC_VER)
- /* Turn off warning about lack of DLL interface */
- #pragma warning(disable:4251)
- /* Turn off warning non-dll class is base for dll-interface class. */
- #pragma warning(disable:4275)
- /* Turn off warning about identifier truncation */
- #pragma warning(disable:4786)
+ #define EXAMPLE_API __declspec(dllimport)
#endif
+ #else
+ #define EXAMPLE_API /* not needed for static on windows */
+ #endif
+ #if defined(_MSC_VER)
+ /* Turn off warning about lack of DLL interface */
+ #pragma warning(disable:4251)
+ /* Turn off warning non-dll class is base for dll-interface class. */
+ #pragma warning(disable:4275)
+ /* Turn off warning about identifier truncation */
+ #pragma warning(disable:4786)
+ #endif
#else
-# if __GNUC__ >= 4 && (defined(EXAMPLE_EXPORTS) || defined(example_EXPORTS))
-# define EXAMPLE_API __attribute__ ((visibility("default")))
-# else
-# define EXAMPLE_API /* hidden by default */
-# endif
+ #if __GNUC__ >= 4 && (defined(EXAMPLE_EXPORTS) || defined(example_EXPORTS))
+ #define EXAMPLE_API __attribute__ ((visibility("default")))
+ #else
+ #define EXAMPLE_API /* hidden by default */
+ #endif
#endif
#endif
diff --git a/tests/internal/src/HeaderOnly.hpp b/tests/internal/src/HeaderOnly.hpp
index 33b207c0e..d23209473 100644
--- a/tests/internal/src/HeaderOnly.hpp
+++ b/tests/internal/src/HeaderOnly.hpp
@@ -1,15 +1,17 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef BLT_HEADER_ONLY_HPP
#define BLT_HEADER_ONLY_HPP
-namespace blt {
+namespace blt
+{
-inline bool ReturnTrue() {
- return true;
+inline bool ReturnTrue()
+{
+ return true;
}
} // end of namespace blt
diff --git a/tests/internal/src/combine_static_library_test/Foo1.cpp b/tests/internal/src/combine_static_library_test/Foo1.cpp
index b6151f789..22b5e4df9 100644
--- a/tests/internal/src/combine_static_library_test/Foo1.cpp
+++ b/tests/internal/src/combine_static_library_test/Foo1.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include
diff --git a/tests/internal/src/combine_static_library_test/Foo1.hpp b/tests/internal/src/combine_static_library_test/Foo1.hpp
index 0da4b9d4b..a6763fdbf 100644
--- a/tests/internal/src/combine_static_library_test/Foo1.hpp
+++ b/tests/internal/src/combine_static_library_test/Foo1.hpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef TESTS_INTERNAL_SRC_COMBINE_STATIC_LIBRARY_TEST_FOO1_HPP_
@@ -16,7 +16,7 @@ class Foo1
public:
Foo1();
~Foo1();
-
+
std::string output();
};
diff --git a/tests/internal/src/combine_static_library_test/Foo2.cpp b/tests/internal/src/combine_static_library_test/Foo2.cpp
index b9f767c0c..0075b7b67 100644
--- a/tests/internal/src/combine_static_library_test/Foo2.cpp
+++ b/tests/internal/src/combine_static_library_test/Foo2.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "Foo2.hpp"
diff --git a/tests/internal/src/combine_static_library_test/Foo2.hpp b/tests/internal/src/combine_static_library_test/Foo2.hpp
index 22a5d39aa..d8a4b5199 100644
--- a/tests/internal/src/combine_static_library_test/Foo2.hpp
+++ b/tests/internal/src/combine_static_library_test/Foo2.hpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef TESTS_INTERNAL_SRC_COMBINE_STATIC_LIBRARY_TEST_FOO2_HPP_
@@ -16,7 +16,7 @@ class Foo2
public:
Foo2();
~Foo2();
-
+
std::string output();
};
diff --git a/tests/internal/src/combine_static_library_test/Foo3.cpp b/tests/internal/src/combine_static_library_test/Foo3.cpp
index be2f83ff3..b500b77da 100644
--- a/tests/internal/src/combine_static_library_test/Foo3.cpp
+++ b/tests/internal/src/combine_static_library_test/Foo3.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "Foo3.hpp"
diff --git a/tests/internal/src/combine_static_library_test/Foo3.hpp b/tests/internal/src/combine_static_library_test/Foo3.hpp
index 1a579914d..e4aa72a43 100644
--- a/tests/internal/src/combine_static_library_test/Foo3.hpp
+++ b/tests/internal/src/combine_static_library_test/Foo3.hpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef TESTS_INTERNAL_SRC_COMBINE_STATIC_LIBRARY_TEST_FOO3_HPP_
diff --git a/tests/internal/src/combine_static_library_test/blt_combine_static_libraries_shared_smoke.cpp b/tests/internal/src/combine_static_library_test/blt_combine_static_libraries_shared_smoke.cpp
index 56a9eaacf..01149851b 100644
--- a/tests/internal/src/combine_static_library_test/blt_combine_static_libraries_shared_smoke.cpp
+++ b/tests/internal/src/combine_static_library_test/blt_combine_static_libraries_shared_smoke.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "gtest/gtest.h"
diff --git a/tests/internal/src/combine_static_library_test/blt_combine_static_libraries_static_smoke.cpp b/tests/internal/src/combine_static_library_test/blt_combine_static_libraries_static_smoke.cpp
index 56a9eaacf..01149851b 100644
--- a/tests/internal/src/combine_static_library_test/blt_combine_static_libraries_static_smoke.cpp
+++ b/tests/internal/src/combine_static_library_test/blt_combine_static_libraries_static_smoke.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "gtest/gtest.h"
diff --git a/tests/internal/src/combine_static_library_test/dummy.cpp b/tests/internal/src/combine_static_library_test/dummy.cpp
index 8d1c8b69c..8b1378917 100644
--- a/tests/internal/src/combine_static_library_test/dummy.cpp
+++ b/tests/internal/src/combine_static_library_test/dummy.cpp
@@ -1 +1 @@
-
+
diff --git a/tests/internal/src/combine_static_library_test/main.cpp b/tests/internal/src/combine_static_library_test/main.cpp
index fbe8cf20f..3f0b0ce35 100644
--- a/tests/internal/src/combine_static_library_test/main.cpp
+++ b/tests/internal/src/combine_static_library_test/main.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include
@@ -8,7 +8,7 @@
#include "Foo2.hpp"
using namespace blt_test;
-int main( int , char ** )
+int main( int, char ** )
{
Foo1 foo1;
Foo2 foo2;
diff --git a/tests/internal/src/object_library_test/base_object.cpp b/tests/internal/src/object_library_test/base_object.cpp
index bde85c499..8db69bc10 100644
--- a/tests/internal/src/object_library_test/base_object.cpp
+++ b/tests/internal/src/object_library_test/base_object.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "base_object.hpp"
@@ -8,10 +8,10 @@
int base_number()
{
-#ifdef INHERITED_FLAG
- return inherited_number() + 2;
-#else
- // should not get here
- return 0;
-#endif
+ #ifdef INHERITED_FLAG
+ return inherited_number() + 2;
+ #else
+ // should not get here
+ return 0;
+ #endif
}
diff --git a/tests/internal/src/object_library_test/base_object.hpp b/tests/internal/src/object_library_test/base_object.hpp
index d88cb4329..472df43e1 100644
--- a/tests/internal/src/object_library_test/base_object.hpp
+++ b/tests/internal/src/object_library_test/base_object.hpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef BASE_OBJECT_HPP
diff --git a/tests/internal/src/object_library_test/inherited_base/inherited_base.cpp b/tests/internal/src/object_library_test/inherited_base/inherited_base.cpp
index a3551ef8f..cae6480fb 100644
--- a/tests/internal/src/object_library_test/inherited_base/inherited_base.cpp
+++ b/tests/internal/src/object_library_test/inherited_base/inherited_base.cpp
@@ -1,11 +1,11 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "inherited_base.hpp"
int inherited_number()
{
- return 3;
+ return 3;
}
diff --git a/tests/internal/src/object_library_test/inherited_base/inherited_base.hpp b/tests/internal/src/object_library_test/inherited_base/inherited_base.hpp
index 491683d50..36f978ebd 100644
--- a/tests/internal/src/object_library_test/inherited_base/inherited_base.hpp
+++ b/tests/internal/src/object_library_test/inherited_base/inherited_base.hpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef INHERITED_OBJECT_HPP
diff --git a/tests/internal/src/object_library_test/main.cpp b/tests/internal/src/object_library_test/main.cpp
index 28a4d3b7c..dc0c31c65 100644
--- a/tests/internal/src/object_library_test/main.cpp
+++ b/tests/internal/src/object_library_test/main.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "object.hpp"
@@ -10,40 +10,47 @@
int main()
{
- bool failed = false;
+ bool failed = false;
- int number = object_number();
- if(number != 6) {
- std::cerr << "Error:"
- << number
- << " was returned from all libraries."
- << std::endl
- << "6 was the correct number."
- << std::endl;
- failed = true;
- } else {
- std::cout << number
- << " was correctly returned from all libraries."
- << std::endl;
- }
+ int number = object_number();
+ if(number != 6)
+ {
+ std::cerr << "Error:"
+ << number
+ << " was returned from all libraries."
+ << std::endl
+ << "6 was the correct number."
+ << std::endl;
+ failed = true;
+ }
+ else
+ {
+ std::cout << number
+ << " was correctly returned from all libraries."
+ << std::endl;
+ }
- int iNumber = inherited_number();
- if(iNumber != 3) {
- std::cerr << "Error:"
- << iNumber
- << " was returned from the inherited library."
- << std::endl
- << "3 was the correct number."
- << std::endl;
- failed = true;
- } else {
- std::cout << iNumber
- << " was correctly returned from inherited library."
- << std::endl;
- }
+ int iNumber = inherited_number();
+ if(iNumber != 3)
+ {
+ std::cerr << "Error:"
+ << iNumber
+ << " was returned from the inherited library."
+ << std::endl
+ << "3 was the correct number."
+ << std::endl;
+ failed = true;
+ }
+ else
+ {
+ std::cout << iNumber
+ << " was correctly returned from inherited library."
+ << std::endl;
+ }
- if (failed){
- return 1;
- }
- return 0;
+ if (failed)
+ {
+ return 1;
+ }
+ return 0;
}
diff --git a/tests/internal/src/object_library_test/object.cpp b/tests/internal/src/object_library_test/object.cpp
index d664d57c6..0997719e8 100644
--- a/tests/internal/src/object_library_test/object.cpp
+++ b/tests/internal/src/object_library_test/object.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "base_object.hpp"
@@ -8,5 +8,5 @@
int object_number()
{
- return 1 + base_number();
+ return 1 + base_number();
}
diff --git a/tests/internal/src/object_library_test/object.hpp b/tests/internal/src/object_library_test/object.hpp
index c308fab96..b8dcaf497 100644
--- a/tests/internal/src/object_library_test/object.hpp
+++ b/tests/internal/src/object_library_test/object.hpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef OBJECT_HPP
diff --git a/tests/internal/src/static_analysis/well_analyzed_source.cpp b/tests/internal/src/static_analysis/well_analyzed_source.cpp
index e7eb66eb9..ab7f6edd0 100644
--- a/tests/internal/src/static_analysis/well_analyzed_source.cpp
+++ b/tests/internal/src/static_analysis/well_analyzed_source.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
/**
@@ -16,9 +16,9 @@
* Will run a matcher "match if-stmt" and produce the output
*
* [100%] Running specified clang_query source code static analysis checks.
- *
+ *
* Match #1:
- *
+ *
* /blt/root/dir/blt/tests/internal/src/static_analysis/well_analyzed_source.cpp:2:2: note: "root" binds here
* if(true){}
* ^~~~~~~~~~
@@ -28,9 +28,10 @@
*
* Will open up the clang-query REPL (Interpreter) and allow you to write your own queries in the language
* described here, but which can mostly be learned through tab completion in that interpreter:
- *
+ *
* https://clang.llvm.org/docs/LibASTMatchersReference.html
*/
-int main(){
- if(true){}
+int main()
+{
+ if(true) {}
}
diff --git a/tests/internal/src/t_example_compile_definitions.cpp b/tests/internal/src/t_example_compile_definitions.cpp
index f83115122..3d0b185df 100644
--- a/tests/internal/src/t_example_compile_definitions.cpp
+++ b/tests/internal/src/t_example_compile_definitions.cpp
@@ -1,28 +1,28 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "gtest/gtest.h"
//------------------------------------------------------------------------------
-// Simple test that expects symbol A to be defined as a non-zero number
-TEST(blt_compile_definitions,check_A_defined)
+// Simple test that expects symbol BLT_A to be defined as a non-zero number
+TEST(blt_compile_definitions,check_BLT_A_defined)
{
-#if A
- SUCCEED();
-#else
- FAIL() << "Compiler define A was not defined as a non-zero number";
-#endif
+ #if BLT_A
+ SUCCEED();
+ #else
+ FAIL() << "Compiler define A was not defined as a non-zero number";
+ #endif
}
-// Simple test that expects symbol B to be defined
-TEST(blt_compile_definitions,check_B_defined)
+// Simple test that expects symbol BLT_B to be defined
+TEST(blt_compile_definitions,check_BLT_B_defined)
{
-#ifdef B
- SUCCEED();
-#else
- FAIL() << "Compiler define B was not defined";
-#endif
+ #ifdef BLT_B
+ SUCCEED();
+ #else
+ FAIL() << "Compiler define B was not defined";
+ #endif
}
diff --git a/tests/internal/src/t_example_smoke.cpp b/tests/internal/src/t_example_smoke.cpp
index 2ec0af018..caa2d17d9 100644
--- a/tests/internal/src/t_example_smoke.cpp
+++ b/tests/internal/src/t_example_smoke.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "gtest/gtest.h"
@@ -10,7 +10,7 @@
TEST(blt_gtest_smoke,basic_assert_example)
{
- Example e;
+ Example e;
- EXPECT_TRUE( e.ReturnTrue() );
+ EXPECT_TRUE( e.ReturnTrue() );
}
diff --git a/tests/internal/src/t_header_only_smoke.cpp b/tests/internal/src/t_header_only_smoke.cpp
index 7ff4a6ffd..2aef8efc9 100644
--- a/tests/internal/src/t_header_only_smoke.cpp
+++ b/tests/internal/src/t_header_only_smoke.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "gtest/gtest.h"
@@ -8,5 +8,5 @@
TEST(blt_header_only_smoke,basic_assert_example)
{
- EXPECT_TRUE( blt::ReturnTrue() );
+ EXPECT_TRUE( blt::ReturnTrue() );
}
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/CMakeLists.txt b/tests/internal/src/test_cuda_device_call_from_kernel/CMakeLists.txt
index 752c676e1..5e242f732 100644
--- a/tests/internal/src/test_cuda_device_call_from_kernel/CMakeLists.txt
+++ b/tests/internal/src/test_cuda_device_call_from_kernel/CMakeLists.txt
@@ -3,27 +3,26 @@
#
# SPDX-License-Identifier: (BSD-3-Clause)
-#####################################
+#------------------------------------------------------------------------------
# Test CUDA virtual device method call from kernels across library boundary
-# CUDA needs to be enabled, with appropriate Flags set up for building and running
-# on your current GPU architecture.
-#####################################
+# CUDA needs to be enabled, with appropriate Flags set up for building and
+# running on your current GPU architecture.
+#------------------------------------------------------------------------------
set(t_cuda_device_call_from_kernel_headers
- Child.h
- Parent.h)
+ Child.hpp
+ Parent.hpp)
set(t_cuda_device_call_from_kernel_sources
- Child.cxx
- Parent.cxx)
+ Child.cpp
+ Parent.cpp)
blt_add_library(NAME t_cuda_device_call_from_kernel_lib
SOURCES ${t_cuda_device_call_from_kernel_sources}
HEADERS ${t_cuda_device_call_from_kernel_headers}
- DEPENDS_ON cuda
- )
+ DEPENDS_ON cuda)
set(t_cuda_device_call_from_kernel_exec_src
- CudaTests.cxx)
+ CudaTests.cpp)
blt_add_executable( NAME t_cuda_device_call_from_kernel_exec
SOURCES ${t_cuda_device_call_from_kernel_exec_src}
@@ -32,4 +31,3 @@ blt_add_executable( NAME t_cuda_device_call_from_kernel_exec
blt_add_test(NAME t_cuda_device_call_from_kernel
COMMAND t_cuda_device_call_from_kernel_exec)
-
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/Child.cpp b/tests/internal/src/test_cuda_device_call_from_kernel/Child.cpp
new file mode 100644
index 000000000..03009801e
--- /dev/null
+++ b/tests/internal/src/test_cuda_device_call_from_kernel/Child.cpp
@@ -0,0 +1,51 @@
+// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+// other BLT Project Developers. See the top-level COPYRIGHT file for details
+//
+// SPDX-License-Identifier: (BSD-3-Clause)
+
+#include
+#include "Child.hpp"
+
+__global__ void kernelCreateChild(Parent **myGpuParent,
+ double a, double b,
+ double c, double d)
+{
+ *myGpuParent = new Child(a, b, c, d);
+}
+
+__host__ __device__ Child::Child(double a, double b, double c, double d)
+ : Parent("", 0)
+ , m_a(a)
+ , m_b(b)
+ , m_c(c)
+ , m_d(d)
+{
+ #ifndef __CUDA_ARCH__
+ cudaMalloc(&(m_gpuParent), sizeof(Parent **));
+
+ kernelCreateChild<<<1,1>>>(m_gpuParent, a, b, c, d);
+ cudaDeviceSynchronize();
+ #endif
+}
+
+__host__ __device__ Child::~Child()
+{
+}
+
+__host__ __device__
+double Child::Evaluate(const double ain, const double bin,
+ const double cin, const double din) const
+{
+ double bb, cc;
+ double e = 0.0;
+
+ e = (din-m_d);
+ e = (ain-m_a);
+ e = (bin-m_b);
+ e = (cin-m_c);
+ bb = (bin-m_b);
+ cc = (cin-m_c);
+ e = sqrt(bb*bb+cc*cc);
+
+ return e;
+}
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/Child.cxx b/tests/internal/src/test_cuda_device_call_from_kernel/Child.cxx
deleted file mode 100644
index 25a70eb9f..000000000
--- a/tests/internal/src/test_cuda_device_call_from_kernel/Child.cxx
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
-// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
-// SPDX-License-Identifier: (BSD-3-Clause)
-
-#include
-#include "Child.h"
-
-__global__ void kernelCreateChild(Parent **myGpuParent, double a, double b, double c, double d)
-{
- *myGpuParent = new Child(a, b, c, d);
-}
-
-__host__ __device__ Child::Child(double a, double b, double c, double d)
- : Parent("", 0),
- m_a(a),
- m_b(b),
- m_c(c),
- m_d(d)
-{
-#ifndef __CUDA_ARCH__
- cudaMalloc(&(m_gpuParent), sizeof(Parent **));
-
- kernelCreateChild<<<1,1>>>(m_gpuParent, a, b, c, d);
- cudaDeviceSynchronize();
-#endif
-}
-
-__host__ __device__ Child::~Child()
-{
-}
-
-__host__ __device__ double Child::Evaluate(const double ain, const double bin, const double cin, const double din) const
-{
- double bb, cc;
- double e = 0.0;
-
- e = (din-m_d);
- e = (ain-m_a);
- e = (bin-m_b);
- e = (cin-m_c);
- bb = (bin-m_b);
- cc = (cin-m_c);
- e = sqrt(bb*bb+cc*cc);
-
- return e;
-}
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/Child.h b/tests/internal/src/test_cuda_device_call_from_kernel/Child.h
deleted file mode 100644
index 367ccb7c2..000000000
--- a/tests/internal/src/test_cuda_device_call_from_kernel/Child.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
-// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
-// SPDX-License-Identifier: (BSD-3-Clause)
-
-#ifndef __Child_h
-#define __Child_h
-
-#include "Parent.h"
-
-class Child : public Parent {
- public:
- __host__ __device__ Child(double a, double b, double c, double d);
-
- __host__ __device__ virtual ~Child() ;
-
- __host__ __device__ double Evaluate(const double ain, const double bin, const double cin, const double din) const;
-
- __host__ __device__ inline double Evaluate(const double *args) const { return Evaluate(args[0], args[1], args[2], args[3]) ; }
-
- private:
- double m_a, m_b, m_c, m_d;
-};
-
-#endif
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/Child.hpp b/tests/internal/src/test_cuda_device_call_from_kernel/Child.hpp
new file mode 100644
index 000000000..e148050bd
--- /dev/null
+++ b/tests/internal/src/test_cuda_device_call_from_kernel/Child.hpp
@@ -0,0 +1,30 @@
+// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+// other BLT Project Developers. See the top-level COPYRIGHT file for details
+//
+// SPDX-License-Identifier: (BSD-3-Clause)
+
+#ifndef __Child_h
+#define __Child_h
+
+#include "Parent.hpp"
+
+class Child : public Parent
+{
+public:
+ __host__ __device__ Child(double a, double b, double c, double d);
+
+ __host__ __device__ virtual ~Child() ;
+
+ __host__ __device__ double Evaluate(const double ain, const double bin,
+ const double cin, const double din) const;
+
+ __host__ __device__ inline double Evaluate(const double *args) const
+ {
+ return Evaluate(args[0], args[1], args[2], args[3]) ;
+ }
+
+private:
+ double m_a, m_b, m_c, m_d;
+};
+
+#endif
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/CudaTests.cpp b/tests/internal/src/test_cuda_device_call_from_kernel/CudaTests.cpp
new file mode 100644
index 000000000..2ee6aa53d
--- /dev/null
+++ b/tests/internal/src/test_cuda_device_call_from_kernel/CudaTests.cpp
@@ -0,0 +1,38 @@
+// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+// other BLT Project Developers. See the top-level COPYRIGHT file for details
+//
+// SPDX-License-Identifier: (BSD-3-Clause)
+
+#include
+#include "Parent.hpp"
+#include "Child.hpp"
+
+inline void gpuAssert(cudaError_t code, const char *file, int line,
+ bool abort=true)
+{
+ if (code != cudaSuccess)
+ {
+ fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
+ if (abort)
+ {
+ exit(code);
+ }
+ }
+}
+__global__ void kernelApply(Parent** myGpuParent)
+{
+ double *input = new double[4];
+ input[0] = 1.0;
+ input[1] = 2.0;
+ input[2] = 3.0;
+ input[3] = 4.0;
+ (*myGpuParent)->Evaluate(input);
+}
+
+int main(void)
+{
+ Child *c = new Child(0.0, 0.0, 0.0, 0.0);
+ kernelApply<<<1, 1>>>(c->m_gpuParent);
+ gpuAssert(cudaDeviceSynchronize(),__FILE__,__LINE__);
+ return 0;
+}
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/CudaTests.cxx b/tests/internal/src/test_cuda_device_call_from_kernel/CudaTests.cxx
deleted file mode 100644
index bf766ac23..000000000
--- a/tests/internal/src/test_cuda_device_call_from_kernel/CudaTests.cxx
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
-// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
-// SPDX-License-Identifier: (BSD-3-Clause)
-
-#include
-#include "Parent.h"
-#include "Child.h"
-
-inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
-{
- if (code != cudaSuccess) {
- fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
- if (abort) {
- exit(code);
- }
- }
-}
-__global__ void kernelApply(Parent** myGpuParent)
-{
- double *input = new double[4];
- input[0] = 1.0;
- input[1] = 2.0;
- input[2] = 3.0;
- input[3] = 4.0;
- (*myGpuParent)->Evaluate(input);
-}
-
-int main(void)
-{
- Child *c = new Child(0.0, 0.0, 0.0, 0.0);
- kernelApply<<<1, 1>>>(c->m_gpuParent);
- gpuAssert(cudaDeviceSynchronize(),__FILE__,__LINE__);
- return 0;
-}
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/Parent.cxx b/tests/internal/src/test_cuda_device_call_from_kernel/Parent.cpp
similarity index 83%
rename from tests/internal/src/test_cuda_device_call_from_kernel/Parent.cxx
rename to tests/internal/src/test_cuda_device_call_from_kernel/Parent.cpp
index bb04ca7e6..0ca76ce8a 100644
--- a/tests/internal/src/test_cuda_device_call_from_kernel/Parent.cxx
+++ b/tests/internal/src/test_cuda_device_call_from_kernel/Parent.cpp
@@ -1,15 +1,14 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
-#include "Parent.h"
+#include "Parent.hpp"
#include
__host__ __device__ Parent::Parent(const char *id, int order)
- :
- m_gpuParent(NULL),
- m_gpuExtractedParents(NULL)
+ : m_gpuParent(NULL)
+ , m_gpuExtractedParents(NULL)
{}
__global__ void kernelDelete(Parent** myGpuParent) {}
diff --git a/tests/internal/src/test_cuda_device_call_from_kernel/Parent.h b/tests/internal/src/test_cuda_device_call_from_kernel/Parent.hpp
similarity index 51%
rename from tests/internal/src/test_cuda_device_call_from_kernel/Parent.h
rename to tests/internal/src/test_cuda_device_call_from_kernel/Parent.hpp
index d34120cef..eb10ee708 100644
--- a/tests/internal/src/test_cuda_device_call_from_kernel/Parent.h
+++ b/tests/internal/src/test_cuda_device_call_from_kernel/Parent.hpp
@@ -1,20 +1,21 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#ifndef __Parent_h
#define __Parent_h
-class Parent {
- public:
+class Parent
+{
+public:
- Parent** m_gpuParent;
- Parent*** m_gpuExtractedParents;
+ Parent** m_gpuParent;
+ Parent*** m_gpuExtractedParents;
- __host__ __device__ Parent(const char *id, int order);
+ __host__ __device__ Parent(const char *id, int order);
- __host__ __device__ virtual double Evaluate(const double * args) const = 0;
+ __host__ __device__ virtual double Evaluate(const double * args) const = 0;
};
diff --git a/tests/internal/src/test_cuda_mpi.cpp b/tests/internal/src/test_cuda_mpi.cpp
new file mode 100644
index 000000000..975cc3439
--- /dev/null
+++ b/tests/internal/src/test_cuda_mpi.cpp
@@ -0,0 +1,418 @@
+
+// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+// other BLT Project Developers. See the top-level COPYRIGHT file for details
+//
+// SPDX-License-Identifier: (BSD-3-Clause)
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+// Note: This is a simple CUDA/MPI example
+// The program generates an arbitrarily (very) large array of floats, it
+// initializes it only locally on the master MPI rank (rank 0) to the value 998.
+// It then splits it into chunks that the master MPI rank sends to the slave
+// ranks. Each rank will run individually a simple CUDA kernel that will add 1
+// to each element of their respective local array chunks and sends the
+// modified array back to the master MPI rank, that will update the dataset.
+// If all elements of the initial large array contain the value 999, the
+// program has been completed successfully. If not, it will give you a
+// detailed error.
+//
+// Technical notes:
+// - This program uses hwloc for determining CPU and GPU affinities.
+// - This program does NOT currently support MPI sends above INT_MAX elements.
+// - Tested successfully on multiGPU/multiNode configurations.
+// - MPI calls are in C99 style, although it is a C++ source code
+//
+// Code design notes:
+// This program is a realistic example of what the skeleton of production
+// codes using CUDA and MPI look like.
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+
+//-----------------------------------------------------------------------------
+//
+// file: test_cuda_mpi.cpp
+//
+//-----------------------------------------------------------------------------
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// This macro is to report the CUDA errors it can detect in a nice readable form.
+#define cuChk(call) \
+ { \
+ const cudaError_t cudaError = call; \
+ if (cudaError != cudaSuccess) \
+ { \
+ printf("\nError %s: %d, ", __FILE__, __LINE__ ); \
+ printf("Code %d, reason %s\n", cudaError, cudaGetErrorString(cudaError)); \
+ exit(1); \
+ } \
+ } \
+
+// Simple CUDA kernel adding 1 to each element of an existing array
+__global__ void addOne(float* a, int bufsize)
+{
+ // The size_t type is needed to avoid memory address overflows with large arrays
+ size_t index = blockIdx.x * blockDim.x + threadIdx.x;
+ size_t stride = blockDim.x * gridDim.x;
+ size_t sbufsize = (size_t) bufsize;
+ for (size_t i = index; i < sbufsize; i+=stride)
+ {
+ a[i]+=1.f;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ hwloc_topology_t topology;
+ hwloc_cpuset_t cpuset;
+ // Initial values are set negative for early error detection.
+ int cpu = -1; int ii = -1;
+ int rank = -1, local_rank = -1, totalRanks = -1;
+ int cuDevice = -1;
+
+ int Npower = 0; // Stores power of 2 for the number of elements
+
+ // Do not mess with the following lines unless you know what you are doing
+ // --------------------------------------------------------------------------------------
+ #ifdef OPEN_MPI
+ rank = atoi(std::getenv("OMPI_COMM_WORLD_RANK"));
+ local_rank = atoi(std::getenv("OMPI_COMM_WORLD_LOCAL_RANK"));
+ #endif
+
+ #ifdef MPICH
+ rank = atoi(std::getenv("MV2_COMM_WORLD_RANK"));
+ local_rank = atoi(std::getenv("MV2_COMM_WORLD_LOCAL_RANK"));
+ #endif
+
+ if (rank < 0 || local_rank < 0)
+ {
+ std::cout << "FATAL ERROR: MPI LIBRARY NOT SUPPORTED. EXITING ..." << std::endl;
+ std::cout << "This program only supports "
+ << "Open MPI, MPICH, MVAPICH2 and compatible" << std::endl;
+ exit(-1);
+ }
+
+ // --------------------------------------------------------------------------------------
+
+ if (rank == 0) { std::cout << "*** Simple CUDA+MPI smoke test for BLT ***" << std::endl << std::endl; }
+
+ hwloc_topology_init(&topology); // Creates a hwloc topology
+ // Gets the topology of the system, including attached devices
+ hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_IO);
+ hwloc_topology_load(topology);
+
+ int cuDevCount = 0;
+ cuChk(cudaGetDeviceCount(&cuDevCount));
+
+ // For each local rank (rank running on each node), select CUDA device number matching the rank number
+ cuChk(cudaSetDevice(local_rank % cuDevCount));
+ cuChk(cudaGetDevice(&cuDevice)); // Get properties of the currently selected GPU
+
+ // Select cores in node and get the logical processors near the selected GPU
+ cpuset = hwloc_bitmap_alloc();
+ hwloc_cudart_get_device_cpuset(topology, cuDevice, cpuset);
+
+ // Cycle through all logical processors in the cpuset.
+ // * NOTE: This is a preprocessor MACRO. No terminating semicolon. *
+ int match = 0;
+ hwloc_bitmap_foreach_begin(ii, cpuset)
+
+ if (match == local_rank)
+ {
+ cpu = ii;
+ break;
+ }
+ // * NOTE: This is a preprocessor MACRO too, but needs a terminating semicolon. *
+ hwloc_bitmap_foreach_end();
+
+ hwloc_bitmap_t onecpu = hwloc_bitmap_alloc();
+ hwloc_bitmap_set(onecpu, cpu);
+ hwloc_set_cpubind(topology, onecpu, 0);
+
+ hwloc_bitmap_free(onecpu);
+ hwloc_bitmap_free(cpuset);
+ hwloc_topology_destroy(topology);
+
+ char hostname[MPI_MAX_PROCESSOR_NAME];
+ gethostname(hostname, sizeof(hostname));
+ cpu = sched_getcpu();
+
+
+ // -------------------------------- MPI REGION BEGINS
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &totalRanks);
+ char procname[MPI_MAX_PROCESSOR_NAME];
+ int length;
+ if (MPI_SUCCESS != MPI_Get_processor_name(procname, &length))
+ {
+ strcpy(procname, "unknown");
+ }
+
+ if (argc == 2) // If we have one exact command line argument ...
+ {
+ Npower = atoi(argv[1]);
+ }
+ else // else ignore everything
+ {
+ Npower = 10; // Sets a default value in case no command line argument is specified
+ }
+ size_t N = (size_t) 1 << Npower; // Allocates 2^Npower entries
+ size_t Nbytes = N * (size_t) sizeof(float);
+
+ size_t cudaStreams = (size_t) totalRanks;
+ size_t sbufsize = (N/cudaStreams) + (N % cudaStreams);
+
+ std::cout << "MPI rank " << rank << " using GPU " << cuDevice << " and CPU " <<
+ cpu << " on host " << hostname << std::endl;
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if ( rank == 0 && sbufsize > (size_t) INT_MAX )
+ {
+ printf("Bufsize requested: %lu\n", sbufsize);
+ printf("Maximum bufsize currently supported: %d\n", INT_MAX);
+ printf("Retry to run the program with more MPI ranks\n");
+ printf("Exiting ...\n\n\n");
+ exit(-1);
+ }
+ int bufsize = (int) sbufsize;
+
+ // CUDA Kernel run parameters
+ dim3 block(1024);
+ dim3 grid((bufsize+block.x-1)/block.x);
+ float *h_master;
+
+ // Gets free and total memory of each GPU device
+ size_t devFreeMem, devTotMem;
+ cuChk( cudaMemGetInfo(&devFreeMem, &devTotMem) );
+
+ std::cout << "Device " << cuDevice << " on host " << hostname << " has "
+ << devFreeMem/(1 << 20) << " MB of free memory" << std::endl;
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ // Fills the master array with synthetic data (an array of ones)
+ if (rank == 0)
+ {
+ // This is some eye-candy to have dynamic units for memory
+ size_t szkB = (size_t) 1 << 10;
+ size_t szMB = (size_t) 1 << 20;
+ size_t szGB = (size_t) 1 << 30;
+
+ char NbytesScale[4][3] = {" B", "kB", "MB", "GB"};
+ int scaleIdx = 3;
+ size_t NbytesScaled = Nbytes/szGB;
+ if (NbytesScaled == 0)
+ {
+ NbytesScaled = Nbytes/szMB;
+ scaleIdx = 2;
+ if (NbytesScaled == 0)
+ {
+ NbytesScaled = Nbytes/szkB;
+ scaleIdx = 1;
+ if (Nbytes/szkB == 0)
+ {
+ NbytesScaled = Nbytes;
+ scaleIdx = 0;
+ }
+ }
+ }
+ std::cout << std::endl << "Elements in N: " << N << "\t Required memory: "
+ << NbytesScaled << " " << NbytesScale[scaleIdx] << std::endl;
+ h_master = (float *) malloc(Nbytes);
+ for (size_t i = 0U; i < N; ++i)
+ {
+ h_master[i] = 998.0f;
+ // Displays progress of filling the bigmem array as a percentage.
+ // * This eye-candy slows the process down a bit, but for large memory
+ // * allocations it will let you know if the program si stuck or is
+ // * actually doing something.
+ if (i % (1 << 24) == 0 || i > N - (1 << 2))
+ {
+ size_t iN = ((i+1)*100)/N;
+ printf("Filling master array ... %lu%% completed. \r", iN);
+ }
+ }
+ std::cout << std::endl;
+ }
+
+ // This is needed to allow the master array to fill before MPI Communication can occur safely
+ MPI_Barrier(MPI_COMM_WORLD);
+ // Uncomment below as needed
+
+ if (rank == 0 ) // Some runtime info
+ {
+ std::cout << " INT_MAX = " << INT_MAX << std::endl;
+ std::cout << " bufsize = " << bufsize << std::endl;
+ std::cout << " bufByte = " << (size_t) (bufsize * sizeof(float)) << std::endl;
+ std::cout << "blockSize = " << block.x << std::endl;
+ std::cout << "numBlocks = " << grid.x << std::endl;
+ }
+
+
+ // rank-local variables for storing chunks of the master array
+ float *h_buf=NULL;
+ float *d_buf=NULL;
+
+
+ // No CUDA streams, no party!
+ cudaStream_t cuStreams[cudaStreams];
+ cuChk(cudaStreamCreate(&cuStreams[rank]));
+
+ // This is needed for pinned memory access
+ cuChk(cudaHostAlloc(&h_buf, bufsize * sizeof(float), cudaHostAllocPortable));
+ cuChk(cudaMalloc(&d_buf, bufsize * sizeof(float)));
+
+ cuChk(cudaMemGetInfo(&devFreeMem, &devTotMem));
+ std::cout << "Device " << cuDevice << " on host " << hostname << " has "
+ << devFreeMem/(1<<20) << " MB of free memory" << std::endl;
+
+ MPI_Request sreq, rreq;
+
+ if (rank == 0)
+ {
+ for (int j = 1; j < totalRanks; j++)
+ {
+ for (size_t i = 0; i < sbufsize; ++i)
+ {
+ size_t Nchunk = i + sbufsize * (size_t) j;
+ if (Nchunk < N)
+ {
+ h_buf[i] = h_master[Nchunk];
+ }
+ }
+ std::cout << "MPI_Isend from rank " << rank << " to rank " << j << " ... ";
+ MPI_Isend(h_buf, bufsize, MPI_FLOAT, j, 0, MPI_COMM_WORLD, &sreq);
+ MPI_Status mpiStatus;
+ MPI_Wait(&sreq, &mpiStatus);
+ std::cout << "Done!" << std::endl;
+ }
+
+ for (size_t i = 0; i < sbufsize; ++i)
+ {
+ h_buf[i] = h_master[i];
+ }
+ cuChk(cudaMemcpy(d_buf, h_buf, bufsize*sizeof(float), cudaMemcpyHostToDevice));
+ std::cout << "Rank " << rank << ": launching CUDA kernels ... ";
+ addOne<<>>(d_buf, bufsize);
+ cudaError_t cuErr = cudaGetLastError();
+ std::cout << cudaGetErrorString(cuErr) <>>(d_buf, bufsize);
+ cudaError_t cuErr = cudaGetLastError();
+ std::cout << cudaGetErrorString(cuErr) < 0)
+ {
+ printf("Rank %d returns h_buf[%lu] = %10.5f\n", rank, i, h_buf[i]);
+ iErr--;
+ }
+ else
+ {
+ exit(-1);
+ }
+ }
+ }
+
+ MPI_Request sreq;
+ MPI_Status mpiStatus;
+ std::cout << "Rank " << rank << " MPI_Isend to rank 0 ...";
+ MPI_Isend(h_buf, bufsize, MPI_FLOAT, 0, 0, MPI_COMM_WORLD, &sreq);
+ MPI_Wait(&sreq, &mpiStatus);
+ std::cout << "Done!" << std::endl;
+ }
+
+ if (rank == 0)
+ {
+ for (int j = 1; j < totalRanks; j++)
+ {
+ MPI_Status mpiStatus;
+ MPI_Irecv(h_buf, bufsize, MPI_FLOAT, j, 0, MPI_COMM_WORLD, &rreq);
+ MPI_Wait(&rreq, &mpiStatus);
+ for (int bi = 0; bi < bufsize; bi++)
+ {
+ size_t bufIdx = (size_t) bi + (size_t) j * (size_t) (bufsize);
+ if (bufIdx < N)
+ {
+ h_master[bufIdx] = h_buf[bi];
+ }
+ if (bufIdx >= N) { break; }
+ }
+ }
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (rank == 0)
+ {
+ int passedBool = 1;
+ int errLines = 10;
+ std::cout << "Validating the result ... ";
+ for (size_t i = 0; i < N; ++i)
+ {
+ if (h_master[i] != 999.0)
+ {
+ std::cout << "Something is wrong: h_master[" << i << "] = " << h_master[i]
+ << " instead of 999.0" << std::endl;
+ passedBool = 0;
+ errLines--;
+ if (errLines == 0)
+ {
+ MPI_Finalize();
+ exit(-1);
+ }
+ }
+ }
+ if (passedBool) { std::cout << "PASSED!" << std::endl; }
+ }
+
+ cuChk(cudaFree(d_buf));
+ cuChk(cudaFreeHost(h_buf));
+ if (rank == 0) { free(h_master); }
+ MPI_Finalize();
+ return 0;
+}
diff --git a/tests/smoke/CMakeLists.txt b/tests/smoke/CMakeLists.txt
index e84e40e3e..88449a1fa 100644
--- a/tests/smoke/CMakeLists.txt
+++ b/tests/smoke/CMakeLists.txt
@@ -78,8 +78,11 @@ if (ENABLE_OPENMP)
FOLDER blt/tests )
# _blt_tutorial_openmp_executable_end
- blt_add_test(NAME blt_openmp_smoke
- COMMAND blt_openmp_smoke)
+ # _blt_tutorial_openmp_test_start
+ blt_add_test(NAME blt_openmp_smoke
+ COMMAND blt_openmp_smoke
+ NUM_OMP_THREADS 4)
+ # _blt_tutorial_openmp_test_end
endif()
@@ -99,7 +102,7 @@ if (ENABLE_MPI)
endif()
################
-# CUDA test
+# CUDA tests
################
if (ENABLE_CUDA)
blt_add_executable(NAME blt_cuda_smoke
@@ -130,6 +133,17 @@ if (ENABLE_CUDA)
blt_add_test(NAME blt_cuda_openmp_smoke
COMMAND blt_cuda_openmp_smoke)
endif()
+
+ if (ENABLE_MPI)
+ blt_add_executable(NAME blt_cuda_mpi_smoke
+ SOURCES blt_cuda_mpi_smoke.cpp
+ OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY}
+ DEPENDS_ON cuda mpi
+ FOLDER blt/tests )
+ blt_add_test(NAME blt_cuda_mpi_smoke
+ COMMAND blt_cuda_mpi_smoke
+ NUM_MPI_TASKS 4)
+ endif()
endif()
################
diff --git a/tests/smoke/blt_cuda_mpi_smoke.cpp b/tests/smoke/blt_cuda_mpi_smoke.cpp
new file mode 100644
index 000000000..d1f0ed0e4
--- /dev/null
+++ b/tests/smoke/blt_cuda_mpi_smoke.cpp
@@ -0,0 +1,68 @@
+// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
+// other BLT Project Developers. See the top-level COPYRIGHT file for details
+//
+// SPDX-License-Identifier: (BSD-3-Clause)
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+// Note: Parts of this are a CUDA Hello world example from NVIDIA:
+// Obtained from here: https://developer.nvidia.com/cuda-education
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
+
+//-----------------------------------------------------------------------------
+//
+// file: blt_cuda_mpi_smoke.cpp
+//
+//-----------------------------------------------------------------------------
+
+#include
+#include
+#include
+
+__device__ const char *STR = "HELLO WORLD!";
+const char STR_LENGTH = 12;
+
+__global__ void hello()
+{
+ printf("%c\n", STR[threadIdx.x % STR_LENGTH]);
+}
+
+int main(int argc, char** argv)
+{
+ // CUDA smoke test
+ int num_threads = STR_LENGTH;
+ int num_blocks = 1;
+ hello<<>>();
+ cudaDeviceSynchronize();
+
+ // MPI smoke test
+ // Initialize MPI and get rank and comm size
+ MPI_Init(&argc, &argv);
+
+ int commRank = -1;
+ MPI_Comm_rank(MPI_COMM_WORLD, &commRank);
+ int commSize = -1;
+ MPI_Comm_size(MPI_COMM_WORLD, &commSize);
+
+ // Do a basic mpi reduce to determine this actually works
+ int globalValue = 0;
+ int valueToSend = 1;
+ MPI_Reduce(&valueToSend, &globalValue, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
+
+ // Finalize MPI
+ MPI_Finalize();
+
+ if (commRank == 0)
+ {
+ std::cout << "Count should be equal to rank size" << std::endl;
+ std::cout << "Count = " << globalValue << ", Size = " << commSize << std::endl;
+
+ if (globalValue != commSize)
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
diff --git a/tests/smoke/blt_cuda_openmp_smoke.cpp b/tests/smoke/blt_cuda_openmp_smoke.cpp
index c01321df1..d1532cb5e 100644
--- a/tests/smoke/blt_cuda_openmp_smoke.cpp
+++ b/tests/smoke/blt_cuda_openmp_smoke.cpp
@@ -1,17 +1,17 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
-// Note: Parts of this is a CUDA Hello world example from NVIDIA:
+// Note: Parts of this are a CUDA Hello world example from NVIDIA:
// Obtained from here: https://developer.nvidia.com/cuda-education
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//-----------------------------------------------------------------------------
-///
-/// file: blt_cuda_openmp_smoke.cpp
-///
+//
+// file: blt_cuda_openmp_smoke.cpp
+//
//-----------------------------------------------------------------------------
#include
@@ -23,30 +23,32 @@ const char STR_LENGTH = 12;
__global__ void hello()
{
- printf("%c\n", STR[threadIdx.x % STR_LENGTH]);
+ printf("%c\n", STR[threadIdx.x % STR_LENGTH]);
}
int main()
{
- int num_threads = STR_LENGTH;
- int num_blocks = 1;
- hello<<>>();
- cudaDeviceSynchronize();
-
- #pragma omp parallel
- {
- int thId = omp_get_thread_num();
- int thNum = omp_get_num_threads();
- int thMax = omp_get_max_threads();
-
- #pragma omp critical
- std::cout <<"\nMy thread id is: " << thId
- <<"\nNum threads is: " << thNum
- <<"\nMax threads is: " << thMax
- << std::endl;
- }
-
- return 0;
+ // CUDA smoke test
+ int num_threads = STR_LENGTH;
+ int num_blocks = 1;
+ hello<<>>();
+ cudaDeviceSynchronize();
+
+ // OpenMP smoke test
+ #pragma omp parallel
+ {
+ int thId = omp_get_thread_num();
+ int thNum = omp_get_num_threads();
+ int thMax = omp_get_max_threads();
+
+ #pragma omp critical
+ std::cout <<"\nMy thread id is: " << thId
+ <<"\nNum threads is: " << thNum
+ <<"\nMax threads is: " << thMax
+ << std::endl;
+ }
+
+ return 0;
}
diff --git a/tests/smoke/blt_cuda_runtime_smoke.cpp b/tests/smoke/blt_cuda_runtime_smoke.cpp
index a496b19f3..ccff05c56 100644
--- a/tests/smoke/blt_cuda_runtime_smoke.cpp
+++ b/tests/smoke/blt_cuda_runtime_smoke.cpp
@@ -1,18 +1,18 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Note: This is a CUDA example from NVIDIA:
-// Obtained from here:
+// Obtained from here:
// https://devblogs.nvidia.com/parallelforall/how-query-device-properties-and-handle-errors-cuda-cc/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//-----------------------------------------------------------------------------
-///
-/// file: blt_cuda_runtime_smoke.cpp
-///
+//
+// file: blt_cuda_runtime_smoke.cpp
+//
//-----------------------------------------------------------------------------
#include
@@ -21,23 +21,23 @@
int main()
{
- int nDevices;
+ int nDevices;
- cudaGetDeviceCount(&nDevices);
- for (int i = 0; i < nDevices; i++)
- {
- cudaDeviceProp prop;
- cudaGetDeviceProperties(&prop, i);
- printf("Device Number: %d\n", i);
- printf(" Device name: %s\n", prop.name);
- printf(" Memory Clock Rate (KHz): %d\n",
- prop.memoryClockRate);
- printf(" Memory Bus Width (bits): %d\n",
- prop.memoryBusWidth);
- printf(" Peak Memory Bandwidth (GB/s): %f\n\n",
- 2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
- }
+ cudaGetDeviceCount(&nDevices);
+ for (int i = 0; i < nDevices; i++)
+ {
+ cudaDeviceProp prop;
+ cudaGetDeviceProperties(&prop, i);
+ printf("Device Number: %d\n", i);
+ printf(" Device name: %s\n", prop.name);
+ printf(" Memory Clock Rate (KHz): %d\n",
+ prop.memoryClockRate);
+ printf(" Memory Bus Width (bits): %d\n",
+ prop.memoryBusWidth);
+ printf(" Peak Memory Bandwidth (GB/s): %f\n\n",
+ 2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
+ }
- return 0;
+ return 0;
}
diff --git a/tests/smoke/blt_cuda_smoke.cpp b/tests/smoke/blt_cuda_smoke.cpp
index 12ea2acab..a2c3d4e75 100644
--- a/tests/smoke/blt_cuda_smoke.cpp
+++ b/tests/smoke/blt_cuda_smoke.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
@@ -9,9 +9,9 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//-----------------------------------------------------------------------------
-///
-/// file: blt_cuda_smoke.cpp
-///
+//
+// file: blt_cuda_smoke.cpp
+//
//-----------------------------------------------------------------------------
#include
@@ -22,17 +22,17 @@ const char STR_LENGTH = 12;
__global__ void hello()
{
- printf("%c\n", STR[threadIdx.x % STR_LENGTH]);
+ printf("%c\n", STR[threadIdx.x % STR_LENGTH]);
}
int main()
{
- int num_threads = STR_LENGTH;
- int num_blocks = 1;
- hello<<>>();
- cudaDeviceSynchronize();
-
- return 0;
+ int num_threads = STR_LENGTH;
+ int num_blocks = 1;
+ hello<<>>();
+ cudaDeviceSynchronize();
+
+ return 0;
}
diff --git a/tests/smoke/blt_gbenchmark_smoke.cpp b/tests/smoke/blt_gbenchmark_smoke.cpp
index 4511da6b8..357d99654 100644
--- a/tests/smoke/blt_gbenchmark_smoke.cpp
+++ b/tests/smoke/blt_gbenchmark_smoke.cpp
@@ -1,28 +1,33 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
-#include "benchmark/benchmark_api.h"
+#include
//------------------------------------------------------------------------------
#define BASIC_BENCHMARK_TEST(x) \
- BENCHMARK(x)->Arg( 1<<3 )->Arg( 1<<9 )->Arg( 1 << 13 )
+ BENCHMARK(x)->Arg( 1<<3 )->Arg( 1<<9 )->Arg( 1 << 13 )
-void benchmark_smoke_empty(benchmark::State& state) {
- while (state.KeepRunning()) {
+void benchmark_smoke_empty(benchmark::State& state)
+{
+ for (auto _ : state)
+ {
benchmark::DoNotOptimize(state.iterations());
}
}
BENCHMARK(benchmark_smoke_empty);
-void benchmark_smoke_spin_loop(benchmark::State& state) {
- while (state.KeepRunning()) {
- for (int i=0; i < state.range(0); ++i) {
- benchmark::DoNotOptimize(i);
- }
+void benchmark_smoke_spin_loop(benchmark::State& state)
+{
+ for (auto _ : state)
+ {
+ for (int i=0; i < state.range(0); ++i)
+ {
+ benchmark::DoNotOptimize(i);
+ }
}
state.SetItemsProcessed(state.iterations() * state.range(0));
@@ -30,18 +35,21 @@ void benchmark_smoke_spin_loop(benchmark::State& state) {
BASIC_BENCHMARK_TEST(benchmark_smoke_spin_loop);
-void benchmark_smoke_accum_loop(benchmark::State& state) {
- while (state.KeepRunning()) {
- int accum = 0;
- for (int i=0; i < state.range(0); ++i) {
- accum += i;
- }
- benchmark::DoNotOptimize(accum);
+void benchmark_smoke_accum_loop(benchmark::State& state)
+{
+ for (auto _ : state)
+ {
+ int accum = 0;
+ for (int i=0; i < state.range(0); ++i)
+ {
+ accum += i;
+ }
+ benchmark::DoNotOptimize(accum);
}
state.SetItemsProcessed(state.iterations() * state.range(0));
}
BASIC_BENCHMARK_TEST(benchmark_smoke_accum_loop);
-BENCHMARK_MAIN()
+BENCHMARK_MAIN();
diff --git a/tests/smoke/blt_gmock_smoke.cpp b/tests/smoke/blt_gmock_smoke.cpp
index 168fcb50a..c7fbc1320 100644
--- a/tests/smoke/blt_gmock_smoke.cpp
+++ b/tests/smoke/blt_gmock_smoke.cpp
@@ -1,10 +1,10 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "gtest/gtest.h"
-#include "gmock/gmock.h"
+#include "gmock/gmock.h"
//------------------------------------------------------------------------------
@@ -13,9 +13,9 @@
//------------------------------------------------------------------------------
class Thing
{
- public:
- virtual ~Thing() {}
- virtual void Method() = 0;
+public:
+ virtual ~Thing() {}
+ virtual void Method() = 0;
};
//------------------------------------------------------------------------------
@@ -23,22 +23,22 @@ class Thing
//------------------------------------------------------------------------------
class MethodCaller
{
- public:
- MethodCaller(Thing *thing)
- :m_thing(thing)
- {
- // empty
- }
+public:
+ MethodCaller(Thing *thing)
+ : m_thing(thing)
+ {
+ // empty
+ }
- void Go()
- {
- // call Method() on thing 2 times
- m_thing->Method();
- m_thing->Method();
- }
+ void Go()
+ {
+ // call Method() on thing 2 times
+ m_thing->Method();
+ m_thing->Method();
+ }
- private:
- Thing* m_thing;
+private:
+ Thing* m_thing;
};
//------------------------------------------------------------------------------
@@ -46,8 +46,8 @@ class MethodCaller
//------------------------------------------------------------------------------
class MockThing : public Thing
{
- public:
- MOCK_METHOD0(Method, void());
+public:
+ MOCK_METHOD0(Method, void());
};
@@ -57,12 +57,12 @@ class MockThing : public Thing
using ::testing::AtLeast;
TEST(blt_gtest_smoke,basic_mock_test)
{
- MockThing m;
- EXPECT_CALL(m, Method()).Times(AtLeast(2));
+ MockThing m;
+ EXPECT_CALL(m, Method()).Times(AtLeast(2));
- MethodCaller mcaller(&m);
+ MethodCaller mcaller(&m);
- mcaller.Go();
+ mcaller.Go();
}
@@ -71,9 +71,9 @@ TEST(blt_gtest_smoke,basic_mock_test)
//------------------------------------------------------------------------------
int main(int argc, char** argv)
{
- // The following lines must be executed to initialize Google Test
- // and Google Mock before running the tests.
- ::testing::InitGoogleTest(&argc, argv);
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
+ // The following lines must be executed to initialize Google Test
+ // and Google Mock before running the tests.
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::InitGoogleMock(&argc, argv);
+ return RUN_ALL_TESTS();
}
diff --git a/tests/smoke/blt_gtest_smoke.cpp b/tests/smoke/blt_gtest_smoke.cpp
index c66cb6510..6047be56b 100644
--- a/tests/smoke/blt_gtest_smoke.cpp
+++ b/tests/smoke/blt_gtest_smoke.cpp
@@ -1,14 +1,14 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include "gtest/gtest.h"
-#include
+#include
//------------------------------------------------------------------------------
-// Simple smoke test for gtest
+// Simple smoke test for gtest
//------------------------------------------------------------------------------
TEST(blt_gtest_smoke,basic_assert_example)
{
@@ -19,14 +19,14 @@ TEST(blt_gtest_smoke,basic_assert_example)
//------------------------------------------------------------------------------
// Tests the gtest death test feature, which are disabled by default.
//
-// Exits program with non-zero exit code, passing the test.
+// Exits program with non-zero exit code, passing the test.
// Note: To enable death tests, configure BLT with ENABLE_GTEST_DEATH_TESTS.
//------------------------------------------------------------------------------
TEST(blt_gtest_smoke,death_test)
{
-#if (GTEST_HAS_DEATH_TEST == 0)
+ #if (GTEST_HAS_DEATH_TEST == 0)
std::cout <<"Note: Death tests disabled in this configuration." << std::endl;
-#endif
+ #endif
// Invoke death test function whether death tests enabled or disabled.
::testing::FLAGS_gtest_death_test_style = "threadsafe";
diff --git a/tests/smoke/blt_hcc_runtime_smoke.cpp b/tests/smoke/blt_hcc_runtime_smoke.cpp
index eb4804989..b45a08f34 100644
--- a/tests/smoke/blt_hcc_runtime_smoke.cpp
+++ b/tests/smoke/blt_hcc_runtime_smoke.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
@@ -8,9 +8,9 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//-----------------------------------------------------------------------------
-///
-/// file: blt_hcc_runtime_smoke.cpp
-///
+//
+// file: blt_hcc_runtime_smoke.cpp
+//
//-----------------------------------------------------------------------------
#include
@@ -19,28 +19,29 @@
int main()
{
- using namespace hc;
- accelerator acc;
- std::vector accv = acc.get_all() ;
-
- std::cout << "Found " << accv.size() << " accelerators." << std::endl;
- std::cout << std::endl;
-
- unsigned long idefault = 0;
- for(unsigned long i=0; i< accv.size();i++)
- {
- accelerator a = accv[i];
- std::cout << "Accelerator " << i << ": " ;
- std::wcout << a.get_device_path() << L" : " << a.get_description();
- std::cout << " : " << (a.get_version()>>16) << "." << (a.get_version()&0xff);
- std::cout << std::endl;
- if (a == acc) idefault = i;
- }
-
- std::cout << std::endl;
- std::cout << "Default Accelerator " << ": " << idefault << " : " ;
- std::wcout << acc.get_device_path() << std::endl;
-
- return 0;
+ using namespace hc;
+ accelerator acc;
+ std::vector accv = acc.get_all() ;
+
+ std::cout << "Found " << accv.size() << " accelerators." << std::endl;
+ std::cout << std::endl;
+
+ unsigned long idefault = 0;
+ for(unsigned long i=0; i< accv.size(); i++)
+ {
+ accelerator a = accv[i];
+ std::cout << "Accelerator " << i << ": " ;
+ std::wcout << a.get_device_path() << L" : " << a.get_description();
+ std::cout << " : " << (a.get_version()>>16) << "."
+ << (a.get_version()&0xff);
+ std::cout << std::endl;
+ if (a == acc) { idefault = i; }
+ }
+
+ std::cout << std::endl;
+ std::cout << "Default Accelerator " << ": " << idefault << " : " ;
+ std::wcout << acc.get_device_path() << std::endl;
+
+ return 0;
}
diff --git a/tests/smoke/blt_hcc_smoke.cpp b/tests/smoke/blt_hcc_smoke.cpp
index 7e007c8a7..48c2ceb08 100644
--- a/tests/smoke/blt_hcc_smoke.cpp
+++ b/tests/smoke/blt_hcc_smoke.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
@@ -8,9 +8,9 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//-----------------------------------------------------------------------------
-///
-/// file: blt_hcc_smoke.cpp
-///
+//
+// file: blt_hcc_smoke.cpp
+//
//-----------------------------------------------------------------------------
#include
@@ -18,11 +18,12 @@
int main()
{
- hc::parallel_for_each(hc::extent<1>(1), []() [[hc]] {
- hc::printf("Accelerator: Hello World!\n");
- }).wait();
+ hc::parallel_for_each(hc::extent<1>(1), []() [[hc]]
+ {
+ hc::printf("Accelerator: Hello World!\n");
+ }).wait();
- return 0;
+ return 0;
}
diff --git a/tests/smoke/blt_hip_runtime_smoke.cpp b/tests/smoke/blt_hip_runtime_smoke.cpp
index a52d1e3d9..e908f1f0b 100644
--- a/tests/smoke/blt_hip_runtime_smoke.cpp
+++ b/tests/smoke/blt_hip_runtime_smoke.cpp
@@ -1,12 +1,12 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
//-----------------------------------------------------------------------------
-///
-/// file: blt_hip_runtime_smoke.cpp
-///
+//
+// file: blt_hip_runtime_smoke.cpp
+//
//-----------------------------------------------------------------------------
#include
@@ -15,23 +15,23 @@
int main()
{
- int nDevices;
+ int nDevices;
- hipGetDeviceCount(&nDevices);
- for (int i = 0; i < nDevices; i++)
- {
- hipDeviceProp_t prop;
- hipGetDeviceProperties(&prop, i);
- printf("Device Number: %d\n", i);
- printf(" Device name: %s\n", prop.name);
- printf(" Memory Clock Rate (KHz): %d\n",
- prop.memoryClockRate);
- printf(" Memory Bus Width (bits): %d\n",
- prop.memoryBusWidth);
- printf(" Peak Memory Bandwidth (GB/s): %f\n\n",
- 2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
- }
+ hipGetDeviceCount(&nDevices);
+ for (int i = 0; i < nDevices; i++)
+ {
+ hipDeviceProp_t prop;
+ hipGetDeviceProperties(&prop, i);
+ printf("Device Number: %d\n", i);
+ printf(" Device name: %s\n", prop.name);
+ printf(" Memory Clock Rate (KHz): %d\n",
+ prop.memoryClockRate);
+ printf(" Memory Bus Width (bits): %d\n",
+ prop.memoryBusWidth);
+ printf(" Peak Memory Bandwidth (GB/s): %f\n\n",
+ 2.0*prop.memoryClockRate*(prop.memoryBusWidth/8)/1.0e6);
+ }
- return 0;
+ return 0;
}
diff --git a/tests/smoke/blt_hip_smoke.cpp b/tests/smoke/blt_hip_smoke.cpp
index 5176eb563..ac825099a 100644
--- a/tests/smoke/blt_hip_smoke.cpp
+++ b/tests/smoke/blt_hip_smoke.cpp
@@ -1,12 +1,12 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
//-----------------------------------------------------------------------------
-///
-/// file: blt_hip_smoke.cpp
-///
+//
+// file: blt_hip_smoke.cpp
+//
//-----------------------------------------------------------------------------
#include
@@ -18,17 +18,17 @@ const char STR_LENGTH = 12;
__global__ void hello()
{
- printf("%c\n", STR[threadIdx.x % STR_LENGTH]);
+ printf("%c\n", STR[threadIdx.x % STR_LENGTH]);
}
int main()
{
- int num_threads = STR_LENGTH;
- int num_blocks = 1;
- hipLaunchKernelGGL((hello), dim3(num_blocks), dim3(num_threads),0,0);
- hipDeviceSynchronize();
-
- return 0;
+ int num_threads = STR_LENGTH;
+ int num_blocks = 1;
+ hipLaunchKernelGGL((hello), dim3(num_blocks), dim3(num_threads),0,0);
+ hipDeviceSynchronize();
+
+ return 0;
}
diff --git a/tests/smoke/blt_mpi_smoke.cpp b/tests/smoke/blt_mpi_smoke.cpp
index b70a866ef..967ed1f88 100644
--- a/tests/smoke/blt_mpi_smoke.cpp
+++ b/tests/smoke/blt_mpi_smoke.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
/*!
@@ -17,30 +17,32 @@
//------------------------------------------------------------------------------
int main(int argc, char** argv)
{
- // Initialize MPI and get rank and comm size
- MPI_Init(&argc, &argv);
-
- int commRank = -1;
- MPI_Comm_rank(MPI_COMM_WORLD, &commRank);
- int commSize = -1;
- MPI_Comm_size(MPI_COMM_WORLD, &commSize);
-
- // Do a basic mpi reduce to determine this actually works
- int globalValue = 0;
- int valueToSend = 1;
- MPI_Reduce(&valueToSend, &globalValue, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
-
- // Finalize MPI
- MPI_Finalize();
-
- if (commRank == 0) {
- std::cout << "Count should be equal to rank size" << std::endl;
- std::cout << "Count = " << globalValue << ", Size = " << commSize << std::endl;
-
- if (globalValue != commSize) {
- return 1;
- }
+ // Initialize MPI and get rank and comm size
+ MPI_Init(&argc, &argv);
+
+ int commRank = -1;
+ MPI_Comm_rank(MPI_COMM_WORLD, &commRank);
+ int commSize = -1;
+ MPI_Comm_size(MPI_COMM_WORLD, &commSize);
+
+ // Do a basic mpi reduce to determine this actually works
+ int globalValue = 0;
+ int valueToSend = 1;
+ MPI_Reduce(&valueToSend, &globalValue, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
+
+ // Finalize MPI
+ MPI_Finalize();
+
+ if (commRank == 0)
+ {
+ std::cout << "Count should be equal to rank size" << std::endl;
+ std::cout << "Count = " << globalValue << ", Size = " << commSize << std::endl;
+
+ if (globalValue != commSize)
+ {
+ return 1;
}
-
- return 0;
+ }
+
+ return 0;
}
diff --git a/tests/smoke/blt_openmp_smoke.cpp b/tests/smoke/blt_openmp_smoke.cpp
index c7af70565..74a5f0d68 100644
--- a/tests/smoke/blt_openmp_smoke.cpp
+++ b/tests/smoke/blt_openmp_smoke.cpp
@@ -1,30 +1,30 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
#include
#include
/**
- * Simple test program that uses openmp without guards. Should only be compiled when OpenMP is enabled.
- */
+ * Simple test program that uses OpenMP without guards. Should only be compiled when OpenMP is enabled.
+ */
int main()
{
-
- #pragma omp parallel
- {
- int thId = omp_get_thread_num();
- int thNum = omp_get_num_threads();
- int thMax = omp_get_max_threads();
- #pragma omp critical
- std::cout <<"\nMy thread id is: " << thId
- <<"\nNum threads is: " << thNum
+ #pragma omp parallel
+ {
+ int thId = omp_get_thread_num();
+ int thNum = omp_get_num_threads();
+ int thMax = omp_get_max_threads();
+
+ #pragma omp critical
+ std::cout <<"\nMy thread id is: " << thId
+ <<"\nNum threads is: " << thNum
<<"\nMax threads is: " << thMax
- << std::endl;
- }
+ << std::endl;
+ }
- return 0;
+ return 0;
}
diff --git a/tests/smoke/fortran_driver.cpp b/tests/smoke/fortran_driver.cpp
index 743dd43f0..489009785 100644
--- a/tests/smoke/fortran_driver.cpp
+++ b/tests/smoke/fortran_driver.cpp
@@ -1,6 +1,6 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other BLT Project Developers. See the top-level COPYRIGHT file for details
-//
+//
// SPDX-License-Identifier: (BSD-3-Clause)
//----------------------------------------------------------------------
diff --git a/thirdparty_builtin/CMakeLists.txt b/thirdparty_builtin/CMakeLists.txt
index c92c38bbc..c49c12485 100644
--- a/thirdparty_builtin/CMakeLists.txt
+++ b/thirdparty_builtin/CMakeLists.txt
@@ -60,6 +60,10 @@ if(ENABLE_TESTS)
if(ENABLE_GTEST)
+ if(CMAKE_CXX_STANDARD LESS 11)
+ message(WARNING "C++11 is required to compile gtest or gmock.")
+ endif()
+
#
# gtest 1.8 emits many warnings related to dll-interface
# issues on windows, so we add flags to work around these
@@ -76,8 +80,8 @@ if(ENABLE_TESTS)
set (INSTALL_GTEST OFF CACHE BOOL "")
# Enable builtin google test
- add_subdirectory(googletest-master-2018-02-01
- ${BLT_BUILD_DIR}/thirdparty_builtin/googletest-master-2018-02-01)
+ add_subdirectory(googletest-master-2020-01-07
+ ${BLT_BUILD_DIR}/thirdparty_builtin/googletest-master-2020-01-07)
if(UNIX AND NOT APPLE)
find_package( Threads )
@@ -121,33 +125,41 @@ if(ENABLE_TESTS)
endif()
if(ENABLE_BENCHMARKS)
- if(WIN32 AND BUILD_SHARED_LIBS)
- message(FATAL_ERROR "Benchmarks cannot be built when BUILD_SHARED_LIBS=On")
+ if(NOT ENABLE_TESTS)
+ message(FATAL_ERROR "ENABLE_BENCHMARKS requires ENABLE_TESTS to be ON")
endif()
- ## google benchmark support
- add_subdirectory(gbenchmark-master-2017-05-19
- ${BLT_BUILD_DIR}/thirdparty_builtin/gbenchmark-master-2017-05-19)
+ message(STATUS "Google Benchmark Support is ${ENABLE_GBENCHMARK}")
- if (UNIX AND NOT APPLE)
- find_library(RT_LIBRARIES rt)
- endif()
+ if(ENABLE_GBENCHMARK)
+ if(WIN32 AND BUILD_SHARED_LIBS)
+ message(FATAL_ERROR "Google Benchmark cannot be built when BUILD_SHARED_LIBS=ON or on Windows")
+ endif()
- blt_register_library(NAME gbenchmark
- INCLUDES ${benchmark_SOURCE_DIR}/include ${benchmark_SOURCE_DIR}
- LIBRARIES benchmark ${RT_LIBRARIES}
- TREAT_INCLUDES_AS_SYSTEM ON
- )
+ if(CMAKE_CXX_STANDARD LESS 11)
+ message(WARNING "C++11 is required to compile gbenchmark.")
+ endif()
+
+ set(BENCHMARK_ENABLE_TESTING OFF CACHE "" BOOL)
+ add_subdirectory(benchmark-1.5.0
+ ${BLT_BUILD_DIR}/thirdparty_builtin/benchmark-1.5.0)
- list(APPEND _blt_tpl_targets benchmark)
+ if (UNIX AND NOT APPLE)
+ find_library(RT_LIBRARIES rt)
+ endif()
- if(ENABLE_TESTS)
- # This sets up a target to run the benchmarks
- add_custom_target(run_benchmarks
- COMMAND ctest -C Benchmark -VV -R benchmark
- WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
- )
+ blt_register_library(NAME gbenchmark
+ INCLUDES ${benchmark_SOURCE_DIR}/include ${benchmark_SOURCE_DIR}
+ LIBRARIES benchmark ${RT_LIBRARIES}
+ TREAT_INCLUDES_AS_SYSTEM ON)
+
+ list(APPEND _blt_tpl_targets gbenchmark)
endif()
+
+ # This sets up a target to run the benchmarks
+ add_custom_target(${BLT_RUN_BENCHMARKS_TARGET_NAME}
+ COMMAND ctest -C Benchmark -VV
+ WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
endif()
# Set the folder property of the blt thirdparty libraries
diff --git a/thirdparty_builtin/gbenchmark-master-2017-05-19/.clang-format b/thirdparty_builtin/benchmark-1.5.0/.clang-format
similarity index 68%
rename from thirdparty_builtin/gbenchmark-master-2017-05-19/.clang-format
rename to thirdparty_builtin/benchmark-1.5.0/.clang-format
index 4b3f13fa5..e7d00feaa 100644
--- a/thirdparty_builtin/gbenchmark-master-2017-05-19/.clang-format
+++ b/thirdparty_builtin/benchmark-1.5.0/.clang-format
@@ -1,5 +1,5 @@
---
Language: Cpp
BasedOnStyle: Google
+PointerAlignment: Left
...
-
diff --git a/thirdparty_builtin/gbenchmark-master-2017-05-19/.gitignore b/thirdparty_builtin/benchmark-1.5.0/.gitignore
similarity index 66%
rename from thirdparty_builtin/gbenchmark-master-2017-05-19/.gitignore
rename to thirdparty_builtin/benchmark-1.5.0/.gitignore
index 3c1b4f218..806d04c6b 100644
--- a/thirdparty_builtin/gbenchmark-master-2017-05-19/.gitignore
+++ b/thirdparty_builtin/benchmark-1.5.0/.gitignore
@@ -6,6 +6,7 @@
*.dylib
*.cmake
!/cmake/*.cmake
+!/test/AssemblyTests.cmake
*~
*.pyc
__pycache__
@@ -41,6 +42,20 @@ build.ninja
install_manifest.txt
rules.ninja
+# bazel output symlinks.
+bazel-*
+
# out-of-source build top-level folders.
build/
_build/
+build*/
+
+# in-source dependencies
+/googletest/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+CMakeSettings.json
+
+# Visual Studio Code cache/options directory
+.vscode/
diff --git a/thirdparty_builtin/gbenchmark-master-2017-05-19/.travis-libcxx-setup.sh b/thirdparty_builtin/benchmark-1.5.0/.travis-libcxx-setup.sh
similarity index 100%
rename from thirdparty_builtin/gbenchmark-master-2017-05-19/.travis-libcxx-setup.sh
rename to thirdparty_builtin/benchmark-1.5.0/.travis-libcxx-setup.sh
diff --git a/thirdparty_builtin/benchmark-1.5.0/.travis.yml b/thirdparty_builtin/benchmark-1.5.0/.travis.yml
new file mode 100644
index 000000000..6b6cfc704
--- /dev/null
+++ b/thirdparty_builtin/benchmark-1.5.0/.travis.yml
@@ -0,0 +1,235 @@
+sudo: required
+dist: trusty
+language: cpp
+
+env:
+ global:
+ - /usr/local/bin:$PATH
+
+matrix:
+ include:
+ - compiler: gcc
+ addons:
+ apt:
+ packages:
+ - lcov
+ env: COMPILER=g++ C_COMPILER=gcc BUILD_TYPE=Coverage
+ - compiler: gcc
+ env: COMPILER=g++ C_COMPILER=gcc BUILD_TYPE=Debug
+ - compiler: gcc
+ env: COMPILER=g++ C_COMPILER=gcc BUILD_TYPE=Release
+ - compiler: gcc
+ addons:
+ apt:
+ packages:
+ - g++-multilib
+ - libc6:i386
+ env:
+ - COMPILER=g++
+ - C_COMPILER=gcc
+ - BUILD_TYPE=Debug
+ - BUILD_32_BITS=ON
+ - EXTRA_FLAGS="-m32"
+ - compiler: gcc
+ addons:
+ apt:
+ packages:
+ - g++-multilib
+ - libc6:i386
+ env:
+ - COMPILER=g++
+ - C_COMPILER=gcc
+ - BUILD_TYPE=Release
+ - BUILD_32_BITS=ON
+ - EXTRA_FLAGS="-m32"
+ - compiler: gcc
+ env:
+ - INSTALL_GCC6_FROM_PPA=1
+ - COMPILER=g++-6 C_COMPILER=gcc-6 BUILD_TYPE=Debug
+ - ENABLE_SANITIZER=1
+ - EXTRA_FLAGS="-fno-omit-frame-pointer -g -O2 -fsanitize=undefined,address -fuse-ld=gold"
+ - compiler: clang
+ env: COMPILER=clang++ C_COMPILER=clang BUILD_TYPE=Debug
+ - compiler: clang
+ env: COMPILER=clang++ C_COMPILER=clang BUILD_TYPE=Release
+ # Clang w/ libc++
+ - compiler: clang
+ dist: xenial
+ addons:
+ apt:
+ packages:
+ clang-3.8
+ env:
+ - INSTALL_GCC6_FROM_PPA=1
+ - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug
+ - LIBCXX_BUILD=1
+ - EXTRA_CXX_FLAGS="-stdlib=libc++"
+ - compiler: clang
+ dist: xenial
+ addons:
+ apt:
+ packages:
+ clang-3.8
+ env:
+ - INSTALL_GCC6_FROM_PPA=1
+ - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Release
+ - LIBCXX_BUILD=1
+ - EXTRA_CXX_FLAGS="-stdlib=libc++"
+ # Clang w/ 32bit libc++
+ - compiler: clang
+ dist: xenial
+ addons:
+ apt:
+ packages:
+ - clang-3.8
+ - g++-multilib
+ - libc6:i386
+ env:
+ - INSTALL_GCC6_FROM_PPA=1
+ - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug
+ - LIBCXX_BUILD=1
+ - BUILD_32_BITS=ON
+ - EXTRA_FLAGS="-m32"
+ - EXTRA_CXX_FLAGS="-stdlib=libc++"
+ # Clang w/ 32bit libc++
+ - compiler: clang
+ dist: xenial
+ addons:
+ apt:
+ packages:
+ - clang-3.8
+ - g++-multilib
+ - libc6:i386
+ env:
+ - INSTALL_GCC6_FROM_PPA=1
+ - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Release
+ - LIBCXX_BUILD=1
+ - BUILD_32_BITS=ON
+ - EXTRA_FLAGS="-m32"
+ - EXTRA_CXX_FLAGS="-stdlib=libc++"
+ # Clang w/ libc++, ASAN, UBSAN
+ - compiler: clang
+ dist: xenial
+ addons:
+ apt:
+ packages:
+ clang-3.8
+ env:
+ - INSTALL_GCC6_FROM_PPA=1
+ - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug
+ - LIBCXX_BUILD=1 LIBCXX_SANITIZER="Undefined;Address"
+ - ENABLE_SANITIZER=1
+ - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=undefined,address -fno-sanitize-recover=all"
+ - EXTRA_CXX_FLAGS="-stdlib=libc++"
+ - UBSAN_OPTIONS=print_stacktrace=1
+ # Clang w/ libc++ and MSAN
+ - compiler: clang
+ dist: xenial
+ addons:
+ apt:
+ packages:
+ clang-3.8
+ env:
+ - INSTALL_GCC6_FROM_PPA=1
+ - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug
+ - LIBCXX_BUILD=1 LIBCXX_SANITIZER=MemoryWithOrigins
+ - ENABLE_SANITIZER=1
+ - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=memory -fsanitize-memory-track-origins"
+ - EXTRA_CXX_FLAGS="-stdlib=libc++"
+ # Clang w/ libc++ and MSAN
+ - compiler: clang
+ dist: xenial
+ addons:
+ apt:
+ packages:
+ clang-3.8
+ env:
+ - INSTALL_GCC6_FROM_PPA=1
+ - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=RelWithDebInfo
+ - LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread
+ - ENABLE_SANITIZER=1
+ - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all"
+ - EXTRA_CXX_FLAGS="-stdlib=libc++"
+ - os: osx
+ osx_image: xcode8.3
+ compiler: clang
+ env:
+ - COMPILER=clang++ BUILD_TYPE=Debug
+ - os: osx
+ osx_image: xcode8.3
+ compiler: clang
+ env:
+ - COMPILER=clang++ BUILD_TYPE=Release
+ - os: osx
+ osx_image: xcode8.3
+ compiler: clang
+ env:
+ - COMPILER=clang++
+ - BUILD_TYPE=Release
+ - BUILD_32_BITS=ON
+ - EXTRA_FLAGS="-m32"
+ - os: osx
+ osx_image: xcode8.3
+ compiler: gcc
+ env:
+ - COMPILER=g++-7 C_COMPILER=gcc-7 BUILD_TYPE=Debug
+
+before_script:
+ - if [ -n "${LIBCXX_BUILD}" ]; then
+ source .travis-libcxx-setup.sh;
+ fi
+ - if [ -n "${ENABLE_SANITIZER}" ]; then
+ export EXTRA_OPTIONS="-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF";
+ else
+ export EXTRA_OPTIONS="";
+ fi
+ - mkdir -p build && cd build
+
+before_install:
+ - if [ -z "$BUILD_32_BITS" ]; then
+ export BUILD_32_BITS=OFF && echo disabling 32 bit build;
+ fi
+ - if [ -n "${INSTALL_GCC6_FROM_PPA}" ]; then
+ sudo add-apt-repository -y "ppa:ubuntu-toolchain-r/test";
+ sudo apt-get update --option Acquire::Retries=100 --option Acquire::http::Timeout="60";
+ fi
+
+install:
+ - if [ -n "${INSTALL_GCC6_FROM_PPA}" ]; then
+ travis_wait sudo -E apt-get -yq --no-install-suggests --no-install-recommends install g++-6;
+ fi
+ - if [ "${TRAVIS_OS_NAME}" == "linux" -a "${BUILD_32_BITS}" == "OFF" ]; then
+ travis_wait sudo -E apt-get -y --no-install-suggests --no-install-recommends install llvm-3.9-tools;
+ sudo cp /usr/lib/llvm-3.9/bin/FileCheck /usr/local/bin/;
+ fi
+ - if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then
+ PATH=~/.local/bin:${PATH};
+ pip install --user --upgrade pip;
+ travis_wait pip install --user cpp-coveralls;
+ fi
+ - if [ "${C_COMPILER}" == "gcc-7" -a "${TRAVIS_OS_NAME}" == "osx" ]; then
+ rm -f /usr/local/include/c++;
+ brew update;
+ travis_wait brew install gcc@7;
+ fi
+ - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
+ sudo apt-get update -qq;
+ sudo apt-get install -qq unzip cmake3;
+ wget https://github.com/bazelbuild/bazel/releases/download/0.10.1/bazel-0.10.1-installer-linux-x86_64.sh --output-document bazel-installer.sh;
+ travis_wait sudo bash bazel-installer.sh;
+ fi
+ - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
+ curl -L -o bazel-installer.sh https://github.com/bazelbuild/bazel/releases/download/0.10.1/bazel-0.10.1-installer-darwin-x86_64.sh;
+ travis_wait sudo bash bazel-installer.sh;
+ fi
+
+script:
+ - cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_C_FLAGS="${EXTRA_FLAGS}" -DCMAKE_CXX_FLAGS="${EXTRA_FLAGS} ${EXTRA_CXX_FLAGS}" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DBENCHMARK_BUILD_32_BITS=${BUILD_32_BITS} ${EXTRA_OPTIONS} ..
+ - make
+ - ctest -C ${BUILD_TYPE} --output-on-failure
+ - bazel test -c dbg --define google_benchmark.have_regex=posix --announce_rc --verbose_failures --test_output=errors --keep_going //test/...
+
+after_success:
+ - if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then
+ coveralls --include src --include include --gcov-options '\-lp' --root .. --build-root .;
+ fi
diff --git a/thirdparty_builtin/gbenchmark-master-2017-05-19/.ycm_extra_conf.py b/thirdparty_builtin/benchmark-1.5.0/.ycm_extra_conf.py
similarity index 99%
rename from thirdparty_builtin/gbenchmark-master-2017-05-19/.ycm_extra_conf.py
rename to thirdparty_builtin/benchmark-1.5.0/.ycm_extra_conf.py
index 86194357d..5649ddcc7 100644
--- a/thirdparty_builtin/gbenchmark-master-2017-05-19/.ycm_extra_conf.py
+++ b/thirdparty_builtin/benchmark-1.5.0/.ycm_extra_conf.py
@@ -7,7 +7,7 @@
flags = [
'-Wall',
'-Werror',
-'-pendantic-errors',
+'-pedantic-errors',
'-std=c++0x',
'-fno-strict-aliasing',
'-O3',
diff --git a/thirdparty_builtin/gbenchmark-master-2017-05-19/AUTHORS b/thirdparty_builtin/benchmark-1.5.0/AUTHORS
similarity index 74%
rename from thirdparty_builtin/gbenchmark-master-2017-05-19/AUTHORS
rename to thirdparty_builtin/benchmark-1.5.0/AUTHORS
index c4b059df2..912cbbc13 100644
--- a/thirdparty_builtin/gbenchmark-master-2017-05-19/AUTHORS
+++ b/thirdparty_builtin/benchmark-1.5.0/AUTHORS
@@ -9,30 +9,43 @@
# Please keep the list sorted.
Albert Pretorius
+Alex Steele
+Andriy Berestovskyy
Arne Beer
+Carto
Christopher Seymour
+Daniel Harvey
David Coeurjolly
-Dominic Hamon
+Deniz Evrenci
+Dirac Research
+Dominik Czarnota
Eric Fiselier
Eugene Zhuk
Evgeny Safronov
+Federico Ficarelli
Felix Homann
Google Inc.
International Business Machines Corporation
Ismael Jimenez Martinez
-Joao Paulo Magalhaes
+Jern-Kuan Leong
JianXiong Zhou
+Joao Paulo Magalhaes
Jussi Knuuttila
Kaito Udagawa
+Kishan Kumar
Lei Xu
Matt Clarkson
Maxim Vafin
+MongoDB Inc.
Nick Hutchinson
Oleksandr Sochka
+Ori Livneh
Paul Redmond
Radoslav Yovchev
+Roman Lebedev