From e2d376357020a2556f96cce69c73935ddd83ae6a Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 22 Feb 2024 13:59:34 -0800 Subject: [PATCH 01/36] remove unnecessary fortran openmp swap logic to use existing generator expressions now that LINK_OPTIONS target properties allow generator expressions --- cmake/BLTMacros.cmake | 6 --- cmake/BLTPrivateMacros.cmake | 77 --------------------------- cmake/thirdparty/BLTSetupOpenMP.cmake | 55 +++++++++---------- 3 files changed, 28 insertions(+), 110 deletions(-) diff --git a/cmake/BLTMacros.cmake b/cmake/BLTMacros.cmake index 6f851fcaa..88c9ba5e2 100644 --- a/cmake/BLTMacros.cmake +++ b/cmake/BLTMacros.cmake @@ -348,12 +348,6 @@ macro(blt_add_executable) set_target_properties(${arg_NAME} PROPERTIES LINKER_LANGUAGE ${_blt_link_lang}) endif() - # 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() diff --git a/cmake/BLTPrivateMacros.cmake b/cmake/BLTPrivateMacros.cmake index e0b408754..3c9543164 100644 --- a/cmake/BLTPrivateMacros.cmake +++ b/cmake/BLTPrivateMacros.cmake @@ -20,83 +20,6 @@ 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) - - # The OpenMP interface library will have been added as a direct - # link dependency instead of via flags - get_target_property(target_link_libs ${target_name} LINK_LIBRARIES) - if ( target_link_libs ) - # Since this is only called on executable targets we can safely convert - # from a "real" target back to a "fake" one as this is a sink vertex in - # the DAG. Only the link flags need to be modified. - list(FIND target_link_libs "openmp" _omp_index) - list(FIND target_link_libs "blt::openmp" _blt_omp_index) - if(${_omp_index} GREATER -1 OR ${_blt_omp_index} GREATER -1) - message(STATUS "Fixing OpenMP Flags for target[${target_name}]") - - # Remove openmp from libraries - list(REMOVE_ITEM target_link_libs "openmp") - list(REMOVE_ITEM target_link_libs "blt::openmp") - set_target_properties( ${target_name} PROPERTIES - LINK_LIBRARIES "${target_link_libs}" ) - - # Add openmp compile flags verbatim w/ generator expression - get_target_property(omp_compile_flags openmp INTERFACE_COMPILE_OPTIONS) - target_compile_options(${target_name} PUBLIC ${omp_compile_flags}) - - # Change CXX flags to Fortran flags - - # These are set through blt_add_target_link_flags which needs to use - # the link_libraries for interface libraries in CMake < 3.13 - if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0" ) - get_target_property(omp_link_flags openmp INTERFACE_LINK_OPTIONS) - else() - get_target_property(omp_link_flags openmp INTERFACE_LINK_LIBRARIES) - endif() - - string( REPLACE "${OpenMP_CXX_FLAGS}" "${OpenMP_Fortran_FLAGS}" - correct_omp_link_flags - "${omp_link_flags}" - ) - if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0" ) - target_link_options(${target_name} PRIVATE "${correct_omp_link_flags}") - else() - set_property(TARGET ${target_name} APPEND PROPERTY LINK_FLAGS "${correct_omp_link_flags}") - endif() - endif() - - # Handle registered library general case - - # OpenMP is an interface library which doesn't have a LINK_FLAGS property - # in versions < 3.13 - set(_property_name LINK_FLAGS) - if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0" ) - # In CMake 3.13+, LINK_FLAGS was converted to LINK_OPTIONS. - set(_property_name LINK_OPTIONS) - endif() - get_target_property(target_link_flags ${target_name} ${_property_name}) - if ( target_link_flags ) - - string( REPLACE "${OpenMP_CXX_FLAGS}" "${OpenMP_Fortran_FLAGS}" - correct_link_flags - "${target_link_flags}" - ) - set_target_properties( ${target_name} PROPERTIES ${_property_name} - "${correct_link_flags}" ) - endif() - endif() - - endif() - -endfunction() ##----------------------------------------------------------------------------- ## blt_find_executable(NAME diff --git a/cmake/thirdparty/BLTSetupOpenMP.cmake b/cmake/thirdparty/BLTSetupOpenMP.cmake index 186ea272f..30567b15f 100644 --- a/cmake/thirdparty/BLTSetupOpenMP.cmake +++ b/cmake/thirdparty/BLTSetupOpenMP.cmake @@ -12,33 +12,34 @@ find_package(OpenMP REQUIRED) # 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 (BLT_ENABLE_FORTRAN) - string(COMPARE NOTEQUAL "${OpenMP_CXX_FLAGS}" "${OpenMP_Fortran_FLAGS}" - BLT_OPENMP_FLAGS_DIFFER ) +set(_flags_differ FALSE) +if(BLT_ENABLE_FORTRAN) + string(COMPARE NOTEQUAL "${OpenMP_CXX_FLAGS}" "${OpenMP_Fortran_FLAGS}" + _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 BLT_ENABLE_CUDA AND BLT_OPENMP_FLAGS_DIFFER) - set(_compile_flags - $<$>,$>>:${OpenMP_CXX_FLAGS}> - $<$:-Xcompiler=${OpenMP_CXX_FLAGS}> - $<$:${OpenMP_Fortran_FLAGS}>) -elseif(NOT COMPILER_FAMILY_IS_MSVC AND BLT_ENABLE_CUDA) - set(_compile_flags - $<$>:${OpenMP_CXX_FLAGS}> - $<$:-Xcompiler=${OpenMP_CXX_FLAGS}>) -elseif(NOT COMPILER_FAMILY_IS_MSVC AND BLT_OPENMP_FLAGS_DIFFER) - set(_compile_flags - $<$>:${OpenMP_CXX_FLAGS}> - $<$:${OpenMP_Fortran_FLAGS}>) +set(BLT_OPENMP_FLAGS_DIFFER ${_flags_differ} CACHE BOOL "") + +set(_flags ${OpenMP_CXX_FLAGS}) + +if(NOT COMPILER_FAMILY_IS_MSVC) + if(BLT_ENABLE_CUDA AND BLT_OPENMP_FLAGS_DIFFER) + set(_flags + $<$>,$>>:${OpenMP_CXX_FLAGS}> + $<$:-Xcompiler=${OpenMP_CXX_FLAGS}> + $<$:${OpenMP_Fortran_FLAGS}>) + elseif(BLT_ENABLE_CUDA) + set(_flags + $<$>:${OpenMP_CXX_FLAGS}> + $<$:-Xcompiler=${OpenMP_CXX_FLAGS}>) + elseif(BLT_OPENMP_FLAGS_DIFFER) + set(_flags + $<$>:${OpenMP_CXX_FLAGS}> + $<$:${OpenMP_Fortran_FLAGS}>) + endif() endif() +set(_compile_flags ${_flags}) +set(_link_flags ${_flags}) # Allow user to override if (BLT_OPENMP_COMPILE_FLAGS) @@ -49,10 +50,10 @@ if (BLT_OPENMP_LINK_FLAGS) endif() -message(STATUS "OpenMP Compile Flags: ${_compile_flags}") -message(STATUS "OpenMP Link Flags: ${_link_flags}") +message(STATUS "BLT OpenMP Compile Flags: ${_compile_flags}") +message(STATUS "BLT OpenMP Link Flags: ${_link_flags}") -blt_import_library(NAME openmp +blt_import_library(NAME openmp COMPILE_FLAGS ${_compile_flags} LINK_FLAGS ${_link_flags} EXPORTABLE ${BLT_EXPORT_THIRDPARTY}) From 8334cb42f8de3245458e5644ceb055d13195fa0c Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 22 Feb 2024 13:59:53 -0800 Subject: [PATCH 02/36] raise the CMake base version that we warn against to 3.15 --- SetupBLT.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SetupBLT.cmake b/SetupBLT.cmake index 3bf3c1485..4873a6ed7 100644 --- a/SetupBLT.cmake +++ b/SetupBLT.cmake @@ -41,10 +41,10 @@ if (NOT BLT_LOADED) endif() unset(_is_multi_config) - if(${CMAKE_VERSION} VERSION_LESS 3.8.0) + if(${CMAKE_VERSION} VERSION_LESS 3.15.0) message("*************************************") message("* Unsupported version of CMake detected.") - message("* BLT requires CMake 3.8 or above.") + message("* BLT requires CMake 3.15 or above.") message("* Some BLT features may not work.") message("*************************************") endif() From 1aa0482acc48ee8dafdf7e8465c0983229ad30ff Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 22 Feb 2024 14:00:04 -0800 Subject: [PATCH 03/36] print out implicit directories and libraries that cmake finds --- cmake/SetupCompilerOptions.cmake | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/cmake/SetupCompilerOptions.cmake b/cmake/SetupCompilerOptions.cmake index bb9d7e29b..e37c1695b 100644 --- a/cmake/SetupCompilerOptions.cmake +++ b/cmake/SetupCompilerOptions.cmake @@ -358,12 +358,22 @@ endforeach() ################################## # Remove implicit link directories ################################## +message(STATUS "CMake's C implicit Link Directories: ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") +message(STATUS "CMake's CXX implicit Link Directories: ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") +if (ENABLE_FORTRAN) + message(STATUS "CMake's Fortran implicit Link Directories: ${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}") +endif () +if (ENABLE_CUDA) + message(STATUS "CMake's CUDA implicit Link Directories: ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") +endif () + if(BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE) message(STATUS "Removing implicit link directories: ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}") - list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) - message(STATUS "Updated CXX implicit Link Directories: ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") + list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) message(STATUS "Updated C implicit Link Directories: ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) + message(STATUS "Updated CXX implicit Link Directories: ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") if (ENABLE_FORTRAN) list(REMOVE_ITEM CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) message(STATUS "Updated Fortran implicit Link Directories: ${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}") @@ -377,12 +387,22 @@ endif() ################################## # Remove implicit link libraries ################################## +message(STATUS "CMake's C implicit Link Libraries: ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}") +message(STATUS "CMake's CXX implicit Link Libraries: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") +if (ENABLE_FORTRAN) + message(STATUS "CMake's Fortran implicit Link Libraries: ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") +endif () +if (ENABLE_CUDA) + message(STATUS "CMake's CUDA implicit Link Libraries: ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES}") +endif () + if(BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE) message(STATUS "Removing implicit link libraries: ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}") - list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_LIBRARIES ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) - message(STATUS "Updated CXX implicit Link Libraries: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") + list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_LIBRARIES ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) message(STATUS "Updated C implicit Link Libraries: ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}") + list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_LIBRARIES ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) + message(STATUS "Updated CXX implicit Link Libraries: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") if (ENABLE_FORTRAN) list(REMOVE_ITEM CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) message(STATUS "Updated Fortran implicit Link Libraries: ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") From d5a13bdda659b4e1da1846f0b3a6c0de26a4e5d6 Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 22 Feb 2024 15:18:00 -0800 Subject: [PATCH 04/36] set properties to search in non-standard locations --- SetupBLT.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SetupBLT.cmake b/SetupBLT.cmake index 4873a6ed7..54c5640b6 100644 --- a/SetupBLT.cmake +++ b/SetupBLT.cmake @@ -87,6 +87,13 @@ if (NOT BLT_LOADED) cmake_policy(SET CMP0076 OLD) endif() + ################################ + # Enable various find commands to look in non-default paths + ################################ + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE) + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE) + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS TRUE) + ################################ # Invoke CMake Fortran setup # if ENABLE_FORTRAN == ON From b7d21d5277e9efd3b2fd1d02deea4e9d07170e41 Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 22 Feb 2024 16:46:14 -0800 Subject: [PATCH 05/36] guard against this matching on tioga --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 497cacf5a..9ebc9ed99 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ stages: .build_script: script: #Use pre-existing allocation if any - - JOBID=$(if [[ $SYS_TYPE = toss_* ]]; then squeue -h --name=${PROJECT_ALLOC_NAME} --format=%A; fi) + - JOBID=$(if [[ "$SYS_TYPE" == "toss_4_x86_64_ib" ]]; then squeue -h --name=${PROJECT_ALLOC_NAME} --format=%A; fi) - ASSIGN_ID=$(if [[ -n "${JOBID}" ]]; then echo "--jobid=${JOBID}"; fi) #BUILD + TEST - echo -e "section_start:$(date +%s):build_and_test\r\e[0K From 755814e6b1f776c6aecbb1389582036d71e00afa Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 1 Mar 2024 12:52:55 -0800 Subject: [PATCH 06/36] add release notes and fix capitalization --- RELEASE-NOTES.md | 8 ++++++++ cmake/SetupCompilerOptions.cmake | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index b9f74535a..68549cf29 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -9,6 +9,14 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/ ## [Unreleased] - Release date yyyy-mm-dd +### Added +- Added output for CMake's implicitly added link libraries and directories. + +### Changed +- OpenMP target now uses a generator expression for Fortran flags instead of replacing flags in + Fortran targets created with BLT macros. + + ## [Version 0.6.1] - Release date 2024-01-29 ### Fixed diff --git a/cmake/SetupCompilerOptions.cmake b/cmake/SetupCompilerOptions.cmake index e37c1695b..59dc7628f 100644 --- a/cmake/SetupCompilerOptions.cmake +++ b/cmake/SetupCompilerOptions.cmake @@ -358,29 +358,29 @@ endforeach() ################################## # Remove implicit link directories ################################## -message(STATUS "CMake's C implicit Link Directories: ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") -message(STATUS "CMake's CXX implicit Link Directories: ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") +message(STATUS "CMake's C implicit link directories: ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") +message(STATUS "CMake's CXX implicit link directories: ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") if (ENABLE_FORTRAN) - message(STATUS "CMake's Fortran implicit Link Directories: ${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}") + message(STATUS "CMake's Fortran implicit link directories: ${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}") endif () if (ENABLE_CUDA) - message(STATUS "CMake's CUDA implicit Link Directories: ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") + message(STATUS "CMake's CUDA implicit link directories: ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") endif () if(BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE) message(STATUS "Removing implicit link directories: ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}") list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) - message(STATUS "Updated C implicit Link Directories: ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + message(STATUS "Updated C implicit link directories: ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) - message(STATUS "Updated CXX implicit Link Directories: ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") + message(STATUS "Updated CXX implicit link directories: ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") if (ENABLE_FORTRAN) list(REMOVE_ITEM CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) - message(STATUS "Updated Fortran implicit Link Directories: ${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}") + message(STATUS "Updated Fortran implicit link directories: ${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}") endif () if (ENABLE_CUDA) list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES ${BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) - message(STATUS "Updated CUDA implicit Link Directories: ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") + message(STATUS "Updated CUDA implicit link directories: ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") endif () endif() From 9ac60ad59aca89f023a45fd7cfc02ec4639b509b Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 1 Mar 2024 12:56:43 -0800 Subject: [PATCH 07/36] remove setting CMP0076 which left relative paths alone instead of changing them to absolute paths in target_sources() --- RELEASE-NOTES.md | 3 ++- SetupBLT.cmake | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 68549cf29..912376912 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -15,7 +15,8 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/ ### Changed - OpenMP target now uses a generator expression for Fortran flags instead of replacing flags in Fortran targets created with BLT macros. - +- Remove setting CMP0076 to OLD which left relative paths in `target_sources()` instead of altering + them to absolute paths. ## [Version 0.6.1] - Release date 2024-01-29 diff --git a/SetupBLT.cmake b/SetupBLT.cmake index 54c5640b6..f01f2d04d 100644 --- a/SetupBLT.cmake +++ b/SetupBLT.cmake @@ -79,14 +79,6 @@ if (NOT BLT_LOADED) 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 - # problems in header only libraries, OLD keeps current behavior - if(POLICY CMP0076) - cmake_policy(SET CMP0076 OLD) - endif() - ################################ # Enable various find commands to look in non-default paths ################################ From 67a4d79766151ab8e52d4497444b5e0eb42adc90 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 1 Mar 2024 13:52:18 -0800 Subject: [PATCH 08/36] avoid using target_sources --- cmake/BLTMacros.cmake | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/cmake/BLTMacros.cmake b/cmake/BLTMacros.cmake index 88c9ba5e2..c75494b99 100644 --- a/cmake/BLTMacros.cmake +++ b/cmake/BLTMacros.cmake @@ -206,22 +206,9 @@ macro(blt_add_library) LIBRARY_TYPE ${_lib_type}) endif() else() - # # Header-only library support - # - foreach (_file ${arg_HEADERS}) - # Determine build location of headers - get_filename_component(_absolute ${_file} ABSOLUTE) - list(APPEND _build_headers ${_absolute}) - endforeach() - - #Note: This only works if both libraries are handled in the same directory, - # otherwise just don't include non-header files in your source list. - set_source_files_properties(${_build_headers} PROPERTIES HEADER_FILE_ONLY ON) - add_library( ${arg_NAME} INTERFACE ) - target_sources( ${arg_NAME} INTERFACE - $) + add_library( ${arg_NAME} INTERFACE ${arg_HEADERS}) endif() # Clear value of _have_fortran from previous calls From 80c0936924ec5f00b286ed6935d6fb3e644679c7 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 1 Mar 2024 14:32:26 -0800 Subject: [PATCH 09/36] try 400 --- cmake/BLTMacros.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/BLTMacros.cmake b/cmake/BLTMacros.cmake index c75494b99..1f38c1e7f 100644 --- a/cmake/BLTMacros.cmake +++ b/cmake/BLTMacros.cmake @@ -208,7 +208,9 @@ macro(blt_add_library) else() # Header-only library support - add_library( ${arg_NAME} INTERFACE ${arg_HEADERS}) + add_library( ${arg_NAME} INTERFACE) + # Add header sources for IDE support + target_sources( ${arg_NAME} PRIVATE ${arg_HEADERS}) endif() # Clear value of _have_fortran from previous calls From e0dc94a88aa5a7adbb1081ca4a6297ec5431e994 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 1 Mar 2024 14:56:23 -0800 Subject: [PATCH 10/36] try 401 --- cmake/BLTMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/BLTMacros.cmake b/cmake/BLTMacros.cmake index 1f38c1e7f..df79c502d 100644 --- a/cmake/BLTMacros.cmake +++ b/cmake/BLTMacros.cmake @@ -210,7 +210,7 @@ macro(blt_add_library) add_library( ${arg_NAME} INTERFACE) # Add header sources for IDE support - target_sources( ${arg_NAME} PRIVATE ${arg_HEADERS}) + set_target_properties( ${arg_NAME} PROPERTIES PRIVATE_HEADER "${arg_HEADERS}") endif() # Clear value of _have_fortran from previous calls From fa9349535a5ecf7acd1bf3fbebcc4b33936d9292 Mon Sep 17 00:00:00 2001 From: Chris White Date: Mon, 4 Mar 2024 16:48:28 -0800 Subject: [PATCH 11/36] add headers to IDE support for header-only libraries Co-authored-by: Kenneth Weiss --- cmake/BLTMacros.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/BLTMacros.cmake b/cmake/BLTMacros.cmake index df79c502d..920f3d0da 100644 --- a/cmake/BLTMacros.cmake +++ b/cmake/BLTMacros.cmake @@ -206,11 +206,17 @@ macro(blt_add_library) LIBRARY_TYPE ${_lib_type}) endif() else() + # # Header-only library support - - add_library( ${arg_NAME} INTERFACE) - # Add header sources for IDE support - set_target_properties( ${arg_NAME} PROPERTIES PRIVATE_HEADER "${arg_HEADERS}") + # + # Note: Will not add header files to header-only interface libraries in older versions + # of CMake when CMP0076 is set to NEW + # + if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0" ) + add_library( ${arg_NAME} INTERFACE ${arg_HEADERS} ) + else() + add_library( ${arg_NAME} INTERFACE ) + endif() endif() # Clear value of _have_fortran from previous calls From fa3ad27a11ff4baf43bbf9dd6522bfeba05a9d7e Mon Sep 17 00:00:00 2001 From: Chris White Date: Mon, 4 Mar 2024 17:29:53 -0800 Subject: [PATCH 12/36] simplify checks for tpl flags --- cmake/BLTSetupTargets.cmake | 23 ++++++++------------ cmake/BLTThirdPartyConfigFlags.cmake.in | 28 ++++++++++--------------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/cmake/BLTSetupTargets.cmake b/cmake/BLTSetupTargets.cmake index 96fdf3e55..20e0874f2 100644 --- a/cmake/BLTSetupTargets.cmake +++ b/cmake/BLTSetupTargets.cmake @@ -16,29 +16,24 @@ if (NOT BLT_LOADED) endif() # If the generated TPL config file exists, include it here. if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/BLTThirdPartyConfigFlags.cmake") + # Case: Imported BLT project (ie. an installed TPL loading its BLT targets) include("${CMAKE_CURRENT_LIST_DIR}/BLTThirdPartyConfigFlags.cmake") else() + # Case: Main BLT project (ie. a project loading it's own BLT) # Otherwise, configure the TPL flags. We have to prefix these variables with # BLT so that they never conflict with user-level CMake variables in downstream # projects. # # We have to do some checks before we overwrite these internal variables to assure # that we don't turn off a third-party library enabled by the dependency. - if (NOT DEFINED BLT_ENABLE_HIP OR NOT ${BLT_ENABLE_HIP}) - set(BLT_ENABLE_HIP ${ENABLE_HIP}) - endif() - if (NOT DEFINED BLT_ENABLE_CUDA OR NOT ${BLT_ENABLE_CUDA}) - set(BLT_ENABLE_CUDA ${ENABLE_CUDA}) - endif() - if (NOT DEFINED BLT_ENABLE_MPI OR NOT ${BLT_ENABLE_MPI}) - set(BLT_ENABLE_MPI ${ENABLE_MPI}) - endif() - if (NOT DEFINED BLT_ENABLE_OPENMP OR NOT ${BLT_ENABLE_OPENMP}) - set(BLT_ENABLE_OPENMP ${ENABLE_OPENMP}) - endif() - if (NOT DEFINED BLT_ENABLE_FIND_MPI OR NOT ${BLT_ENABLE_FIND_MPI}) - set(BLT_ENABLE_FIND_MPI ${ENABLE_FIND_MPI}) + if (DEFINED BLT_ENABLE_HIP) + message(FATAL_ERROR "This variable should never exist at this point. Something has gone horribly wrong.") endif() + set(BLT_ENABLE_HIP ${ENABLE_HIP}) + set(BLT_ENABLE_CUDA ${ENABLE_CUDA}) + set(BLT_ENABLE_MPI ${ENABLE_MPI}) + set(BLT_ENABLE_OPENMP ${ENABLE_OPENMP}) + set(BLT_ENABLE_FIND_MPI ${ENABLE_FIND_MPI}) set(BLT_ENABLE_CLANG_CUDA ${ENABLE_CLANG_CUDA}) endif() diff --git a/cmake/BLTThirdPartyConfigFlags.cmake.in b/cmake/BLTThirdPartyConfigFlags.cmake.in index ccb061ca5..446d33f2b 100644 --- a/cmake/BLTThirdPartyConfigFlags.cmake.in +++ b/cmake/BLTThirdPartyConfigFlags.cmake.in @@ -1,20 +1,14 @@ -if ("@ENABLE_CUDA@") - set(BLT_ENABLE_CUDA "@ENABLE_CUDA@") -endif() - -if ("@ENABLE_HIP@") - set(BLT_ENABLE_HIP "@ENABLE_HIP@") -endif() - -if ("@ENABLE_MPI@") - set(BLT_ENABLE_MPI "@ENABLE_MPI@") -endif() - -if ("@ENABLE_OPENMP@") - set(BLT_ENABLE_OPENMP "@ENABLE_OPENMP@") -endif() - -set(BLT_ENABLE_FIND_MPI "@ENABLE_FIND_MPI@") +set(BLT_ENABLE_CUDA @ENABLE_CUDA@) +set(BLT_ENABLE_HIP @ENABLE_HIP@) +set(BLT_ENABLE_MPI @ENABLE_MPI@) +set(BLT_ENABLE_OPENMP @ENABLE_OPENMP@) +set(BLT_ENABLE_FIND_MPI @ENABLE_FIND_MPI@) + +foreach(_var BLT_ENABLE_CUDA BLT_ENABLE_HIP BLT_ENABLE_MPI BLT_ENABLE_OPENMP BLT_ENABLE_FIND_MPI) + if(NOT ${_var}) + set(${_var} OFF) + endif() +endforeach() # User configurable CUDA options needed by downstream. Normally, exporting # these targets would pass these flags to downstream targets, but this From 403961b2fc497670a99be0045c1cd48cc93716df Mon Sep 17 00:00:00 2001 From: Chris White Date: Mon, 4 Mar 2024 17:56:00 -0800 Subject: [PATCH 13/36] add project name to message --- cmake/BLTSetupTargets.cmake | 10 ++++++---- cmake/BLTThirdPartyConfigFlags.cmake.in | 26 ++++++------------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/cmake/BLTSetupTargets.cmake b/cmake/BLTSetupTargets.cmake index 20e0874f2..cc1f3a3f9 100644 --- a/cmake/BLTSetupTargets.cmake +++ b/cmake/BLTSetupTargets.cmake @@ -35,6 +35,8 @@ else() set(BLT_ENABLE_OPENMP ${ENABLE_OPENMP}) set(BLT_ENABLE_FIND_MPI ${ENABLE_FIND_MPI}) set(BLT_ENABLE_CLANG_CUDA ${ENABLE_CLANG_CUDA}) + + set(_current_project_name ${PROJECT_NAME}) endif() # Detect if Fortran has been introduced. @@ -57,7 +59,7 @@ endif() # MPI #------------------------------------ if (NOT TARGET mpi) - message(STATUS "MPI Support is ${BLT_ENABLE_MPI}") + message(STATUS "${_current_project_name} MPI support is ${BLT_ENABLE_MPI}") if (BLT_ENABLE_MPI AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupMPI.cmake") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupMPI.cmake") endif() @@ -68,7 +70,7 @@ endif() # OpenMP #------------------------------------ if (NOT TARGET openmp) - message(STATUS "OpenMP Support is ${BLT_ENABLE_OPENMP}") + message(STATUS "${_current_project_name} OpenMP support is ${BLT_ENABLE_OPENMP}") if (BLT_ENABLE_OPENMP AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupOpenMP.cmake") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupOpenMP.cmake") endif() @@ -79,7 +81,7 @@ endif() # CUDA #------------------------------------ if (NOT TARGET cuda) - message(STATUS "CUDA Support is ${BLT_ENABLE_CUDA}") + message(STATUS "${_current_project_name} CUDA support is ${BLT_ENABLE_CUDA}") if (BLT_ENABLE_CUDA AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupCUDA.cmake") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupCUDA.cmake") endif() @@ -90,7 +92,7 @@ endif() # HIP #------------------------------------ if (NOT TARGET blt_hip) - message(STATUS "HIP Support is ${BLT_ENABLE_HIP}") + message(STATUS "${_current_project_name} HIP support is ${BLT_ENABLE_HIP}") if (BLT_ENABLE_HIP AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupHIP.cmake") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupHIP.cmake") endif() diff --git a/cmake/BLTThirdPartyConfigFlags.cmake.in b/cmake/BLTThirdPartyConfigFlags.cmake.in index 446d33f2b..8d86f0970 100644 --- a/cmake/BLTThirdPartyConfigFlags.cmake.in +++ b/cmake/BLTThirdPartyConfigFlags.cmake.in @@ -3,32 +3,18 @@ set(BLT_ENABLE_HIP @ENABLE_HIP@) set(BLT_ENABLE_MPI @ENABLE_MPI@) set(BLT_ENABLE_OPENMP @ENABLE_OPENMP@) set(BLT_ENABLE_FIND_MPI @ENABLE_FIND_MPI@) +set(BLT_ENABLE_CLANG_CUDA @ENABLE_CLANG_CUDA@) -foreach(_var BLT_ENABLE_CUDA BLT_ENABLE_HIP BLT_ENABLE_MPI BLT_ENABLE_OPENMP BLT_ENABLE_FIND_MPI) - if(NOT ${_var}) - set(${_var} OFF) - endif() -endforeach() - -# User configurable CUDA options needed by downstream. Normally, exporting -# these targets would pass these flags to downstream targets, but this -# must be done manually if targets aren't exported. -if ("@ENABLE_CLANG_CUDA@" AND NOT DEFINED ENABLE_CLANG_CUDA) - set(BLT_ENABLE_CLANG_CUDA "@ENABLE_CLANG_CUDA@") -# If the user specifies this variable, ignore the inherited flag. -elseif (DEFINED ENABLE_CLANG_CUDA) - set(BLT_ENABLE_CLANG_CUDA ${ENABLE_CLANG_CUDA}) -endif() - -if ("@BLT_CLANG_CUDA_ARCH@" AND NOT DEFINED BLT_CLANG_CUDA_ARCH) +if (NOT DEFINED BLT_CLANG_CUDA_ARCH) set(BLT_CLANG_CUDA_ARCH "@BLT_CLANG_CUDA_ARCH@") endif() -if ("@CUDA_TOOLKIT_ROOT_DIR@" AND NOT DEFINED CUDA_TOOLKIT_ROOT_DIR) +if (NOT DEFINED CUDA_TOOLKIT_ROOT_DIR) set(CUDA_TOOLKIT_ROOT_DIR "@CUDA_TOOLKIT_ROOT_DIR@") endif() -# User configurable HIP options needed by downstream -if ("@ROCM_PATH@" AND NOT DEFINED ROCM_PATH) +if (NOT DEFINED ROCM_PATH) set(ROCM_PATH "@ROCM_PATH@") endif() + +set(_current_project_name @PROJECT_NAME@) From f3fbb720b420aa0781dc64444cf42a0e76676193 Mon Sep 17 00:00:00 2001 From: Chris White Date: Mon, 4 Mar 2024 18:11:31 -0800 Subject: [PATCH 14/36] always print project blt support --- cmake/BLTSetupTargets.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/BLTSetupTargets.cmake b/cmake/BLTSetupTargets.cmake index cc1f3a3f9..da229b97b 100644 --- a/cmake/BLTSetupTargets.cmake +++ b/cmake/BLTSetupTargets.cmake @@ -58,8 +58,8 @@ endif() #------------------------------------ # MPI #------------------------------------ +message(STATUS "${_current_project_name} MPI support is ${BLT_ENABLE_MPI}") if (NOT TARGET mpi) - message(STATUS "${_current_project_name} MPI support is ${BLT_ENABLE_MPI}") if (BLT_ENABLE_MPI AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupMPI.cmake") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupMPI.cmake") endif() @@ -69,8 +69,8 @@ endif() #------------------------------------ # OpenMP #------------------------------------ +message(STATUS "${_current_project_name} OpenMP support is ${BLT_ENABLE_OPENMP}") if (NOT TARGET openmp) - message(STATUS "${_current_project_name} OpenMP support is ${BLT_ENABLE_OPENMP}") if (BLT_ENABLE_OPENMP AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupOpenMP.cmake") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupOpenMP.cmake") endif() @@ -80,8 +80,8 @@ endif() #------------------------------------ # CUDA #------------------------------------ +message(STATUS "${_current_project_name} CUDA support is ${BLT_ENABLE_CUDA}") if (NOT TARGET cuda) - message(STATUS "${_current_project_name} CUDA support is ${BLT_ENABLE_CUDA}") if (BLT_ENABLE_CUDA AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupCUDA.cmake") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupCUDA.cmake") endif() @@ -91,8 +91,8 @@ endif() #------------------------------------ # HIP #------------------------------------ +message(STATUS "${_current_project_name} HIP support is ${BLT_ENABLE_HIP}") if (NOT TARGET blt_hip) - message(STATUS "${_current_project_name} HIP support is ${BLT_ENABLE_HIP}") if (BLT_ENABLE_HIP AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupHIP.cmake") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupHIP.cmake") endif() From 4eb6a65562de61147ae78496a1c257c72a1e3628 Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 09:51:41 -0800 Subject: [PATCH 15/36] honor the current project --- cmake/BLTThirdPartyConfigFlags.cmake.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/BLTThirdPartyConfigFlags.cmake.in b/cmake/BLTThirdPartyConfigFlags.cmake.in index 8d86f0970..8c7744fdc 100644 --- a/cmake/BLTThirdPartyConfigFlags.cmake.in +++ b/cmake/BLTThirdPartyConfigFlags.cmake.in @@ -3,7 +3,11 @@ set(BLT_ENABLE_HIP @ENABLE_HIP@) set(BLT_ENABLE_MPI @ENABLE_MPI@) set(BLT_ENABLE_OPENMP @ENABLE_OPENMP@) set(BLT_ENABLE_FIND_MPI @ENABLE_FIND_MPI@) -set(BLT_ENABLE_CLANG_CUDA @ENABLE_CLANG_CUDA@) + +# Always prefer the current project if they turned it on +if(ENABLE_CLANG_CUDA) + set(BLT_ENABLE_CLANG_CUDA @ENABLE_CLANG_CUDA@) +endif() if (NOT DEFINED BLT_CLANG_CUDA_ARCH) set(BLT_CLANG_CUDA_ARCH "@BLT_CLANG_CUDA_ARCH@") From ad46813634c6f5faa894bf814e4d7a056bd87ee6 Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 10:12:58 -0800 Subject: [PATCH 16/36] fix if --- cmake/BLTThirdPartyConfigFlags.cmake.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/BLTThirdPartyConfigFlags.cmake.in b/cmake/BLTThirdPartyConfigFlags.cmake.in index 8c7744fdc..6112f369e 100644 --- a/cmake/BLTThirdPartyConfigFlags.cmake.in +++ b/cmake/BLTThirdPartyConfigFlags.cmake.in @@ -6,6 +6,8 @@ set(BLT_ENABLE_FIND_MPI @ENABLE_FIND_MPI@) # Always prefer the current project if they turned it on if(ENABLE_CLANG_CUDA) + set(BLT_ENABLE_CLANG_CUDA ${ENABLE_CLANG_CUDA}) +else() set(BLT_ENABLE_CLANG_CUDA @ENABLE_CLANG_CUDA@) endif() From 1e9f9badd0c174a406e54ada47d73a38afd8e98e Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 10:22:17 -0800 Subject: [PATCH 17/36] clarify comment --- cmake/BLTMacros.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/BLTMacros.cmake b/cmake/BLTMacros.cmake index 920f3d0da..e31d82615 100644 --- a/cmake/BLTMacros.cmake +++ b/cmake/BLTMacros.cmake @@ -209,10 +209,9 @@ macro(blt_add_library) # # Header-only library support # - # Note: Will not add header files to header-only interface libraries in older versions - # of CMake when CMP0076 is set to NEW - # if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0" ) + # Adding headers here allows them to show up in IDE projects but is not + # necessary for building add_library( ${arg_NAME} INTERFACE ${arg_HEADERS} ) else() add_library( ${arg_NAME} INTERFACE ) From 97107ed839c20ab26fbffb08dd494fac5ded4ca2 Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 12:14:36 -0800 Subject: [PATCH 18/36] clarify comments --- RELEASE-NOTES.md | 2 ++ cmake/BLTSetupTargets.cmake | 20 +++++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 912376912..197e2bd88 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -17,6 +17,8 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/ Fortran targets created with BLT macros. - Remove setting CMP0076 to OLD which left relative paths in `target_sources()` instead of altering them to absolute paths. +- Header-only libraries headers now show up under their own target in IDE project views instead of + under downstream targes. This only works in CMake >= 3.19, otherwise they will not show up at all. ## [Version 0.6.1] - Release date 2024-01-29 diff --git a/cmake/BLTSetupTargets.cmake b/cmake/BLTSetupTargets.cmake index da229b97b..082c4410f 100644 --- a/cmake/BLTSetupTargets.cmake +++ b/cmake/BLTSetupTargets.cmake @@ -3,9 +3,9 @@ # # SPDX-License-Identifier: (BSD-3-Clause) -# This file is intended to be included in the *-config.cmake files of -# any project using a third-party library. The macro -# `blt_install_tpl_setups(DESTINATION )` installs this file +# This file is intended to be included in the installed config files of +# any project using BLT's third-party library as well as in a BLT project. +# The macro `blt_install_tpl_setups(DESTINATION )` installs this file # into the destination specified by the argument . # BLTInstallableMacros provides helper macros for setting up and creating @@ -14,21 +14,15 @@ if (NOT BLT_LOADED) include("${CMAKE_CURRENT_LIST_DIR}/BLTInstallableMacros.cmake") endif() -# If the generated TPL config file exists, include it here. + +# Handle the two cases of TPL config variables, installed from upstream project +# and the current/main BLT project. Prefix all variables here to not conflict with +# non-BLT projects that load this as a configuration file. if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/BLTThirdPartyConfigFlags.cmake") # Case: Imported BLT project (ie. an installed TPL loading its BLT targets) include("${CMAKE_CURRENT_LIST_DIR}/BLTThirdPartyConfigFlags.cmake") else() # Case: Main BLT project (ie. a project loading it's own BLT) - # Otherwise, configure the TPL flags. We have to prefix these variables with - # BLT so that they never conflict with user-level CMake variables in downstream - # projects. - # - # We have to do some checks before we overwrite these internal variables to assure - # that we don't turn off a third-party library enabled by the dependency. - if (DEFINED BLT_ENABLE_HIP) - message(FATAL_ERROR "This variable should never exist at this point. Something has gone horribly wrong.") - endif() set(BLT_ENABLE_HIP ${ENABLE_HIP}) set(BLT_ENABLE_CUDA ${ENABLE_CUDA}) set(BLT_ENABLE_MPI ${ENABLE_MPI}) From e9c33bc73caf60ef3b6019290b0b4845d8c72a8b Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 13:10:22 -0800 Subject: [PATCH 19/36] make 'on' for BLT TPLs sticky --- cmake/BLTSetupTargets.cmake | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/cmake/BLTSetupTargets.cmake b/cmake/BLTSetupTargets.cmake index 082c4410f..521c7a94a 100644 --- a/cmake/BLTSetupTargets.cmake +++ b/cmake/BLTSetupTargets.cmake @@ -23,12 +23,26 @@ if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/BLTThirdPartyConfigFlags.cmake") include("${CMAKE_CURRENT_LIST_DIR}/BLTThirdPartyConfigFlags.cmake") else() # Case: Main BLT project (ie. a project loading it's own BLT) - set(BLT_ENABLE_HIP ${ENABLE_HIP}) - set(BLT_ENABLE_CUDA ${ENABLE_CUDA}) - set(BLT_ENABLE_MPI ${ENABLE_MPI}) - set(BLT_ENABLE_OPENMP ${ENABLE_OPENMP}) - set(BLT_ENABLE_FIND_MPI ${ENABLE_FIND_MPI}) - set(BLT_ENABLE_CLANG_CUDA ${ENABLE_CLANG_CUDA}) + # + # Always stay enabled if any upstream has already turned you on. + if(NOT BLT_ENABLE_HIP) + set(BLT_ENABLE_HIP ${ENABLE_HIP}) + endif() + if(NOT BLT_ENABLE_CUDA) + set(BLT_ENABLE_CUDA ${ENABLE_CUDA}) + endif() + if(NOT BLT_ENABLE_MPI) + set(BLT_ENABLE_MPI ${ENABLE_MPI}) + endif() + if(NOT BLT_ENABLE_OPENMP) + set(BLT_ENABLE_OPENMP ${ENABLE_OPENMP}) + endif() + if(NOT BLT_ENABLE_FIND_MPI) + set(BLT_ENABLE_FIND_MPI ${ENABLE_FIND_MPI}) + endif() + if(NOT BLT_ENABLE_CLANG_CUDA) + set(BLT_ENABLE_CLANG_CUDA ${ENABLE_CLANG_CUDA}) + endif() set(_current_project_name ${PROJECT_NAME}) endif() @@ -36,9 +50,9 @@ endif() # Detect if Fortran has been introduced. get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES) if(_languages MATCHES "Fortran") - set(_fortran_already_enabled TRUE) + set(_fortran_already_enabled TRUE) else() - set(_fortran_already_enabled FALSE) + set(_fortran_already_enabled FALSE) endif() # Only update ENABLE_FORTRAN if it is a new requirement, don't turn From 661c31668144765619db32861a289a868c2c4641 Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 13:51:04 -0800 Subject: [PATCH 20/36] make 'on' for BLT TPLs sticky --- cmake/BLTThirdPartyConfigFlags.cmake.in | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cmake/BLTThirdPartyConfigFlags.cmake.in b/cmake/BLTThirdPartyConfigFlags.cmake.in index 6112f369e..c5c107a92 100644 --- a/cmake/BLTThirdPartyConfigFlags.cmake.in +++ b/cmake/BLTThirdPartyConfigFlags.cmake.in @@ -1,8 +1,19 @@ -set(BLT_ENABLE_CUDA @ENABLE_CUDA@) -set(BLT_ENABLE_HIP @ENABLE_HIP@) -set(BLT_ENABLE_MPI @ENABLE_MPI@) -set(BLT_ENABLE_OPENMP @ENABLE_OPENMP@) -set(BLT_ENABLE_FIND_MPI @ENABLE_FIND_MPI@) +# Always stay enabled if any upstream has already turned you on. +if(NOT BLT_ENABLE_CUDA) + set(BLT_ENABLE_CUDA @ENABLE_CUDA@) +endif() +if(NOT BLT_ENABLE_HIP) + set(BLT_ENABLE_HIP @ENABLE_HIP@) +endif() +if(NOT BLT_ENABLE_MPI) + set(BLT_ENABLE_MPI @ENABLE_MPI@) +endif() +if(NOT BLT_ENABLE_OPENMP) + set(BLT_ENABLE_OPENMP @ENABLE_OPENMP@) +endif() +if(NOT BLT_ENABLE_FIND_MPI) + set(BLT_ENABLE_FIND_MPI @ENABLE_FIND_MPI@) +endif() # Always prefer the current project if they turned it on if(ENABLE_CLANG_CUDA) From e3b17cf502d3d974ddb81fbae227754cbf03d0b8 Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 15:24:57 -0800 Subject: [PATCH 21/36] add release note about cmake version --- RELEASE-NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 197e2bd88..7125190e9 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -19,6 +19,7 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/ them to absolute paths. - Header-only libraries headers now show up under their own target in IDE project views instead of under downstream targes. This only works in CMake >= 3.19, otherwise they will not show up at all. +- Raised version for base CMake version supported by BLT to 3.15 to support ALIAS targets across BLT. ## [Version 0.6.1] - Release date 2024-01-29 From b5e7fa1e57b24e0a294d76d55f013991bd05f773 Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 15:25:15 -0800 Subject: [PATCH 22/36] cleanup messages --- cmake/BLTSetupTargets.cmake | 13 ++++++++----- cmake/BLTThirdPartyConfigFlags.cmake.in | 2 -- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmake/BLTSetupTargets.cmake b/cmake/BLTSetupTargets.cmake index 521c7a94a..ddcb6c5d5 100644 --- a/cmake/BLTSetupTargets.cmake +++ b/cmake/BLTSetupTargets.cmake @@ -44,7 +44,10 @@ else() set(BLT_ENABLE_CLANG_CUDA ${ENABLE_CLANG_CUDA}) endif() - set(_current_project_name ${PROJECT_NAME}) + message(STATUS "BLT MPI support is ${BLT_ENABLE_MPI}") + message(STATUS "BLT OpenMP support is ${BLT_ENABLE_OPENMP}") + message(STATUS "BLT CUDA support is ${BLT_ENABLE_CUDA}") + message(STATUS "BLT HIP support is ${BLT_ENABLE_HIP}") endif() # Detect if Fortran has been introduced. @@ -66,9 +69,9 @@ endif() #------------------------------------ # MPI #------------------------------------ -message(STATUS "${_current_project_name} MPI support is ${BLT_ENABLE_MPI}") if (NOT TARGET mpi) if (BLT_ENABLE_MPI AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupMPI.cmake") + message(STATUS "Creating BLT MPI targets...") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupMPI.cmake") endif() endif() @@ -77,9 +80,9 @@ endif() #------------------------------------ # OpenMP #------------------------------------ -message(STATUS "${_current_project_name} OpenMP support is ${BLT_ENABLE_OPENMP}") if (NOT TARGET openmp) if (BLT_ENABLE_OPENMP AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupOpenMP.cmake") + message(STATUS "Creating BLT OpenMP targets...") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupOpenMP.cmake") endif() endif() @@ -88,9 +91,9 @@ endif() #------------------------------------ # CUDA #------------------------------------ -message(STATUS "${_current_project_name} CUDA support is ${BLT_ENABLE_CUDA}") if (NOT TARGET cuda) if (BLT_ENABLE_CUDA AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupCUDA.cmake") + message(STATUS "Creating BLT CUDA targets...") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupCUDA.cmake") endif() endif() @@ -99,9 +102,9 @@ endif() #------------------------------------ # HIP #------------------------------------ -message(STATUS "${_current_project_name} HIP support is ${BLT_ENABLE_HIP}") if (NOT TARGET blt_hip) if (BLT_ENABLE_HIP AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupHIP.cmake") + message(STATUS "Creating BLT HIP targets...") include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/BLTSetupHIP.cmake") endif() endif() diff --git a/cmake/BLTThirdPartyConfigFlags.cmake.in b/cmake/BLTThirdPartyConfigFlags.cmake.in index c5c107a92..d91b73cb9 100644 --- a/cmake/BLTThirdPartyConfigFlags.cmake.in +++ b/cmake/BLTThirdPartyConfigFlags.cmake.in @@ -33,5 +33,3 @@ endif() if (NOT DEFINED ROCM_PATH) set(ROCM_PATH "@ROCM_PATH@") endif() - -set(_current_project_name @PROJECT_NAME@) From 1b6ababd46d3b1c1fcfa8b713c76121800be9c3e Mon Sep 17 00:00:00 2001 From: Chris White Date: Tue, 5 Mar 2024 16:17:06 -0800 Subject: [PATCH 23/36] fix capitalization --- cmake/SetupCompilerOptions.cmake | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmake/SetupCompilerOptions.cmake b/cmake/SetupCompilerOptions.cmake index 59dc7628f..74a758db7 100644 --- a/cmake/SetupCompilerOptions.cmake +++ b/cmake/SetupCompilerOptions.cmake @@ -387,28 +387,28 @@ endif() ################################## # Remove implicit link libraries ################################## -message(STATUS "CMake's C implicit Link Libraries: ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}") -message(STATUS "CMake's CXX implicit Link Libraries: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") +message(STATUS "CMake's C implicit link libraries: ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}") +message(STATUS "CMake's CXX implicit link libraries: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") if (ENABLE_FORTRAN) - message(STATUS "CMake's Fortran implicit Link Libraries: ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") + message(STATUS "CMake's Fortran implicit link libraries: ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") endif () if (ENABLE_CUDA) - message(STATUS "CMake's CUDA implicit Link Libraries: ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES}") + message(STATUS "CMake's CUDA implicit link libraries: ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES}") endif () if(BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE) message(STATUS "Removing implicit link libraries: ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}") list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_LIBRARIES ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) - message(STATUS "Updated C implicit Link Libraries: ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}") + message(STATUS "Updated C implicit link libraries: ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}") list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_LIBRARIES ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) - message(STATUS "Updated CXX implicit Link Libraries: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") + message(STATUS "Updated CXX implicit link libraries: ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") if (ENABLE_FORTRAN) list(REMOVE_ITEM CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) - message(STATUS "Updated Fortran implicit Link Libraries: ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") + message(STATUS "Updated Fortran implicit link libraries: ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") endif () if (ENABLE_CUDA) list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES ${BLT_CMAKE_IMPLICIT_LINK_LIBRARIES_EXCLUDE}) - message(STATUS "Updated CUDA implicit Link Libraries: ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES}") + message(STATUS "Updated CUDA implicit link libraries: ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES}") endif () endif() From c98f320835d71f778fbffcc48f07675142c08635 Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 6 Mar 2024 13:48:47 -0800 Subject: [PATCH 24/36] be more specific on compile vs link flags --- cmake/thirdparty/BLTSetupOpenMP.cmake | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/cmake/thirdparty/BLTSetupOpenMP.cmake b/cmake/thirdparty/BLTSetupOpenMP.cmake index 30567b15f..22f3078cc 100644 --- a/cmake/thirdparty/BLTSetupOpenMP.cmake +++ b/cmake/thirdparty/BLTSetupOpenMP.cmake @@ -19,27 +19,39 @@ if(BLT_ENABLE_FORTRAN) endif() set(BLT_OPENMP_FLAGS_DIFFER ${_flags_differ} CACHE BOOL "") -set(_flags ${OpenMP_CXX_FLAGS}) +set(_compile_flags ${OpenMP_CXX_FLAGS}) +set(_link_flags) + +if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0" ) + set(_link_exp LINK_LANGUAGE) +else() + set(_link_exp COMPILE_LANGUAGE) +endif() if(NOT COMPILER_FAMILY_IS_MSVC) if(BLT_ENABLE_CUDA AND BLT_OPENMP_FLAGS_DIFFER) - set(_flags + set(_compile_flags $<$>,$>>:${OpenMP_CXX_FLAGS}> $<$:-Xcompiler=${OpenMP_CXX_FLAGS}> $<$:${OpenMP_Fortran_FLAGS}>) elseif(BLT_ENABLE_CUDA) - set(_flags + set(_compile_flags $<$>:${OpenMP_CXX_FLAGS}> $<$:-Xcompiler=${OpenMP_CXX_FLAGS}>) elseif(BLT_OPENMP_FLAGS_DIFFER) - set(_flags + set(_compile_flags $<$>:${OpenMP_CXX_FLAGS}> $<$:${OpenMP_Fortran_FLAGS}>) endif() -endif() -set(_compile_flags ${_flags}) -set(_link_flags ${_flags}) + if(BLT_OPENMP_FLAGS_DIFFER) + set(_link_flags + $<$>:${OpenMP_CXX_FLAGS}> + $<$<${_link_exp}:Fortran>:${OpenMP_Fortran_FLAGS}>) + else() + set(_link_flags ${OpenMP_CXX_FLAGS}) + endif() +endif() # Allow user to override if (BLT_OPENMP_COMPILE_FLAGS) From ee7dc7670b48e3e879ae7336d1428b914fdfab75 Mon Sep 17 00:00:00 2001 From: Cyrus Harrison Date: Thu, 7 Mar 2024 11:53:02 -0800 Subject: [PATCH 25/36] Update RELEASE-NOTES.md --- RELEASE-NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 7125190e9..a4edf4205 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -18,7 +18,7 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/ - Remove setting CMP0076 to OLD which left relative paths in `target_sources()` instead of altering them to absolute paths. - Header-only libraries headers now show up under their own target in IDE project views instead of - under downstream targes. This only works in CMake >= 3.19, otherwise they will not show up at all. + under downstream targets. This only works in CMake >= 3.19, otherwise they will not show up at all. - Raised version for base CMake version supported by BLT to 3.15 to support ALIAS targets across BLT. ## [Version 0.6.1] - Release date 2024-01-29 From 02dbff14197a2a8b2cdb6397418635222cc60ee4 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 14:34:53 -0700 Subject: [PATCH 26/36] bump version to 0.6.2 --- RELEASE-NOTES.md | 5 ++++- SetupBLT.cmake | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index a4edf4205..395f5ce5f 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -9,6 +9,8 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/ ## [Unreleased] - Release date yyyy-mm-dd +## [Version 0.6.2] - Release date 2024-03-15 + ### Added - Added output for CMake's implicitly added link libraries and directories. @@ -329,7 +331,8 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/ -[Unreleased]: https://github.com/LLNL/blt/compare/v0.6.1...develop +[Unreleased]: https://github.com/LLNL/blt/compare/v0.6.2...develop +[Version 0.6.2]: https://github.com/LLNL/blt/compare/v0.6.1...v0.6.2 [Version 0.6.1]: https://github.com/LLNL/blt/compare/v0.6.0...v0.6.1 [Version 0.6.0]: https://github.com/LLNL/blt/compare/v0.5.3...v0.6.0 [Version 0.5.3]: https://github.com/LLNL/blt/compare/v0.5.2...v0.5.3 diff --git a/SetupBLT.cmake b/SetupBLT.cmake index f01f2d04d..7cbcc8510 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.6.1" CACHE STRING "") + set(BLT_VERSION "0.6.2" CACHE STRING "") mark_as_advanced(BLT_VERSION) message(STATUS "BLT Version: ${BLT_VERSION}") From 60e811e8eb7624549ebc2118141f2ceb8df85406 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 14:56:00 -0700 Subject: [PATCH 27/36] use correct CUDA settings --- .../cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/projects/cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake b/tests/projects/cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake index 3f46d1816..e58a61040 100644 --- a/tests/projects/cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake +++ b/tests/projects/cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake @@ -21,9 +21,9 @@ set(CMAKE_CXX_COMPILER "${CLANG_HOME}/bin/clang++" CACHE PATH "") #------------------------------------------------------------------------------ set(ENABLE_CUDA ON CACHE BOOL "") -set(CUDA_TOOLKIT_ROOT_DIR "/usr/tce/packages/cuda/cuda-11.1.0" CACHE PATH "") +set(CUDA_TOOLKIT_ROOT_DIR "/usr/tce/packages/cuda/cuda-11.2.0" CACHE PATH "") set(CMAKE_CUDA_COMPILER "${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc" CACHE PATH "") set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}" CACHE PATH "") -set(CMAKE_CUDA_ARCHITECTURES "60" CACHE STRING "") +set(CMAKE_CUDA_ARCHITECTURES "70" CACHE STRING "") set(CMAKE_CUDA_FLAGS "-restrict --expt-extended-lambda -G" CACHE STRING "") From 826f085f5362cb1f18dfde1668f4b1054a8458a3 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 14:57:18 -0700 Subject: [PATCH 28/36] fix spacing --- cmake/thirdparty/BLTSetupCUDA.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/thirdparty/BLTSetupCUDA.cmake b/cmake/thirdparty/BLTSetupCUDA.cmake index 76d1b0d1c..dc1f95ae0 100644 --- a/cmake/thirdparty/BLTSetupCUDA.cmake +++ b/cmake/thirdparty/BLTSetupCUDA.cmake @@ -114,9 +114,9 @@ message(STATUS "CUDA Version: ${CUDA_VERSION_STRING}") message(STATUS "CUDA Toolkit Root Dir: ${CUDA_TOOLKIT_ROOT_DIR}") message(STATUS "CUDA Compiler: ${CMAKE_CUDA_COMPILER}") if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.9.0" ) - message(STATUS "CUDA Host Compiler: ${CMAKE_CUDA_HOST_COMPILER}") + message(STATUS "CUDA Host Compiler: ${CMAKE_CUDA_HOST_COMPILER}") else() - message(STATUS "CUDA Host Compiler: ${CUDA_HOST_COMPILER}") + message(STATUS "CUDA Host Compiler: ${CUDA_HOST_COMPILER}") endif() message(STATUS "CUDA Include Path: ${CUDA_INCLUDE_DIRS}") message(STATUS "CUDA Libraries: ${CUDA_LIBRARIES}") From 639bd598183e42255d685295e1a358f1e08060ae Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 15:24:51 -0700 Subject: [PATCH 29/36] use known good host-config --- .gitlab/build_lassen.yml | 2 +- .../base/clang@10.0.1_nvcc_c++14_lassen.cmake | 29 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 tests/projects/cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake diff --git a/.gitlab/build_lassen.yml b/.gitlab/build_lassen.yml index 5defcf49c..d5fd714b4 100644 --- a/.gitlab/build_lassen.yml +++ b/.gitlab/build_lassen.yml @@ -67,5 +67,5 @@ lassen-clang_14.0.5_with_gcc_8.3.1_nvcc_c++_only: lassen-clang_10.0.1_nvcc_cuda_clang_test: variables: ENABLED_BLT_TESTS: "cuda-arch cuda-mpi-cpp" - HOST_CONFIG: "cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake" + HOST_CONFIG: "clang@10.0.1_nvcc_c++17.cmake" extends: [.run_project_integration_test_on_lassen, .with_cuda] diff --git a/tests/projects/cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake b/tests/projects/cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake deleted file mode 100644 index e58a61040..000000000 --- a/tests/projects/cuda-arch/base/clang@10.0.1_nvcc_c++14_lassen.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and -# other BLT Project Developers. See the top-level LICENSE file for details -# -# SPDX-License-Identifier: (BSD-3-Clause) - -#------------------------------------------------------------------------------ -# Host-config file for executing tests of BLT's configuration of CUDA targets on Lassen. -#------------------------------------------------------------------------------ - -#------------------------------------------------------------------------------ -# Compilers -#------------------------------------------------------------------------------ - -set(BLT_CXX_STD "c++14" CACHE STRING "") -set(CLANG_HOME "/usr/tce/packages/clang/clang-16.0.6") -set(CMAKE_C_COMPILER "${CLANG_HOME}/bin/clang" CACHE PATH "") -set(CMAKE_CXX_COMPILER "${CLANG_HOME}/bin/clang++" CACHE PATH "") - -#------------------------------------------------------------------------------ -# CUDA support -#------------------------------------------------------------------------------ -set(ENABLE_CUDA ON CACHE BOOL "") - -set(CUDA_TOOLKIT_ROOT_DIR "/usr/tce/packages/cuda/cuda-11.2.0" CACHE PATH "") -set(CMAKE_CUDA_COMPILER "${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc" CACHE PATH "") -set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}" CACHE PATH "") - -set(CMAKE_CUDA_ARCHITECTURES "70" CACHE STRING "") -set(CMAKE_CUDA_FLAGS "-restrict --expt-extended-lambda -G" CACHE STRING "") From f3ac7f17dcb4bc12ab82aa38937a8285f7d2dc6d Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 15:30:22 -0700 Subject: [PATCH 30/36] use full path --- .gitlab/build_lassen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/build_lassen.yml b/.gitlab/build_lassen.yml index d5fd714b4..4a92a9f12 100644 --- a/.gitlab/build_lassen.yml +++ b/.gitlab/build_lassen.yml @@ -67,5 +67,5 @@ lassen-clang_14.0.5_with_gcc_8.3.1_nvcc_c++_only: lassen-clang_10.0.1_nvcc_cuda_clang_test: variables: ENABLED_BLT_TESTS: "cuda-arch cuda-mpi-cpp" - HOST_CONFIG: "clang@10.0.1_nvcc_c++17.cmake" + HOST_CONFIG: "host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@10.0.1_nvcc_c++17.cmake" extends: [.run_project_integration_test_on_lassen, .with_cuda] From 01ef6270f4b7a05036f4f6b866bb26eb99eb0852 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 15:46:33 -0700 Subject: [PATCH 31/36] use all blessed host-configs and remove old ones" --- .gitlab/build_lassen.yml | 2 +- .gitlab/build_quartz.yml | 2 +- .gitlab/build_tioga.yml | 2 +- .gitlab/run_project_integration_tests.sh | 2 +- .../llnl/toss_4_x86_64_ib/clang@14.0.6.cmake | 4 +++- .../base/clang@14.0.0_hip.cmake | 21 ------------------- .../base/clang@14.0.6.cmake | 4 ---- 7 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 tests/projects/hip-config-test/base/clang@14.0.0_hip.cmake delete mode 100644 tests/projects/openmp-cpp-fortran/base/clang@14.0.6.cmake diff --git a/.gitlab/build_lassen.yml b/.gitlab/build_lassen.yml index 4a92a9f12..d5fd714b4 100644 --- a/.gitlab/build_lassen.yml +++ b/.gitlab/build_lassen.yml @@ -67,5 +67,5 @@ lassen-clang_14.0.5_with_gcc_8.3.1_nvcc_c++_only: lassen-clang_10.0.1_nvcc_cuda_clang_test: variables: ENABLED_BLT_TESTS: "cuda-arch cuda-mpi-cpp" - HOST_CONFIG: "host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@10.0.1_nvcc_c++17.cmake" + HOST_CONFIG: "clang@10.0.1_nvcc_c++17.cmake" extends: [.run_project_integration_test_on_lassen, .with_cuda] diff --git a/.gitlab/build_quartz.yml b/.gitlab/build_quartz.yml index b646b1cf0..e1262d5c8 100644 --- a/.gitlab/build_quartz.yml +++ b/.gitlab/build_quartz.yml @@ -78,6 +78,6 @@ quartz-intel_2022_1_0_cxx17: # HIP project tests quartz_openmp_mpi_fortran_tests: variables: - HOST_CONFIG: openmp-cpp-fortran/base/clang@14.0.6.cmake ENABLED_BLT_TESTS: "mpi-cpp-fortran,openmp-cpp-fortran,openmp-mpi-cpp" + HOST_CONFIG: "clang@14.0.6.cmake" extends: [.run_project_integration_test_on_quartz] diff --git a/.gitlab/build_tioga.yml b/.gitlab/build_tioga.yml index 67856f48e..125293eb8 100644 --- a/.gitlab/build_tioga.yml +++ b/.gitlab/build_tioga.yml @@ -38,5 +38,5 @@ tioga-clang_14_0_0_hip: tioga-clang_14.0.1_hip_config_test: variables: ENABLED_BLT_TESTS: "hip-config-test" - HOST_CONFIG: "hip-config-test/base/clang@14.0.0_hip.cmake" + HOST_CONFIG: "clang@14.0.0_hip.cmake" extends: [.run_project_integration_test_on_tioga] diff --git a/.gitlab/run_project_integration_tests.sh b/.gitlab/run_project_integration_tests.sh index 87562abec..99f251345 100755 --- a/.gitlab/run_project_integration_tests.sh +++ b/.gitlab/run_project_integration_tests.sh @@ -5,7 +5,7 @@ RUNNER_SCRIPT=`pwd`/tests/projects/run_tests.py cd `pwd`/tests/projects/ if [[ -z $HOST_CONFIG ]]; then - HOST_CONFIG=`pwd`/tests/projects/$HOST_CONFIG + HOST_CONFIG=`pwd`/host-configs/llnl/$SYS_TYPE/$HOST_CONFIG python3 $RUNNER_SCRIPT --run-test $ENABLED_BLT_TESTS --verbose --clean --blt-source-dir $BLT_DIR else python3 $RUNNER_SCRIPT --run-test $ENABLED_BLT_TESTS --host-config $HOST_CONFIG --verbose --clean --blt-source-dir $BLT_DIR diff --git a/host-configs/llnl/toss_4_x86_64_ib/clang@14.0.6.cmake b/host-configs/llnl/toss_4_x86_64_ib/clang@14.0.6.cmake index 2126c2378..c42f546a3 100644 --- a/host-configs/llnl/toss_4_x86_64_ib/clang@14.0.6.cmake +++ b/host-configs/llnl/toss_4_x86_64_ib/clang@14.0.6.cmake @@ -8,7 +8,7 @@ #------------------------------------------------------------------------------ # # This file provides CMake with paths / details for: -# C,C++, & Fortran compilers + MPI +# C,C++, & Fortran compilers + MPI + OpenMP #------------------------------------------------------------------------------ # clang-14.0.6 compilers @@ -27,6 +27,8 @@ set(ENABLE_FORTRAN ON CACHE BOOL "") # fortran compiler set(CMAKE_Fortran_COMPILER "${GNU_HOME}/bin/gfortran" CACHE PATH "") +set(ENABLE_OPENMP ON CACHE BOOL "") + #------------------------------------------------------------------------------ # Static Analysis Support #------------------------------------------------------------------------------ diff --git a/tests/projects/hip-config-test/base/clang@14.0.0_hip.cmake b/tests/projects/hip-config-test/base/clang@14.0.0_hip.cmake deleted file mode 100644 index ec80ea228..000000000 --- a/tests/projects/hip-config-test/base/clang@14.0.0_hip.cmake +++ /dev/null @@ -1,21 +0,0 @@ -#------------------------------------------------------------------------------ -# This is meant to be a lightweight host config file to tell CMake where to find -# HIP on Tioga, for CI purposes. -#------------------------------------------------------------------------------ -# CMake executable path: /usr/tce/packages/cmake/cmake-3.21.1/bin/cmake -#------------------------------------------------------------------------------ - -set(CMAKE_C_COMPILER "/opt/rocm-5.1.1/llvm/bin/amdclang" CACHE PATH "") -set(CMAKE_CXX_COMPILER "/opt/rocm-5.1.1/llvm/bin/amdclang++" CACHE PATH "") -set(CMAKE_Fortran_COMPILER "/opt/rocm-5.1.1/llvm/bin/amdflang" CACHE PATH "") -set(CMAKE_Fortran_FLAGS "-Mfreeform" CACHE STRING "") - -#------------------------------------------------------------------------------ -# HIP -#------------------------------------------------------------------------------ - -set(ENABLE_HIP ON CACHE BOOL "") -set(HIP_ROOT_DIR "/opt/rocm-5.1.1/hip" CACHE STRING "") -set(HIP_CLANG_PATH "/opt/rocm-5.1.1/hip/../llvm/bin" CACHE STRING "") -set(CMAKE_HIP_ARCHITECTURES "gfx90a" CACHE STRING "") -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--disable-new-dtags -L/opt/rocm-5.1.1/hip/../llvm/lib -L/opt/rocm-5.1.1/hip/lib -Wl,-rpath,/opt/rocm-5.1.1/hip/../llvm/lib:/opt/rocm-5.1.1/hip/lib -lpgmath -lflang -lflangrti -lompstub -lamdhip64 -L/opt/rocm-5.1.1/hip/../lib64 -Wl,-rpath,/opt/rocm-5.1.1/hip/../lib64 -lhsakmt -lamd_comgr" CACHE STRING "") diff --git a/tests/projects/openmp-cpp-fortran/base/clang@14.0.6.cmake b/tests/projects/openmp-cpp-fortran/base/clang@14.0.6.cmake deleted file mode 100644 index 6e83f45bb..000000000 --- a/tests/projects/openmp-cpp-fortran/base/clang@14.0.6.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(CLANG_VERSION "clang-14.0.6") -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 "") From f6a4f0530b208b7772abf8044c73ea20f58e21eb Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 15:56:00 -0700 Subject: [PATCH 32/36] simplify using path --- .gitlab/run_project_integration_tests.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.gitlab/run_project_integration_tests.sh b/.gitlab/run_project_integration_tests.sh index 99f251345..e7a385044 100755 --- a/.gitlab/run_project_integration_tests.sh +++ b/.gitlab/run_project_integration_tests.sh @@ -2,11 +2,7 @@ BLT_DIR=`pwd` RUNNER_SCRIPT=`pwd`/tests/projects/run_tests.py -cd `pwd`/tests/projects/ +HOST_CONFIG_PATH=`pwd`/host-configs/llnl/$SYS_TYPE/$HOST_CONFIG -if [[ -z $HOST_CONFIG ]]; then - HOST_CONFIG=`pwd`/host-configs/llnl/$SYS_TYPE/$HOST_CONFIG - python3 $RUNNER_SCRIPT --run-test $ENABLED_BLT_TESTS --verbose --clean --blt-source-dir $BLT_DIR -else - python3 $RUNNER_SCRIPT --run-test $ENABLED_BLT_TESTS --host-config $HOST_CONFIG --verbose --clean --blt-source-dir $BLT_DIR -fi +cd `pwd`/tests/projects/ +python3 $RUNNER_SCRIPT --run-test $ENABLED_BLT_TESTS --host-config $HOST_CONFIG_PATH --verbose --clean --blt-source-dir $BLT_DIR From 8af1712a9f357e5040bc753d329ab71998091dda Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 16:19:02 -0700 Subject: [PATCH 33/36] remove clang-cuda --- tests/projects/cuda-arch/downstream/CMakeLists.txt | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tests/projects/cuda-arch/downstream/CMakeLists.txt b/tests/projects/cuda-arch/downstream/CMakeLists.txt index f65b1c0ea..5bd3faee6 100644 --- a/tests/projects/cuda-arch/downstream/CMakeLists.txt +++ b/tests/projects/cuda-arch/downstream/CMakeLists.txt @@ -2,13 +2,9 @@ cmake_minimum_required(VERSION 3.14) project(cuda-clang-cpp-user LANGUAGES CXX) -set(ENABLE_CLANG_CUDA On CACHE BOOL "") -set(BLT_CLANG_CUDA_ARCH "sm_70" CACHE STRING "") -set(CMAKE_CUDA_SEPARABLE_COMPILATION On CACHE BOOL "") # Load BLT include(${BLT_SOURCE_DIR}/SetupBLT.cmake) -set(BLT_CXX_STD c++14 CACHE STRING "") # Calling find_package sets up the TPL targets needed by the project # in its argument. find_package(cuda-clang-cpp REQUIRED @@ -29,15 +25,7 @@ message(STATUS "CUDA target created with compile flags set to: ${cuda_compile_fl string(FIND "${cuda_compile_flags}" "-x" clang_cuda_flag) string(FIND "${cuda_compile_flags}" "sm_70" clang_cuda_arch) -string(FIND "${cuda_compile_flags}" "/usr/tce/packages/cuda/cuda-11.1.0" expected_cuda_toolkit_dir) - -if (clang_cuda_flag EQUAL -1) - message(FATAL_ERROR "Expected downstream project CLANG CUDA config flags to override upstream project's.") -endif() - -if(clang_cuda_arch EQUAL -1) - message(FATAL_ERROR "Expected downstream project CLANG CUDA cuda arch config flags to override upstream project's.") -endif() +string(FIND "${cuda_compile_flags}" "/usr/tce/packages/cuda/cuda-11.2.0" expected_cuda_toolkit_dir) if (expected_cuda_toolkit_dir EQUAL -1) message(FATAL_ERROR "Expected downstream project config flags to inherit upstream project's when alternative is not specified.") From 45572749994f43315f3128a80c86941d28ec8237 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 15 Mar 2024 16:26:32 -0700 Subject: [PATCH 34/36] remove more tests --- tests/projects/cuda-arch/downstream/CMakeLists.txt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/projects/cuda-arch/downstream/CMakeLists.txt b/tests/projects/cuda-arch/downstream/CMakeLists.txt index 5bd3faee6..677385d8d 100644 --- a/tests/projects/cuda-arch/downstream/CMakeLists.txt +++ b/tests/projects/cuda-arch/downstream/CMakeLists.txt @@ -17,20 +17,6 @@ if (NOT TARGET blt::cuda) "downstream project configuration.") endif() -# Check that the cuda target created during the `find_package` call contains the expected -# user provided flags for clang cuda. -get_target_property(cuda_compile_flags blt::cuda INTERFACE_COMPILE_OPTIONS) - -message(STATUS "CUDA target created with compile flags set to: ${cuda_compile_flags}") - -string(FIND "${cuda_compile_flags}" "-x" clang_cuda_flag) -string(FIND "${cuda_compile_flags}" "sm_70" clang_cuda_arch) -string(FIND "${cuda_compile_flags}" "/usr/tce/packages/cuda/cuda-11.2.0" expected_cuda_toolkit_dir) - -if (expected_cuda_toolkit_dir EQUAL -1) - message(FATAL_ERROR "Expected downstream project config flags to inherit upstream project's when alternative is not specified.") -endif() - # Compile a basic example to test correctness of link and compile flags. blt_add_executable( NAME hello-cuda From bff19e6100cf713280f6e1fa0ec0fd53ff813202 Mon Sep 17 00:00:00 2001 From: Chris White Date: Mon, 18 Mar 2024 11:42:00 -0700 Subject: [PATCH 35/36] fix line endings --- tests/projects/run_tests.py | 435 ++++++++++++++++++------------------ 1 file changed, 218 insertions(+), 217 deletions(-) mode change 100644 => 100755 tests/projects/run_tests.py diff --git a/tests/projects/run_tests.py b/tests/projects/run_tests.py old mode 100644 new mode 100755 index 23f5a7f57..4ef01f978 --- a/tests/projects/run_tests.py +++ b/tests/projects/run_tests.py @@ -1,217 +1,218 @@ -#!/bin/sh -"exec" "python3" "-u" "-B" "$0" "$@" -# Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and -# other BLT Project Developers. See the top-level LICENSE file for details -# -# SPDX-License-Identifier: (BSD-3-Clause) - -import os -import sys -import subprocess -import glob -import re -import argparse -import string -import shutil - -from functools import partial - -# Since we use subprocesses, flushing prints allows us to keep logs in -# order. -print = partial(print, flush=True) - -def sexe(cmd): - """ Helper for executing shell commands. """ - p = subprocess.Popen(cmd, - shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - out = p.communicate()[0] - out = out.decode('utf8') - return p.returncode, out - -def cmake_build_project(path_to_test: string, blt_source_dir: string, host_config: string, is_base: bool, verbose=False): - base_or_downstream = "base" if is_base else "downstream" - install_flag = "-DCMAKE_INSTALL_PREFIX" if is_base else "-Dbase_install_dir" - blt_path_flag = "-DBLT_SOURCE_DIR" - - # Convert these paths to absolute paths to avoid CMake seeing an incorrect relative path. - source_path = os.path.abspath(os.path.join(path_to_test, base_or_downstream)) - build_path = os.path.abspath(os.path.join(source_path, "build")) - install_path = os.path.abspath(os.path.join(path_to_test, "tmp_install_dir")) - - # Projects in this directory follow a base/downstream format, where base files - # are built and installed, and downstream projects are fed their install path. - # If a base project is being built, feed CMake the path to install the built - # project. - # If a downstream project is being built, feed CMake the base install path. - cmake_command = "cmake -DENABLE_GTEST=Off -B {0} -S {1} {2}={3} {4}={5}".format( - build_path, source_path, install_flag, install_path, blt_path_flag, blt_source_dir) - if host_config is not None and os.path.exists(host_config): - cmake_command += " -C {0}".format(host_config) - - build_command = "cmake --build {0}".format(build_path) - install_command = "cmake --install {0}".format(build_path) - # cmake, build and install the base project. - code, err = sexe(cmake_command) - if code: - return code, err - elif verbose: - print(err) - code, err = sexe(build_command) - if code: - return code, err - elif verbose: - print(err) - if is_base: - code, err = sexe(install_command) - if verbose: - print(err) - if code: - return code, err - elif verbose: - print(err) - - return 0, "Success" - -def clean_helper(path_to_test: string): - shutil.rmtree(os.path.join(path_to_test, "base", "build")) - shutil.rmtree(os.path.join(path_to_test, "downstream", "build")) - shutil.rmtree(os.path.join(path_to_test, "tmp_install_dir")) - -def run_test(path_to_test: string, blt_source_dir: string, host_config: string, verbose=False, clean=False): - """ Run test, using a yaml to specify CMake arguments """ - # CMake, Build and install base - code, err = cmake_build_project(path_to_test, blt_source_dir, host_config, True, verbose) - if code: - if clean: - shutil.rmtree(os.path.join(path_to_test, "base", "build")) - return code, err - # CMake, build downstream - code, err = cmake_build_project(path_to_test, blt_source_dir, host_config, False, verbose) - - if clean: - clean_helper(path_to_test) - - if code: - return code, err - - return 0, "Test {0} passed".format(path_to_test) - -def parse_args(): - "Parses args from command line" - parser = argparse.ArgumentParser() - parser.add_argument("--host-config", - dest="host-config", - default=None, - help="Host config file to be used by all test projects.") - - # Where to find BLT - parser.add_argument("--blt-source-dir", - dest="blt-source-dir", - default=None, - help="Path to BLT source to be used by all test projects.") - - # Verbose mode: useful for debugging. - parser.add_argument("--verbose", - action='store_true', - dest="verbose", - help="Print all stdout and stderr from running tests.") - - # Specify a subset of tests to run. Useful for debugging - parser.add_argument("--run-test", - default=None, - dest="run-test", - help="Comma delimited list of tests to run. Test names must be a subset of the " - "list of directories inside test. Only run tests specified.") - - # Specify whether to clean build and install directories - parser.add_argument("--clean", - action='store_true', - help="Remove build and install paths from test directories.") - - args, extra_args = parser.parse_known_args() - args = vars(args) - - if not args["blt-source-dir"]: - print("[ERROR: Required command line argument, 'blt-source-dir', was not provided.]") - return None - - if args["host-config"] is not None and not os.path.exists(args["host-config"]): - print("ERROR: Host config file {0} specified, but file does not exist.".format(args["host-config"])) - return None - - if args["run-test"] is not None: - all_tests = set(os.listdir(os.path.relpath("."))) - user_tests = set(args["run-test"].split(",")) - if not user_tests.issubset(all_tests): - user_tests_str = ", ".join(user_tests.difference(all_tests)) - print("ERROR: Specified test(s) {0}, but test(s) do not exist inside the test directory.".format(user_tests_str)) - return None - - if args["verbose"] is True: - print("Running tests verbosely") - - # Pretty print given args - print("========================================") - print("Command line arguments:") - for key in args.keys(): - print("[{0}]: {1}".format(key, args[key])) - print("========================================") - - return args - -def should_test_run(name, path, hostconfig): - run_test = True - #TODO: read regexs (?) from yaml file that show whether we should run the test - # and run them over the given host-config. - # for example, ENABLE_CUDA being ON, if none are present just run test always - return run_test - -def main(): - args = parse_args() - if not args: - return 1 - - # Iterate through the tests, run them, and report error if encountered. - tests = [] - blt_source_dir = args["blt-source-dir"] - host_config = args["host-config"] - verbose = args["verbose"] - clean = args["clean"] - - failed_tests = [] - tests_dir = os.path.relpath(".") - tests_to_run = os.listdir(tests_dir) - # Run only a subset of tests if specified. - if args["run-test"] is not None: - tests_to_run = args["run-test"].split(",") - - print("Running tests {0}".format(", ".join(tests_to_run))) - - for test_dir in tests_to_run: - path_to_test_dir = os.path.join(tests_dir, test_dir) - if not os.path.isdir(path_to_test_dir): - print(path_to_test_dir) - continue - tests.append(test_dir) - status, err = run_test(path_to_test_dir, blt_source_dir, host_config, verbose, clean) - print(err) - if status: - print("Test {0} failed with error {1}".format(test_dir, err)) - failed_tests.append(test_dir) - - # Print final status - if len(failed_tests) == 0: - print("[Success! All tests passed!]") - else: - print("[ERROR: The following {0} out of {1} tests failed:".format(len(failed_tests), len(tests))) - for name in failed_tests: - print(" {0}".format(name)) - print("]") - return 1 - - return 0 - -if __name__ == "__main__": - sys.exit(main()) +#!/bin/sh +"exec" "python3" "-u" "-B" "$0" "$@" + +# Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and +# other BLT Project Developers. See the top-level LICENSE file for details +# +# SPDX-License-Identifier: (BSD-3-Clause) + +import os +import sys +import subprocess +import glob +import re +import argparse +import string +import shutil + +from functools import partial + +# Since we use subprocesses, flushing prints allows us to keep logs in +# order. +print = partial(print, flush=True) + +def sexe(cmd): + """ Helper for executing shell commands. """ + p = subprocess.Popen(cmd, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + out = p.communicate()[0] + out = out.decode('utf8') + return p.returncode, out + +def cmake_build_project(path_to_test: string, blt_source_dir: string, host_config: string, is_base: bool, verbose=False): + base_or_downstream = "base" if is_base else "downstream" + install_flag = "-DCMAKE_INSTALL_PREFIX" if is_base else "-Dbase_install_dir" + blt_path_flag = "-DBLT_SOURCE_DIR" + + # Convert these paths to absolute paths to avoid CMake seeing an incorrect relative path. + source_path = os.path.abspath(os.path.join(path_to_test, base_or_downstream)) + build_path = os.path.abspath(os.path.join(source_path, "build")) + install_path = os.path.abspath(os.path.join(path_to_test, "tmp_install_dir")) + + # Projects in this directory follow a base/downstream format, where base files + # are built and installed, and downstream projects are fed their install path. + # If a base project is being built, feed CMake the path to install the built + # project. + # If a downstream project is being built, feed CMake the base install path. + cmake_command = "cmake -DENABLE_GTEST=Off -B {0} -S {1} {2}={3} {4}={5}".format( + build_path, source_path, install_flag, install_path, blt_path_flag, blt_source_dir) + if host_config is not None and os.path.exists(host_config): + cmake_command += " -C {0}".format(host_config) + + build_command = "cmake --build {0}".format(build_path) + install_command = "cmake --install {0}".format(build_path) + # cmake, build and install the base project. + code, err = sexe(cmake_command) + if code: + return code, err + elif verbose: + print(err) + code, err = sexe(build_command) + if code: + return code, err + elif verbose: + print(err) + if is_base: + code, err = sexe(install_command) + if verbose: + print(err) + if code: + return code, err + elif verbose: + print(err) + + return 0, "Success" + +def clean_helper(path_to_test: string): + shutil.rmtree(os.path.join(path_to_test, "base", "build")) + shutil.rmtree(os.path.join(path_to_test, "downstream", "build")) + shutil.rmtree(os.path.join(path_to_test, "tmp_install_dir")) + +def run_test(path_to_test: string, blt_source_dir: string, host_config: string, verbose=False, clean=False): + """ Run test, using a yaml to specify CMake arguments """ + # CMake, Build and install base + code, err = cmake_build_project(path_to_test, blt_source_dir, host_config, True, verbose) + if code: + if clean: + shutil.rmtree(os.path.join(path_to_test, "base", "build")) + return code, err + # CMake, build downstream + code, err = cmake_build_project(path_to_test, blt_source_dir, host_config, False, verbose) + + if clean: + clean_helper(path_to_test) + + if code: + return code, err + + return 0, "Test {0} passed".format(path_to_test) + +def parse_args(): + "Parses args from command line" + parser = argparse.ArgumentParser() + parser.add_argument("--host-config", + dest="host-config", + default=None, + help="Host config file to be used by all test projects.") + + # Where to find BLT + parser.add_argument("--blt-source-dir", + dest="blt-source-dir", + default=None, + help="Path to BLT source to be used by all test projects.") + + # Verbose mode: useful for debugging. + parser.add_argument("--verbose", + action='store_true', + dest="verbose", + help="Print all stdout and stderr from running tests.") + + # Specify a subset of tests to run. Useful for debugging + parser.add_argument("--run-test", + default=None, + dest="run-test", + help="Comma delimited list of tests to run. Test names must be a subset of the " + "list of directories inside test. Only run tests specified.") + + # Specify whether to clean build and install directories + parser.add_argument("--clean", + action='store_true', + help="Remove build and install paths from test directories.") + + args, extra_args = parser.parse_known_args() + args = vars(args) + + if not args["blt-source-dir"]: + print("[ERROR: Required command line argument, 'blt-source-dir', was not provided.]") + return None + + if args["host-config"] is not None and not os.path.exists(args["host-config"]): + print("ERROR: Host config file {0} specified, but file does not exist.".format(args["host-config"])) + return None + + if args["run-test"] is not None: + all_tests = set(os.listdir(os.path.relpath("."))) + user_tests = set(args["run-test"].split(",")) + if not user_tests.issubset(all_tests): + user_tests_str = ", ".join(user_tests.difference(all_tests)) + print("ERROR: Specified test(s) {0}, but test(s) do not exist inside the test directory.".format(user_tests_str)) + return None + + if args["verbose"] is True: + print("Running tests verbosely") + + # Pretty print given args + print("========================================") + print("Command line arguments:") + for key in args.keys(): + print("[{0}]: {1}".format(key, args[key])) + print("========================================") + + return args + +def should_test_run(name, path, hostconfig): + run_test = True + #TODO: read regexs (?) from yaml file that show whether we should run the test + # and run them over the given host-config. + # for example, ENABLE_CUDA being ON, if none are present just run test always + return run_test + +def main(): + args = parse_args() + if not args: + return 1 + + # Iterate through the tests, run them, and report error if encountered. + tests = [] + blt_source_dir = args["blt-source-dir"] + host_config = args["host-config"] + verbose = args["verbose"] + clean = args["clean"] + + failed_tests = [] + tests_dir = os.path.relpath(".") + tests_to_run = os.listdir(tests_dir) + # Run only a subset of tests if specified. + if args["run-test"] is not None: + tests_to_run = args["run-test"].split(",") + + print("Running tests {0}".format(", ".join(tests_to_run))) + + for test_dir in tests_to_run: + path_to_test_dir = os.path.join(tests_dir, test_dir) + if not os.path.isdir(path_to_test_dir): + print(path_to_test_dir) + continue + tests.append(test_dir) + status, err = run_test(path_to_test_dir, blt_source_dir, host_config, verbose, clean) + print(err) + if status: + print("Test {0} failed with error {1}".format(test_dir, err)) + failed_tests.append(test_dir) + + # Print final status + if len(failed_tests) == 0: + print("[Success! All tests passed!]") + else: + print("[ERROR: The following {0} out of {1} tests failed:".format(len(failed_tests), len(tests))) + for name in failed_tests: + print(" {0}".format(name)) + print("]") + return 1 + + return 0 + +if __name__ == "__main__": + sys.exit(main()) From 8c7966e0acee8d0134113057d8d1590cc43ba928 Mon Sep 17 00:00:00 2001 From: Chris White Date: Mon, 18 Mar 2024 11:42:16 -0700 Subject: [PATCH 36/36] unset options to test if they are being inherited --- tests/projects/cuda-arch/downstream/CMakeLists.txt | 7 +++++++ tests/projects/cuda-mpi-cpp/downstream/CMakeLists.txt | 7 +++++++ tests/projects/hip-config-test/downstream/CMakeLists.txt | 7 +++++++ tests/projects/mpi-cpp-fortran/downstream/CMakeLists.txt | 7 +++++++ .../projects/openmp-cpp-fortran/downstream/CMakeLists.txt | 7 +++++++ tests/projects/openmp-mpi-cpp/downstream/CMakeLists.txt | 7 +++++++ 6 files changed, 42 insertions(+) diff --git a/tests/projects/cuda-arch/downstream/CMakeLists.txt b/tests/projects/cuda-arch/downstream/CMakeLists.txt index 677385d8d..f86ca95dd 100644 --- a/tests/projects/cuda-arch/downstream/CMakeLists.txt +++ b/tests/projects/cuda-arch/downstream/CMakeLists.txt @@ -1,3 +1,10 @@ +# Clear variables set in the host-config so we can test that they are inherited +# from the upstream project +foreach(_option MPI CUDA HIP OPENMP) + unset(ENABLE_${_option} CACHE) + unset(ENABLE_${_option}) +endforeach() + cmake_minimum_required(VERSION 3.14) project(cuda-clang-cpp-user LANGUAGES CXX) diff --git a/tests/projects/cuda-mpi-cpp/downstream/CMakeLists.txt b/tests/projects/cuda-mpi-cpp/downstream/CMakeLists.txt index b3e32def0..6ee2addaa 100644 --- a/tests/projects/cuda-mpi-cpp/downstream/CMakeLists.txt +++ b/tests/projects/cuda-mpi-cpp/downstream/CMakeLists.txt @@ -1,3 +1,10 @@ +# Clear variables set in the host-config so we can test that they are inherited +# from the upstream project +foreach(_option MPI CUDA HIP OPENMP) + unset(ENABLE_${_option} CACHE) + unset(ENABLE_${_option}) +endforeach() + cmake_minimum_required(VERSION 3.14) project(cuda-mpi-cpp-user LANGUAGES CXX) diff --git a/tests/projects/hip-config-test/downstream/CMakeLists.txt b/tests/projects/hip-config-test/downstream/CMakeLists.txt index 4804f5ea8..37554e560 100644 --- a/tests/projects/hip-config-test/downstream/CMakeLists.txt +++ b/tests/projects/hip-config-test/downstream/CMakeLists.txt @@ -1,3 +1,10 @@ +# Clear variables set in the host-config so we can test that they are inherited +# from the upstream project +foreach(_option MPI CUDA HIP OPENMP) + unset(ENABLE_${_option} CACHE) + unset(ENABLE_${_option}) +endforeach() + cmake_minimum_required(VERSION 3.14) project(hip-config-test-user LANGUAGES CXX C) diff --git a/tests/projects/mpi-cpp-fortran/downstream/CMakeLists.txt b/tests/projects/mpi-cpp-fortran/downstream/CMakeLists.txt index fb511713d..8cae44a95 100644 --- a/tests/projects/mpi-cpp-fortran/downstream/CMakeLists.txt +++ b/tests/projects/mpi-cpp-fortran/downstream/CMakeLists.txt @@ -1,3 +1,10 @@ +# Clear variables set in the host-config so we can test that they are inherited +# from the upstream project +foreach(_option MPI CUDA HIP OPENMP) + unset(ENABLE_${_option} CACHE) + unset(ENABLE_${_option}) +endforeach() + cmake_minimum_required(VERSION 3.14) project(mpi-cpp-fortran-user LANGUAGES CXX Fortran) diff --git a/tests/projects/openmp-cpp-fortran/downstream/CMakeLists.txt b/tests/projects/openmp-cpp-fortran/downstream/CMakeLists.txt index 218c73ba6..33faba0e7 100644 --- a/tests/projects/openmp-cpp-fortran/downstream/CMakeLists.txt +++ b/tests/projects/openmp-cpp-fortran/downstream/CMakeLists.txt @@ -1,3 +1,10 @@ +# Clear variables set in the host-config so we can test that they are inherited +# from the upstream project +foreach(_option MPI CUDA HIP OPENMP) + unset(ENABLE_${_option} CACHE) + unset(ENABLE_${_option}) +endforeach() + cmake_minimum_required(VERSION 3.14) project(openmp-cpp-fortran-user LANGUAGES CXX Fortran) diff --git a/tests/projects/openmp-mpi-cpp/downstream/CMakeLists.txt b/tests/projects/openmp-mpi-cpp/downstream/CMakeLists.txt index f7a77b2a2..6dc205598 100644 --- a/tests/projects/openmp-mpi-cpp/downstream/CMakeLists.txt +++ b/tests/projects/openmp-mpi-cpp/downstream/CMakeLists.txt @@ -1,3 +1,10 @@ +# Clear variables set in the host-config so we can test that they are inherited +# from the upstream project +foreach(_option MPI CUDA HIP OPENMP) + unset(ENABLE_${_option} CACHE) + unset(ENABLE_${_option}) +endforeach() + cmake_minimum_required(VERSION 3.14) project(openmp-mpi-cpp-user LANGUAGES CXX)