From 42f22abe833f56bd0b94cf25262d1c9ae5d5c159 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Fri, 27 Aug 2021 08:09:51 -0400 Subject: [PATCH 1/4] commit FC-based FindOrFetchUmpire.cmake, but not used due to BLT not being subproject-friendly also: external/scalapack.cmake -> cmake/modules/FindOrFetchScaLAPACK.cmake --- CMakeLists.txt | 5 ++- .../modules/FindOrFetchScaLAPACK.cmake | 0 cmake/modules/FindOrFetchUmpire.cmake | 36 +++++++++++++++++++ examples/scalapack/CMakeLists.txt | 3 +- src/CMakeLists.txt | 4 +-- 5 files changed, 42 insertions(+), 6 deletions(-) rename external/scalapack.cmake => cmake/modules/FindOrFetchScaLAPACK.cmake (100%) create mode 100644 cmake/modules/FindOrFetchUmpire.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a83f8b4541..ef69c27965 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,6 +308,9 @@ endif() include(FindOrFetchMADWorld) detect_MADNESS_configuration() include(external/eigen.cmake) +# the FetchContent-based version will not work due to BLT target name conflicts +# include(FindOrFetchUmpire) +# use the ExternalProject-based version include(external/umpire.cmake) ###### discover linear algebra @@ -344,7 +347,7 @@ endif(ENABLE_WFN91_LINALG_DISCOVERY_KIT) include(FindOrFetchBTAS) include(FindOrFetchBoost) if(ENABLE_SCALAPACK) - include(external/scalapack.cmake) + include(FindOrFetchScaLAPACK) endif() if (TA_ENABLE_RANGEV3) include(FindOrFetchRangeV3) diff --git a/external/scalapack.cmake b/cmake/modules/FindOrFetchScaLAPACK.cmake similarity index 100% rename from external/scalapack.cmake rename to cmake/modules/FindOrFetchScaLAPACK.cmake diff --git a/cmake/modules/FindOrFetchUmpire.cmake b/cmake/modules/FindOrFetchUmpire.cmake new file mode 100644 index 0000000000..ac5896103d --- /dev/null +++ b/cmake/modules/FindOrFetchUmpire.cmake @@ -0,0 +1,36 @@ +# try find_package +if (NOT TARGET umpire) + include (FindPackageRegimport) + find_package_regimport(umpire QUIET CONFIG) + if (TARGET umpire) + message(STATUS "Found umpire CONFIG at ${umpire_CONFIG}") + endif (TARGET umpire) +endif (NOT TARGET umpire) + +# if not found, build via FetchContent +if (NOT TARGET umpire) + + include(FetchContent) + FetchContent_Declare( + umpire + GIT_REPOSITORY https://github.com/LLNL/Umpire.git + GIT_TAG ${TA_TRACKED_UMPIRE_TAG} + ) + FetchContent_MakeAvailable(umpire) + FetchContent_GetProperties(umpire + SOURCE_DIR UMPIRE_SOURCE_DIR + BINARY_DIR UMPIRE_BINARY_DIR + ) + + # set BTAS_CONFIG to the install location so that we know where to find it + set(umpire_CONFIG ${CMAKE_INSTALL_PREFIX}/${UMPIRE_CMAKE_DIR}/umpire-config.cmake) + + # install umpire + install(TARGETS umpire umpire_alloc EXPORT tiledarray COMPONENT tiledarray ) + +endif(NOT TARGET umpire) + +# postcond check +if (NOT TARGET umpire) + message(FATAL_ERROR "FindOrFetchUmpire could not make umpire target available") +endif(NOT TARGET umpire) diff --git a/examples/scalapack/CMakeLists.txt b/examples/scalapack/CMakeLists.txt index 8a66f32ea9..e26591734a 100644 --- a/examples/scalapack/CMakeLists.txt +++ b/examples/scalapack/CMakeLists.txt @@ -30,8 +30,7 @@ foreach(_exec conversion evp) # Add executable add_executable(scalapack-${_exec} EXCLUDE_FROM_ALL ${_exec}.cpp) - target_link_libraries(scalapack-${_exec} PRIVATE tiledarray ${MADNESS_DISABLEPIE_LINKER_FLAG}) - add_dependencies(scalapack-${_exec} External-tiledarray) + target_link_libraries(scalapack-${_exec} PRIVATE tiledarray) add_dependencies(examples-tiledarray scalapack-${_exec}) endforeach() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f54a0348a..f1f2b31795 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -220,6 +220,7 @@ TiledArray/math/linalg/rank-local.cpp ) # the list of libraries on which TiledArray depends on, will be cached later +# when FetchContent umpire: set(_TILEDARRAY_DEPENDENCIES MADworld TiledArray_Eigen BTAS::BTAS blaspp_headers umpire) set(_TILEDARRAY_DEPENDENCIES MADworld TiledArray_Eigen BTAS::BTAS blaspp_headers TiledArray_UMPIRE) # TODO better ways to handle tiledarray cuda dependency @@ -264,9 +265,6 @@ add_library(tiledarray ${TILEDARRAY_SOURCE_FILES} ${TILEDARRAY_HEADER_FILES}) target_link_libraries(${targetname} PUBLIC MADworld) target_link_libraries(${targetname} PUBLIC Boost::boost) - # build all external deps before building tiledarray - add_dependencies(${targetname} External-tiledarray) - # append current CMAKE_CXX_FLAGS string(REPLACE " " ";" CMAKE_CXX_FLAG_LIST "${CMAKE_CXX_FLAGS}") target_compile_options(${targetname} PUBLIC ${CMAKE_CXX_FLAG_LIST}) From b9a08dd189972c3a3c673d9b27ec511ad03818f5 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Fri, 27 Aug 2021 08:18:31 -0400 Subject: [PATCH 2/4] Removed unused DownloadProject module (precursor to FetchContent) --- .../DownloadProject.CMakeLists.cmake.in | 37 ---- cmake/modules/DownloadProject.cmake | 202 ------------------ src/CMakeLists.txt | 3 + 3 files changed, 3 insertions(+), 239 deletions(-) delete mode 100644 cmake/modules/DownloadProject.CMakeLists.cmake.in delete mode 100644 cmake/modules/DownloadProject.cmake diff --git a/cmake/modules/DownloadProject.CMakeLists.cmake.in b/cmake/modules/DownloadProject.CMakeLists.cmake.in deleted file mode 100644 index c5107228a3..0000000000 --- a/cmake/modules/DownloadProject.CMakeLists.cmake.in +++ /dev/null @@ -1,37 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2015 Crascit -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -cmake_minimum_required(VERSION 2.8.2) - -project(${DL_ARGS_PROJ}-download NONE) - -include(ExternalProject) -ExternalProject_Add(${DL_ARGS_PROJ}-download - ${DL_ARGS_UNPARSED_ARGUMENTS} - SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" - BINARY_DIR "${DL_ARGS_BINARY_DIR}" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) - diff --git a/cmake/modules/DownloadProject.cmake b/cmake/modules/DownloadProject.cmake deleted file mode 100644 index d5ebe0ee3b..0000000000 --- a/cmake/modules/DownloadProject.cmake +++ /dev/null @@ -1,202 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2015 Crascit -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# MODULE: DownloadProject -# -# PROVIDES: -# download_project( PROJ projectName -# [PREFIX prefixDir] -# [DOWNLOAD_DIR downloadDir] -# [SOURCE_DIR srcDir] -# [BINARY_DIR binDir] -# [QUIET] -# ... -# ) -# -# Provides the ability to download and unpack a tarball, zip file, git repository, -# etc. at configure time (i.e. when the cmake command is run). How the downloaded -# and unpacked contents are used is up to the caller, but the motivating case is -# to download source code which can then be included directly in the build with -# add_subdirectory() after the call to download_project(). Source and build -# directories are set up with this in mind. -# -# The PROJ argument is required. The projectName value will be used to construct -# the following variables upon exit (obviously replace projectName with its actual -# value): -# -# projectName_SOURCE_DIR -# projectName_BINARY_DIR -# -# The SOURCE_DIR and BINARY_DIR arguments are optional and would not typically -# need to be provided. They can be specified if you want the downloaded source -# and build directories to be located in a specific place. The contents of -# projectName_SOURCE_DIR and projectName_BINARY_DIR will be populated with the -# locations used whether you provide SOURCE_DIR/BINARY_DIR or not. -# -# The DOWNLOAD_DIR argument does not normally need to be set. It controls the -# location of the temporary CMake build used to perform the download. -# -# The PREFIX argument can be provided to change the base location of the default -# values of DOWNLOAD_DIR, SOURCE_DIR and BINARY_DIR. If all of those three arguments -# are provided, then PREFIX will have no effect. The default value for PREFIX is -# CMAKE_BINARY_DIR. -# -# The QUIET option can be given if you do not want to show the output associated -# with downloading the specified project. -# -# In addition to the above, any other options are passed through unmodified to -# ExternalProject_Add() to perform the actual download, patch and update steps. -# The following ExternalProject_Add() options are explicitly prohibited (they -# are reserved for use by the download_project() command): -# -# CONFIGURE_COMMAND -# BUILD_COMMAND -# INSTALL_COMMAND -# TEST_COMMAND -# -# Only those ExternalProject_Add() arguments which relate to downloading, patching -# and updating of the project sources are intended to be used. Also note that at -# least one set of download-related arguments are required. -# -# If using CMake 3.2 or later, the UPDATE_DISCONNECTED option can be used to -# prevent a check at the remote end for changes every time CMake is run -# after the first successful download. See the documentation of the ExternalProject -# module for more information. It is likely you will want to use this option if it -# is available to you. Note, however, that the ExternalProject implementation contains -# bugs which result in incorrect handling of the UPDATE_DISCONNECTED option when -# using the URL download method or when specifying a SOURCE_DIR with no download -# method. Fixes for these have been created, the last of which is scheduled for -# inclusion in CMake 3.8.0. Details can be found here: -# -# https://gitlab.kitware.com/cmake/cmake/commit/bdca68388bd57f8302d3c1d83d691034b7ffa70c -# https://gitlab.kitware.com/cmake/cmake/issues/16428 -# -# If you experience build errors related to the update step, consider avoiding -# the use of UPDATE_DISCONNECTED. -# -# EXAMPLE USAGE: -# -# include(DownloadProject) -# download_project(PROJ googletest -# GIT_REPOSITORY https://github.com/google/googletest.git -# GIT_TAG master -# UPDATE_DISCONNECTED 1 -# QUIET -# ) -# -# add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) -# -#======================================================================================== - - -set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}") - -include(CMakeParseArguments) - -function(download_project) - - set(options QUIET) - set(oneValueArgs - PROJ - PREFIX - DOWNLOAD_DIR - SOURCE_DIR - BINARY_DIR - # Prevent the following from being passed through - CONFIGURE_COMMAND - BUILD_COMMAND - INSTALL_COMMAND - TEST_COMMAND - ) - set(multiValueArgs "") - - cmake_parse_arguments(DL_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # Hide output if requested - if (DL_ARGS_QUIET) - set(OUTPUT_QUIET "OUTPUT_QUIET") - else() - unset(OUTPUT_QUIET) - message(STATUS "Downloading/updating ${DL_ARGS_PROJ}") - endif() - - # Set up where we will put our temporary CMakeLists.txt file and also - # the base point below which the default source and binary dirs will be. - # The prefix must always be an absolute path. - if (NOT DL_ARGS_PREFIX) - set(DL_ARGS_PREFIX "${CMAKE_BINARY_DIR}") - else() - get_filename_component(DL_ARGS_PREFIX "${DL_ARGS_PREFIX}" ABSOLUTE - BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") - endif() - if (NOT DL_ARGS_DOWNLOAD_DIR) - set(DL_ARGS_DOWNLOAD_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-download") - endif() - - # Ensure the caller can know where to find the source and build directories - if (NOT DL_ARGS_SOURCE_DIR) - set(DL_ARGS_SOURCE_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-src") - endif() - if (NOT DL_ARGS_BINARY_DIR) - set(DL_ARGS_BINARY_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-build") - endif() - set(${DL_ARGS_PROJ}_SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" PARENT_SCOPE) - set(${DL_ARGS_PROJ}_BINARY_DIR "${DL_ARGS_BINARY_DIR}" PARENT_SCOPE) - - # The way that CLion manages multiple configurations, it causes a copy of - # the CMakeCache.txt to be copied across due to it not expecting there to - # be a project within a project. This causes the hard-coded paths in the - # cache to be copied and builds to fail. To mitigate this, we simply - # remove the cache if it exists before we configure the new project. It - # is safe to do so because it will be re-generated. Since this is only - # executed at the configure step, it should not cause additional builds or - # downloads. - file(REMOVE "${DL_ARGS_DOWNLOAD_DIR}/CMakeCache.txt") - - # Create and build a separate CMake project to carry out the download. - # If we've already previously done these steps, they will not cause - # anything to be updated, so extra rebuilds of the project won't occur. - # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project - # has this set to something not findable on the PATH. - configure_file("${_DownloadProjectDir}/DownloadProject.CMakeLists.cmake.in" - "${DL_ARGS_DOWNLOAD_DIR}/CMakeLists.txt") - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" - -D "CMAKE_MAKE_PROGRAM:FILE=${CMAKE_MAKE_PROGRAM}" - . - RESULT_VARIABLE result - ${OUTPUT_QUIET} - WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" - ) - if(result) - message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - ${OUTPUT_QUIET} - WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" - ) - if(result) - message(FATAL_ERROR "Build step for ${DL_ARGS_PROJ} failed: ${result}") - endif() - -endfunction() - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f1f2b31795..294959ecb2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -265,6 +265,9 @@ add_library(tiledarray ${TILEDARRAY_SOURCE_FILES} ${TILEDARRAY_HEADER_FILES}) target_link_libraries(${targetname} PUBLIC MADworld) target_link_libraries(${targetname} PUBLIC Boost::boost) + # build all external deps before building tiledarray + add_dependencies(${targetname} External-tiledarray) + # append current CMAKE_CXX_FLAGS string(REPLACE " " ";" CMAKE_CXX_FLAG_LIST "${CMAKE_CXX_FLAGS}") target_compile_options(${targetname} PUBLIC ${CMAKE_CXX_FLAG_LIST}) From 5f3a4376eee82c8e4e13da49751198340d83b223 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Tue, 31 Aug 2021 08:28:37 -0400 Subject: [PATCH 3/4] Typo --- cmake/modules/FindOrFetchBoost.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/FindOrFetchBoost.cmake b/cmake/modules/FindOrFetchBoost.cmake index 4cfd9ea111..4088d40c2c 100644 --- a/cmake/modules/FindOrFetchBoost.cmake +++ b/cmake/modules/FindOrFetchBoost.cmake @@ -29,7 +29,7 @@ if (NOT TARGET Boost::boost) # current boost-cmake/master does not install boost correctly, so warn that installed TiledArray will not be usable # boost-cmake/install_rules https://github.com/Orphis/boost-cmake/pull/45 is supposed to fix it but is inactive - message(WARNING "Building Boost from source makes TiledArray unusable from the install location! Install TA using package manager or manually and reconfigure/reinstall TiledArray to fix this") + message(WARNING "Building Boost from source makes TiledArray unusable from the install location! Install Boost using package manager or manually and reconfigure/reinstall TiledArray to fix this") export(EXPORT tiledarray FILE "${PROJECT_BINARY_DIR}/boost-targets.cmake") install(EXPORT tiledarray From 5a9fdada3759a8965a58c34a0d8e11e252065482 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Tue, 31 Aug 2021 08:29:07 -0400 Subject: [PATCH 4/4] [cmake] set MADNESS_CONFIG if building from source --- cmake/modules/FindOrFetchMADWorld.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/modules/FindOrFetchMADWorld.cmake b/cmake/modules/FindOrFetchMADWorld.cmake index b129bb8248..11ac45cec1 100644 --- a/cmake/modules/FindOrFetchMADWorld.cmake +++ b/cmake/modules/FindOrFetchMADWorld.cmake @@ -51,6 +51,9 @@ if (NOT TARGET MADworld) # force 'all' target to build madness and MADworld using this dummy target add_custom_target(tiledarray-force-all-to-build-madness-target ALL DEPENDS madness MADworld) + # set MADNESS_CONFIG to the install location so that we know where to find it + set(MADNESS_CONFIG ${CMAKE_INSTALL_PREFIX}/${MADNESS_INSTALL_CMAKEDIR}/madness-config.cmake) + endif(NOT TARGET MADworld) # postcond check