diff --git a/CMakeLists.txt b/CMakeLists.txt index 37fc48df..d8da2cae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,131 +10,260 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with crest. If not, see . + +cmake_minimum_required(VERSION 3.17) +option(WITH_OBJECT "To build using object library" TRUE) +option(INSTALL_MODULES "Install Fortran module files to include directory." FALSE) -cmake_minimum_required(VERSION 3.14) +# Buggy CMake versions +if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.27.0 AND CMAKE_VERSION VERSION_LESS 3.28.0) + set(WITH_OBJECT FALSE) +endif() +# Setup the crest Project project( - "crest" - LANGUAGES "Fortran" "C" - VERSION "3.0" + crest + LANGUAGES "C" "Fortran" + VERSION 3.0 + DESCRIPTION "A tool for the exploration of low-energy chemical space" ) set(SOVERSION "pre") +#enable_testing() + # Follow GNU conventions for installing directories include(GNUInstallDirs) -# General configuration information -set(libs) +# Include further configurations add_subdirectory("config") -# -# Libraries -# +############################################################################### +####################### SUBPROJECTS & DEPENDENCIES ############################ +############################################################################### +# Check a specific CMake targets and execute the +# corresponding Find scripts (located in config/modules/) -# OpenMP dependency -if(NOT TARGET OpenMP::OpenMP_Fortran AND WITH_OpenMP) - find_package(OpenMP REQUIRED) - list( - APPEND libs - OpenMP::OpenMP_Fortran - ) +# LAPACK, BLAS, OpenMP (usually via shared dependencies) +if(STATICBUILD) + set(BLA_STATIC ON) endif() - -# BLAS and LAPACK -if(NOT TARGET BLAS::BLAS) - find_package(BLAS REQUIRED) - if(NOT TARGET BLAS::BLAS AND BLAS_FOUND) - add_library(BLAS::BLAS INTERFACE IMPORTED) - target_link_libraries(BLAS::BLAS INTERFACE "${BLAS_LIBRARIES}") - target_link_options(BLAS::BLAS INTERFACE "${BLAS_LINKER_FLAGS}") - endif() +find_package(LAPACK REQUIRED) +find_package(BLAS REQUIRED) +if(NOT TARGET "OpenMP::OpenMP_Fortran" AND WITH_OpenMP) + find_package("OpenMP" REQUIRED) endif() -if(NOT TARGET LAPACK::LAPACK) - find_package(LAPACK REQUIRED) - if(NOT TARGET LAPACK::LAPACK AND LAPACK_FOUND) - add_library(LAPACK::LAPACK INTERFACE IMPORTED) - target_link_libraries(LAPACK::LAPACK INTERFACE "${LAPACK_LIBRARIES}") - target_link_options(LAPACK::LAPACK INTERFACE "${LAPACK_LINKER_FLAGS}") - endif() + +# TOML-F (needs to be imported before tblite) +if(NOT TARGET "toml-f::toml-f" AND WITH_TOMLF) + find_package("toml-f" REQUIRED) + add_compile_definitions(WITH_TOMLF) endif() -list( - APPEND libs - LAPACK::LAPACK - BLAS::BLAS -) # tblite -if(WITH_TBLITE) - find_package("tblite" REQUIRED) - add_definitions(-DWITH_TBLITE) - list( - APPEND libs - tblite::tblite - ) +if(NOT TARGET "tblite::tblite" AND WITH_TBLITE) + find_package("tblite" REQUIRED) + add_compile_definitions(WITH_TBLITE) endif() +# GFN-FF +if(NOT TARGET "gfnff::gfnff" AND WITH_GFNFF) + find_package("gfnff" REQUIRED) + add_compile_definitions(WITH_GFNFF) +endif() -# toml-f -if(WITH_TOMLF) - find_package("toml-f" REQUIRED) - add_definitions(-DWITH_TOMLF) - list( - APPEND libs - toml-f::toml-f - ) +# GFN0-xTB +if(NOT TARGET "gfn0::gfn0" AND WITH_GFN0) + find_package("gfn0" REQUIRED) + add_compile_definitions(WITH_GFN0) endif() +# XHCFF +if(NOT TARGET "xhcff::xhcff" AND WITH_XHCFF) + find_package("xhcff" REQUIRED) + add_compile_definitions(WITH_XHCFF) +endif() -# GFN0-xTB -if(WITH_GFN0) - find_package("gfn0" REQUIRED) - add_definitions(-DWITH_GFN0) - list( - APPEND libs - gfn0::gfn0 - ) +# lwONIOM +if(NOT TARGET "lwoniom::lwoniom" AND WITH_LWONIOM) + find_package("lwoniom" REQUIRED) + add_compile_definitions(WITH_LWONIOM) endif() +# Sources: initialize program sources (prog) and library sources (srcs) empty +set(prog) +set(srcs) +add_subdirectory("src") -# GFN-FF -if(WITH_GFNFF) - find_package("gfnff" REQUIRED) - add_definitions(-DWITH_GFNFF) - list( - APPEND libs - gfnff::gfnff - ) + +if(NOT EXISTS "${PROJECT_BINARY_DIR}/include") + file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/include") endif() -# XHCFF -if(WITH_XHCFF) - find_package("xhcff" REQUIRED) - add_definitions(-DWITH_XHCFF) - list( - APPEND libs - xhcff::xhcff - ) +############################################################################### +########################## OBJECT LIBRARY ##################################### +############################################################################### +if(WITH_OBJECT AND NOT STATICBUILD) + + add_library( + "${PROJECT_NAME}-object" + OBJECT + ${srcs} + ) + + # customize object library + set_target_properties( + "${PROJECT_NAME}-object" + PROPERTIES + Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include" + POSITION_INDEPENDENT_CODE ON + ) + + # link object library conditionally against required + target_link_libraries( + "${PROJECT_NAME}-object" + PUBLIC + $<$:tblite::tblite> + $<$:gfn0::gfn0> + $<$:gfnff::gfnff> + $<$:xhcff::xhcff> + $<$:toml-f::toml-f> + $<$:lwoniom::lwoniom> + $<$:OpenMP::OpenMP_Fortran> + ) + + # include directories + target_include_directories( + "${PROJECT_NAME}-object" + PUBLIC + ${crest-config-dir} + ${PROJECT_BINARY_DIR} + $ + $ + $/${CMAKE_INSTALL_INCLUDEDIR}> + ) + endif() +############################################################################### +############################### Static Library ################################ +############################################################################### +if(WITH_OBJECT AND NOT STATICBUILD) + add_library( + "lib-${PROJECT_NAME}-static" + STATIC + $ + ) +else() + add_library( + "lib-${PROJECT_NAME}-static" + STATIC + ${srcs} + ) +endif() +# workaround attemp. doesn't work yet +set(LINK_OpenMP FALSE) +if(WITH_OpenMP AND NOT STATICBUILD) + set(LINK_OpenMP TRUE) +endif() +target_link_libraries( + "lib-${PROJECT_NAME}-static" + PUBLIC + ${BLAS_LIBRARIES} + ${LAPACK_LIBRARIES} + $<$:OpenMP::OpenMP_Fortran> + $<$:tblite::tblite> + $<$:gfn0::gfn0> + $<$:gfnff::gfnff> + $<$:xhcff::xhcff> + $<$:toml-f::toml-f> + $<$:lwoniom::lwoniom> + $<$:-static> +) -# -# CREST sources -# -set(prog) -set(srcs) -add_subdirectory("src") +set_target_properties( + "lib-${PROJECT_NAME}-static" + PROPERTIES + Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include" + ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + POSITION_INDEPENDENT_CODE ON + OUTPUT_NAME "${PROJECT_NAME}" + ) -# -# Executables -# + +target_include_directories( + "lib-${PROJECT_NAME}-static" + PUBLIC + $ + $ + $/${CMAKE_INSTALL_INCLUDEDIR}> +) + + +#################################################################################### +############################# Shared Library ####################################### +#################################################################################### +if (WITH_OBJECT AND NOT STATICBUILD) + add_library( + "lib-${PROJECT_NAME}-shared" + SHARED + $ + ) + + target_link_libraries( + "lib-${PROJECT_NAME}-shared" + PUBLIC + ${BLAS_LIBRARIES} + ${LAPACK_LIBRARIES} + $<$:OpenMP::OpenMP_Fortran> + $<$:tblite::tblite> + $<$:gfn0::gfn0> + $<$:gfnff::gfnff> + $<$:xhcff::xhcff> + $<$:toml-f::toml-f> + $<$:lwoniom::lwoniom> + ) + + set_target_properties( + "lib-${PROJECT_NAME}-shared" + PROPERTIES + Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include" + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + OUTPUT_NAME "${PROJECT_NAME}" + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION_MAJOR}" + ) + + target_include_directories( + "lib-${PROJECT_NAME}-shared" + PUBLIC + $ + $ + $/${CMAKE_INSTALL_INCLUDEDIR}> + ) +endif() + +############################################################################### +############################### Executables ################################### +############################################################################### add_executable( ${PROJECT_NAME}-exe - "${srcs}" "${prog}" + ${prog} ) + +target_link_libraries( + ${PROJECT_NAME}-exe + PRIVATE + "lib-${PROJECT_NAME}-static" + $<$:-static> +) + set_target_properties( ${PROJECT_NAME}-exe PROPERTIES @@ -142,24 +271,11 @@ set_target_properties( RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} OUTPUT_NAME "${PROJECT_NAME}" ) -target_link_libraries( - ${PROJECT_NAME}-exe - PRIVATE - "${libs}" -) - -get_target_property(OUT ${PROJECT_NAME}-exe LINK_LIBRARIES) -message(STATUS ${OUT}) -# -# Binary installing option -# -install( - TARGETS - "${PROJECT_NAME}-exe" - EXPORT - "${PROJECT_NAME}-targets" - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +target_include_directories( + ${PROJECT_NAME}-exe + PRIVATE + ${PROJECT_SOURCE_DIR}/include + $ ) + diff --git a/README.md b/README.md index 10e009f7..f078223d 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,26 @@ For more information about builds including subprojects see [here](./subprojects Some basic build instructions can be found in the following dropdown tabs: + +
+

CMake build

+ + +Building CREST with CMake works with the following chain of commands (in this example with `gfortran/gcc` compilers): +```bash +export FC=gfortran CC=gcc +cmake -B _build -DCMAKE_BUILD_TYPE=Release +``` +and then to build the CREST binary +```bash +make -C _build +``` + +The `CMake` build typically requires access to shared libraries of LAPACK and OpenMP. They must be present in the library paths at compile and runtime. +
+ +

meson build

@@ -97,25 +116,6 @@ When attempting to build with `gfortran` and `gcc`, add `-Dla_backend=mkl` to th By default the `meson` build will create a **statically** linked binary.
-
-

CMake build

- - -For the setup of CMake see also the [CMake setup](https://github.com/grimme-lab/xtb/blob/master/cmake/README.adoc) page hosted at the `xtb` repository. -Building CREST with CMake works with the following chain of commands: -```bash -export FC=gfortran CC=gcc -cmake -B _build -DCMAKE_BUILD_TYPE=Release -``` -and then to build the CREST binary -```bash -make -C _build -``` - -The CMake build of CREST is focused on and tested with the GNU `gfortran`/`gcc` compilers. The Intel compilers could technically be used as well, but in our experience the respective build is more fragile than its static `meson` counterpart. - -By default the `CMake` build will create a **dynamically** linked binary. -

Conda build

diff --git a/assets/template/metadata.f90 b/assets/template/metadata.f90 index b2e4da29..38a4e74b 100644 --- a/assets/template/metadata.f90 +++ b/assets/template/metadata.f90 @@ -10,4 +10,4 @@ character(len=*),parameter :: gfnffvar = "@gfnffvar@" character(len=*),parameter :: tblitevar = "@tblitevar@" character(len=*),parameter :: xhcffvar = "@xhcffvar@" - +character(len=*),parameter :: lwoniomvar = "@lwoniomvar@" diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index 06497a99..e6a7e09d 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -13,21 +13,34 @@ # # You should have received a copy of the GNU Lesser General Public License # along with crest. If not, see . +# Set the module path for CMake includes +######################################################################################### +######################################################################################### +# Add modules to the CMake build list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/modules") set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE) + +# specify module installation directory install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/modules/" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" ) -set( - module-dir - "${PROJECT_NAME}/${CMAKE_Fortran_COMPILER_ID}-${CMAKE_Fortran_COMPILER_VERSION}" -) -set(module-dir "${module-dir}" PARENT_SCOPE) +# Options for enabling or disabling features +option(WITH_OpenMP "Enable OpenMP support" TRUE) +option(WITH_TBLITE "Enable support for tblite" TRUE) +option(WITH_TOMLF "Enable support for toml-f" TRUE) +option(WITH_GFN0 "Enable support for GFN0-xTB" TRUE) +option(WITH_GFNFF "Enable support for GFN-FF" TRUE) +option(WITH_XHCFF "Enable support for XHCFF" FALSE) +option(WITH_LWONIOM "Enable support for lwONIOM" TRUE) +option(STATICBUILD "Attempt to link everything statically" FALSE) # doesn't work yet + +######################################################################################### +######################################################################################### # Set build type as CMake does not provide defaults if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) @@ -42,57 +55,28 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) ) endif() +######################################################################################### +######################################################################################### -### Options and defaults - -include("${CMAKE_CURRENT_SOURCE_DIR}/modules/crest-utils.cmake") -set(fortran_minimal_versions "GNU;7.5" "Intel;19.0") -check_minimal_compiler_version("Fortran" "${fortran_minimal_versions}") - -option(WITH_OpenMP "Enable support for shared memory parallelisation with OpenMP" TRUE) - -option(WITH_TBLITE "Enable build with the lightweight tight-binding library" TRUE) - -option(WITH_TOMLF "Enable build with toml-f support" TRUE) - -option(WITH_GFN0 "Enable build with GFN0-xTB support" TRUE) - -option(WITH_GFNFF "Enable build with GFN-FF support" TRUE) - -option(WITH_XHCFF "Enable build with XHCFF support" FALSE) - -option(WITH_LWONIOM "Enable build with lwONIOM support" TRUE) - -if(NOT DEFINED "${PROJECT_NAME}-dependency-method") - set( - "${PROJECT_NAME}-dependency-method" - "subproject" "cmake" "pkgconf" "fetch" - ) -endif() - -# -# Compiler settings -# +# Compiler settings for GNU and Intel Fortran compilers if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") -# set(dialect "-fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fbacktrace") set(dialect "-g -O0 -fbacktrace -ffree-line-length-none -fbacktrace") - set(bounds "-fbounds-check") -endif() -if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") -# set(dialect "-axAVX2 -r8 -traceback") - set(dialect "-g -O2 -r8 -align array64byte -traceback") - set(bounds "-check bounds") -endif() -if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI") - set(dialect "-Mbackslash -Mallocatable=03 -r8 -traceback") + set(bounds "-fbounds-check -ffpe-trap=invalid,zero,overflow") +elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(dialect "-g -O2 -r8 -align array64byte -traceback") + set(bounds "-check all -fpe0") +else() + message(FATAL_ERROR "Please use an Intel or GNU compiler!") endif() + +# Apply the compiler flags set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}" PARENT_SCOPE) set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}" PARENT_SCOPE) +######################################################################################### +######################################################################################### -# # Populate crest_metadata.fh -# set(version ${PROJECT_VERSION}${SOVERSION}) execute_process(COMMAND git show -s --format=%h RESULT_VARIABLE git_return @@ -111,7 +95,7 @@ set(fcver ${CMAKE_Fortran_COMPILER_VERSION}) set(ccid ${CMAKE_C_COMPILER_ID}) set(ccver ${CMAKE_C_COMPILER_VERSION}) set(bsystem "cmake ${CMAKE_VERSION}") -set(tomlfvar "${WITH_TOMLF}")#string(TOLOWER "${MY_BOOL}" ${WITH_TOMLF})) +set(tomlfvar "${WITH_TOMLF}") set(gfn0var "${WITH_GFN0}") set(gfnffvar "${WITH_GFNFF}") set(tblitevar "${WITH_TBLITE}") @@ -123,12 +107,6 @@ configure_file( "${PROJECT_BINARY_DIR}/crest_metadata.fh" @ONLY ) -# gfortran needs the file at another place... -configure_file( - "${PROJECT_SOURCE_DIR}/assets/template/metadata.f90" - "${PROJECT_BINARY_DIR}/include/crest_metadata.fh" - @ONLY -) - - +######################################################################################### +######################################################################################### diff --git a/config/modules/Findgfn0.cmake b/config/modules/Findgfn0.cmake index f5699b7a..a44f8c8d 100644 --- a/config/modules/Findgfn0.cmake +++ b/config/modules/Findgfn0.cmake @@ -19,29 +19,19 @@ set(_pkg "GFN0") set(_url "https://github.com/pprcht/gfn0") if(NOT DEFINED "${_pkg}_FIND_METHOD") - if(DEFINED "${PROJECT_NAME}-dependency-method") - set("${_pkg}_FIND_METHOD" "${${PROJECT_NAME}-dependency-method}") - else() - set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch") - endif() - set("_${_pkg}_FIND_METHOD") + set("${_pkg}_FIND_METHOD" "subproject" "cmake" "fetch" "pkgconf") endif() include("${CMAKE_CURRENT_LIST_DIR}/crest-utils.cmake") crest_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}") +set (found FALSE) if(TARGET "gfn0::gfn0") set (found TRUE) -else() - set (found FALSE) endif() -message("-- Found GFN0: ${found}") +message(STATUS "Found GFN0-xTB: ${found}") -if(DEFINED "_${_pkg}_FIND_METHOD") - unset("${_pkg}_FIND_METHOD") - unset("_${_pkg}_FIND_METHOD") -endif() unset(_lib) unset(_pkg) unset(_url) diff --git a/config/modules/Findgfnff.cmake b/config/modules/Findgfnff.cmake index 9308b613..faf16024 100644 --- a/config/modules/Findgfnff.cmake +++ b/config/modules/Findgfnff.cmake @@ -19,29 +19,19 @@ set(_pkg "GFNFF") set(_url "https://github.com/pprcht/gfnff") if(NOT DEFINED "${_pkg}_FIND_METHOD") - if(DEFINED "${PROJECT_NAME}-dependency-method") - set("${_pkg}_FIND_METHOD" "${${PROJECT_NAME}-dependency-method}") - else() - set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch") - endif() - set("_${_pkg}_FIND_METHOD") + set("${_pkg}_FIND_METHOD" "subproject" "cmake" "fetch" "pkgconf") endif() include("${CMAKE_CURRENT_LIST_DIR}/crest-utils.cmake") crest_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}") +set(found FALSE) if(TARGET "gfnff::gfnff") set (found TRUE) -else() - set (found FALSE) endif() -message("-- Found GFN-FF: ${found}") +message(STATUS "Found GFN-FF: ${found}") -if(DEFINED "_${_pkg}_FIND_METHOD") - unset("${_pkg}_FIND_METHOD") - unset("_${_pkg}_FIND_METHOD") -endif() unset(_lib) unset(_pkg) unset(_url) diff --git a/config/modules/Findlwoniom.cmake b/config/modules/Findlwoniom.cmake index 8c131dbe..1f825b13 100644 --- a/config/modules/Findlwoniom.cmake +++ b/config/modules/Findlwoniom.cmake @@ -16,32 +16,22 @@ set(_lib "lwoniom") set(_pkg "LWONIOM") -set(_url "https://github.com/pprcht/lwoniom") +set(_url "https://github.com/crest-lab/lwoniom") if(NOT DEFINED "${_pkg}_FIND_METHOD") - if(DEFINED "${PROJECT_NAME}-dependency-method") - set("${_pkg}_FIND_METHOD" "${${PROJECT_NAME}-dependency-method}") - else() - set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch") - endif() - set("_${_pkg}_FIND_METHOD") + set("${_pkg}_FIND_METHOD" "subproject" "cmake" "fetch" "pkgconf") endif() include("${CMAKE_CURRENT_LIST_DIR}/crest-utils.cmake") crest_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}") +set(found FALSE) if(TARGET "lwoniom::lwoniom") set (found TRUE) -else() - set (found FALSE) endif() -message("-- Found lwONIOM: ${found}") +message(STATUS "Found lwONIOM: ${found}") -if(DEFINED "_${_pkg}_FIND_METHOD") - unset("${_pkg}_FIND_METHOD") - unset("_${_pkg}_FIND_METHOD") -endif() unset(_lib) unset(_pkg) unset(_url) diff --git a/config/modules/Findtblite.cmake b/config/modules/Findtblite.cmake index 51464b5d..9ca3cfc3 100644 --- a/config/modules/Findtblite.cmake +++ b/config/modules/Findtblite.cmake @@ -19,29 +19,19 @@ set(_pkg "TBLITE") set(_url "https://github.com/tblite/tblite") if(NOT DEFINED "${_pkg}_FIND_METHOD") - if(DEFINED "${PROJECT_NAME}-dependency-method") - set("${_pkg}_FIND_METHOD" "${${PROJECT_NAME}-dependency-method}") - else() - set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch") - endif() - set("_${_pkg}_FIND_METHOD") + set("${_pkg}_FIND_METHOD" "subproject" "cmake" "fetch" "pkgconf") endif() include("${CMAKE_CURRENT_LIST_DIR}/crest-utils.cmake") crest_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}") +set(found FALSE) if(TARGET "tblite::tblite") set (found TRUE) -else() - set (found FALSE) endif() -message("-- Found tblite: ${found}") +message(STATUS "Found tblite: ${found}") -if(DEFINED "_${_pkg}_FIND_METHOD") - unset("${_pkg}_FIND_METHOD") - unset("_${_pkg}_FIND_METHOD") -endif() unset(_lib) unset(_pkg) unset(_url) diff --git a/config/modules/Findtoml-f.cmake b/config/modules/Findtoml-f.cmake index 81eeb159..ca1da4cb 100644 --- a/config/modules/Findtoml-f.cmake +++ b/config/modules/Findtoml-f.cmake @@ -19,12 +19,7 @@ set(_pkg "TOML-F") set(_url "https://github.com/toml-f/toml-f") if(NOT DEFINED "${_pkg}_FIND_METHOD") - if(DEFINED "${PROJECT_NAME}-dependency-method") - set("${_pkg}_FIND_METHOD" "${${PROJECT_NAME}-dependency-method}") - else() - set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch") - endif() - set("_${_pkg}_FIND_METHOD") + set("${_pkg}_FIND_METHOD" "subproject" "cmake" "fetch" "pkgconf") endif() include("${CMAKE_CURRENT_LIST_DIR}/crest-utils.cmake") @@ -36,12 +31,8 @@ if(TARGET "toml-f::toml-f") else() set (found FALSE) endif() -message("-- Found toml-f: ${found}") +message(STATUS "Found toml-f: ${found}") -if(DEFINED "_${_pkg}_FIND_METHOD") - unset("${_pkg}_FIND_METHOD") - unset("_${_pkg}_FIND_METHOD") -endif() unset(_lib) unset(_pkg) unset(_url) diff --git a/config/modules/Findxhcff.cmake b/config/modules/Findxhcff.cmake index bcfaae4e..fff680e1 100644 --- a/config/modules/Findxhcff.cmake +++ b/config/modules/Findxhcff.cmake @@ -19,29 +19,19 @@ set(_pkg "XHCFF") set(_url "https://github.com/zellerf/xhcff-lib") if(NOT DEFINED "${_pkg}_FIND_METHOD") - if(DEFINED "${PROJECT_NAME}-dependency-method") - set("${_pkg}_FIND_METHOD" "${${PROJECT_NAME}-dependency-method}") - else() - set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch") - endif() - set("_${_pkg}_FIND_METHOD") + set("${_pkg}_FIND_METHOD" "subproject" "cmake" "fetch" "pkgconf" ) endif() include("${CMAKE_CURRENT_LIST_DIR}/crest-utils.cmake") crest_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}") +set(found FALSE) if(TARGET "xhcff::xhcff") set (found TRUE) -else() - set (found FALSE) endif() -message("-- Found xhcff: ${found}") +message(STATUS "Found xhcff: ${found}") -if(DEFINED "_${_pkg}_FIND_METHOD") - unset("${_pkg}_FIND_METHOD") - unset("_${_pkg}_FIND_METHOD") -endif() unset(_lib) unset(_pkg) unset(_url) diff --git a/config/modules/crest-utils.cmake b/config/modules/crest-utils.cmake index dfc38046..375714a2 100644 --- a/config/modules/crest-utils.cmake +++ b/config/modules/crest-utils.cmake @@ -14,6 +14,9 @@ # You should have received a copy of the GNU Lesser General Public License # along with crest. If not, see . +######################################################################################### +######################################################################################### + # Handling of subproject dependencies macro( "crest_find_package" @@ -24,12 +27,17 @@ macro( string(TOLOWER "${package}" _pkg_lc) string(TOUPPER "${package}" _pkg_uc) + + # iterate through lookup types in order foreach(method ${methods}) if(TARGET "${package}::${package}") break() endif() +######################################################################################### + + # look for a -config.cmake on the system if("${method}" STREQUAL "cmake") if(DEFINED "${_pkg_uc}_DIR") set("_${_pkg_uc}_DIR") @@ -42,6 +50,9 @@ macro( endif() endif() +######################################################################################### + + # look for dependency via pkgconf if("${method}" STREQUAL "pkgconf") find_package(PkgConfig QUIET) pkg_check_modules("${_pkg_uc}" QUIET "${package}") @@ -63,6 +74,9 @@ macro( endif() endif() +######################################################################################### + + # look for SOURCE in the subprojects directory (we usually prefer this one) if("${method}" STREQUAL "subproject") if(NOT DEFINED "${_pkg_uc}_SUBPROJECT") set("_${_pkg_uc}_SUBPROJECT") @@ -89,6 +103,9 @@ macro( endif() endif() +######################################################################################### + + # finally, we can try to download sources if("${method}" STREQUAL "fetch") message(STATUS "Retrieving ${package} from ${url}") include(FetchContent) @@ -112,6 +129,8 @@ macro( break() endif() +######################################################################################### + endforeach() if(TARGET "${package}::${package}") @@ -138,9 +157,10 @@ macro( endif() endmacro() -# +######################################################################################### +######################################################################################### + # Check current compiler version requirements. -# function (check_minimal_compiler_version lang compiler_versions) while(compiler_versions) list(POP_FRONT compiler_versions compiler version) diff --git a/src/legacy_algos/cregen_old.f90 b/src/legacy_algos/cregen_old.f90 index 28208ff2..053f2ca4 100644 --- a/src/legacy_algos/cregen_old.f90 +++ b/src/legacy_algos/cregen_old.f90 @@ -32,7 +32,7 @@ subroutine cregen2(env) use axis_module use miscdata, only: rcov use utilities - !$ use omp_lib + use omp_lib implicit none type(systemdata) :: env ! MAIN STORAGE OS SYSTEM DATA diff --git a/src/printouts.f90 b/src/printouts.f90 index c48458fb..7d738c20 100644 --- a/src/printouts.f90 +++ b/src/printouts.f90 @@ -719,7 +719,7 @@ subroutine print_crest_metadata() write (*,'(2x,a,1x,a)') '-DWITH_GFNFF :',gfnffvar write (*,'(2x,a,1x,a)') '-DWITH_TBLITE :',tblitevar write (*,'(2x,a,1x,a)') '-DWITH_XHCFF :',xhcffvar - + write (*,'(2x,a,1x,a)') '-DWITH_LWONIOM :',lwoniomvar end subroutine print_crest_metadata !========================================================================================!