From b842ae1c3fd6776956e5d3fe754e1e3b2e446acb Mon Sep 17 00:00:00 2001
From: albert <92109627+Albkat@users.noreply.github.com>
Date: Mon, 18 Sep 2023 16:29:18 +0200
Subject: [PATCH 1/3] CMake version-independent build
Signed-off-by: albert <92109627+Albkat@users.noreply.github.com>
---
.github/workflows/fortran-build.yml | 8 ++---
CMakeLists.txt | 16 +++++++--
cmake/CMakeLists.txt | 52 +++++++++++++++++------------
cmake/modules/Findcpcmx.cmake | 12 +++----
cmake/modules/Findmctc-lib.cmake | 8 ++---
cmake/modules/Findtblite.cmake | 8 ++---
cmake/modules/Findtest-drive.cmake | 8 ++---
7 files changed, 58 insertions(+), 54 deletions(-)
diff --git a/.github/workflows/fortran-build.yml b/.github/workflows/fortran-build.yml
index c3aac5402..b49402e29 100644
--- a/.github/workflows/fortran-build.yml
+++ b/.github/workflows/fortran-build.yml
@@ -73,15 +73,15 @@ jobs:
steps:
- name: Checkout code
- uses: actions/checkout@v3
-
+ uses: actions/checkout@v4
+
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install CMake
- run: pip3 install ninja cmake==3.26.4
+ run: pip3 install ninja cmake
- name: Configure build
run: cmake -B ${{ env.BUILD_DIR }} -G Ninja
@@ -157,7 +157,7 @@ jobs:
python-version: 3.x
- name: Install CMake
- run: pip3 install ninja cmake==3.26.4
+ run: pip3 install ninja cmake
- name: Configure build
run: cmake -B ${{ env.BUILD_DIR }} -DWITH_CPCMX=false -DWITH_TBLITE=false -G Ninja
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1c1d8a93..dc39cada7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,14 +14,20 @@
# You should have received a copy of the GNU Lesser General Public License
# along with xtb. If not, see .
-cmake_minimum_required(VERSION 3.9)
+cmake_minimum_required(VERSION 3.24)
-# Setup the XTB Project
+# Buggy CMake versions
+if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.27.0 AND CMAKE_VERSION VERSION_LESS 3.27.7)
+ message(WARNING "The project build could be unstable with your current version")
+endif()
+
+# Setup the xtb Project
project(
"xtb"
- VERSION "6.6.1"
+ VERSION "6.6.1"
LANGUAGES "C" "Fortran"
)
+
enable_testing()
# Follow GNU conventions for installing directories
@@ -30,6 +36,8 @@ include(GNUInstallDirs)
# Include CMake specific configurations
add_subdirectory("cmake")
+#message(FATAL_ERROR "STOP: ${CMAKE_Fortran_FLAGS_DEBUG}")
+
if(NOT TARGET "mctc-lib::mctc-lib")
find_package("mctc-lib" REQUIRED)
endif()
@@ -46,6 +54,7 @@ if(NOT TARGET "test-drive::test-drive")
find_package("test-drive" REQUIRED)
endif()
+
# Sources: initialize program sources (prog) and library sources (srcs) empty
set(prog)
set(srcs)
@@ -69,6 +78,7 @@ add_library(
OBJECT
${srcs}
)
+
set_target_properties(
"${PROJECT_NAME}-object"
PROPERTIES
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index cc9b9fd2f..186dbb4ba 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -14,21 +14,24 @@
# You should have received a copy of the Lesser GNU General Public License
# along with xtb. If not, see .
+# Some user-configurable features
option(WITH_OpenMP "Enable support for shared memory parallelisation with OpenMP" TRUE)
option(WITH_TBLITE "Use tblite library as backend for xTB" TRUE)
option(WITH_CPCMX "Use CPCM-X solvation library for xTB" TRUE)
-if(NOT DEFINED "${PROJECT_NAME}-dependeny-method")
- set(
- "${PROJECT_NAME}-dependency-method"
- "subproject" "cmake" "pkgconf" "fetch"
- )
-endif()
-set(
- module-dir
- "${PROJECT_NAME}/${CMAKE_Fortran_COMPILER_ID}-${CMAKE_Fortran_COMPILER_VERSION}"
-)
-set(module-dir "${module-dir}" PARENT_SCOPE)
+
+#if(NOT DEFINED "${PROJECT_NAME}-dependency-method")
+# set(
+# "${PROJECT_NAME}-dependency-method"
+# "subproject" "cmake" "pkgconf" "fetch"
+# )
+#endif()
+
+#set(
+# module-dir
+# "${PROJECT_NAME}/${CMAKE_Fortran_COMPILER_ID}-${CMAKE_Fortran_COMPILER_VERSION}"
+#)
+#set(module-dir "${module-dir}" PARENT_SCOPE)
# Set build type as CMake does not provide defaults
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@@ -43,27 +46,34 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
)
endif()
+# 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}"
)
+# Compiler-specific configurations
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
- set(dialect "-fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fbacktrace")
- set(bounds "-fbounds-check")
-endif()
-if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
- set(dialect "-axAVX2 -r8 -traceback")
- set(bounds "-check bounds")
-endif()
-if(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
- set(dialect "-Mbackslash -Mallocatable=03 -r8 -traceback")
+ set(dialects "-fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fbacktrace")
+ set(bounds "-fbounds-check -ffpe-trap=invalid,zero,overflow")
+elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
+ set(dialects "-axAVX2 -r8 -traceback")
+ set(bounds "-check bounds -fpe0")
+elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
+ set(dialects "-Mbackslash -Mallocatable=03 -r8 -traceback")
endif()
+
+# Customize compiler flags
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}" PARENT_SCOPE)
-set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}" PARENT_SCOPE)
+set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialects}" PARENT_SCOPE)
+
+#message(FATAL_ERROR "STOP: ${dialect} dist ${CMAKE_Fortran_FLAGS}")
+
# Populate xtb_version.fh
set(version ${PROJECT_VERSION})
diff --git a/cmake/modules/Findcpcmx.cmake b/cmake/modules/Findcpcmx.cmake
index a39328a73..ec22b61bf 100644
--- a/cmake/modules/Findcpcmx.cmake
+++ b/cmake/modules/Findcpcmx.cmake
@@ -70,12 +70,8 @@ set(_pkg "cpcmx")
set(_url "https://github.com/grimme-lab/CPCM-X")
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" "cmake" "pkgconf" "subproject" "fetch")
+ set("_${_pkg}_FIND_METHOD")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
@@ -83,8 +79,8 @@ include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
xtb_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}")
if(DEFINED "_${_pkg}_FIND_METHOD")
- unset("${_pkg}_FIND_METHOD")
- unset("_${_pkg}_FIND_METHOD")
+ unset("${_pkg}_FIND_METHOD")
+ unset("_${_pkg}_FIND_METHOD")
endif()
unset(_lib)
unset(_pkg)
diff --git a/cmake/modules/Findmctc-lib.cmake b/cmake/modules/Findmctc-lib.cmake
index 83c60aaf7..38b72158b 100644
--- a/cmake/modules/Findmctc-lib.cmake
+++ b/cmake/modules/Findmctc-lib.cmake
@@ -19,12 +19,8 @@ set(_pkg "MCTCLIB")
set(_url "https://github.com/grimme-lab/mctc-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" "cmake" "pkgconf" "subproject" "fetch")
+ set("_${_pkg}_FIND_METHOD")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
diff --git a/cmake/modules/Findtblite.cmake b/cmake/modules/Findtblite.cmake
index f4dbbd7b2..4d7810ab9 100644
--- a/cmake/modules/Findtblite.cmake
+++ b/cmake/modules/Findtblite.cmake
@@ -19,12 +19,8 @@ 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" "cmake" "pkgconf" "subproject" "fetch")
+ set("_${_pkg}_FIND_METHOD")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
diff --git a/cmake/modules/Findtest-drive.cmake b/cmake/modules/Findtest-drive.cmake
index 491e625ee..f7ba73104 100644
--- a/cmake/modules/Findtest-drive.cmake
+++ b/cmake/modules/Findtest-drive.cmake
@@ -70,12 +70,8 @@ set(_pkg "TEST_DRIVE")
set(_url "https://github.com/fortran-lang/test-drive")
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" "cmake" "pkgconf" "subproject" "fetch")
+ set("_${_pkg}_FIND_METHOD")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
From 26d6d38b1ae1315d5435d9083cab4a98309390b7 Mon Sep 17 00:00:00 2001
From: albert <92109627+Albkat@users.noreply.github.com>
Date: Fri, 20 Oct 2023 17:25:58 +0200
Subject: [PATCH 2/3] some update
Signed-off-by: albert <92109627+Albkat@users.noreply.github.com>
---
CMakeLists.txt | 7 +-
cmake/CMakeLists.txt | 23 +---
cmake/modules/Findcpcmx.cmake | 5 -
cmake/modules/Findmctc-lib.cmake | 5 -
cmake/modules/Findtblite.cmake | 4 -
cmake/modules/Findtest-drive.cmake | 4 -
cmake/modules/xtb-utils.cmake | 163 ++++++++++++++---------------
7 files changed, 84 insertions(+), 127 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc39cada7..a914abb49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,8 +36,7 @@ include(GNUInstallDirs)
# Include CMake specific configurations
add_subdirectory("cmake")
-#message(FATAL_ERROR "STOP: ${CMAKE_Fortran_FLAGS_DEBUG}")
-
+# Check a specific CMake targets for xtb build & execute corresponding Find scripts
if(NOT TARGET "mctc-lib::mctc-lib")
find_package("mctc-lib" REQUIRED)
endif()
@@ -46,6 +45,8 @@ if(NOT TARGET "tblite::tblite" AND WITH_TBLITE)
find_package("tblite" REQUIRED)
endif()
+
+
if(NOT TARGET "cpcmx::cpcmx" AND WITH_CPCMX)
find_package("cpcmx" REQUIRED)
endif()
@@ -54,12 +55,12 @@ if(NOT TARGET "test-drive::test-drive")
find_package("test-drive" REQUIRED)
endif()
-
# Sources: initialize program sources (prog) and library sources (srcs) empty
set(prog)
set(srcs)
add_subdirectory("src")
+message(FATAL_ERROR "STOP: ${srcs}")
add_subdirectory("symmetry")
# Find dependencies
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 186dbb4ba..96cea5d95 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -1,4 +1,4 @@
-# This file is part of xtb.
+# Thi file is part of xtb.
# SPDX-Identifier: LGPL-3.0-or-later
#
# xtb is free software: you can redistribute it and/or modify it under
@@ -20,19 +20,6 @@ option(WITH_TBLITE "Use tblite library as backend for xTB" TRUE)
option(WITH_CPCMX "Use CPCM-X solvation library for xTB" TRUE)
-#if(NOT DEFINED "${PROJECT_NAME}-dependency-method")
-# set(
-# "${PROJECT_NAME}-dependency-method"
-# "subproject" "cmake" "pkgconf" "fetch"
-# )
-#endif()
-
-#set(
-# module-dir
-# "${PROJECT_NAME}/${CMAKE_Fortran_COMPILER_ID}-${CMAKE_Fortran_COMPILER_VERSION}"
-#)
-#set(module-dir "${module-dir}" PARENT_SCOPE)
-
# Set build type as CMake does not provide defaults
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(
@@ -63,7 +50,7 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(bounds "-fbounds-check -ffpe-trap=invalid,zero,overflow")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
set(dialects "-axAVX2 -r8 -traceback")
- set(bounds "-check bounds -fpe0")
+ set(bounds "-check all -fpe0")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI")
set(dialects "-Mbackslash -Mallocatable=03 -r8 -traceback")
endif()
@@ -72,10 +59,8 @@ endif()
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}" PARENT_SCOPE)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialects}" PARENT_SCOPE)
-#message(FATAL_ERROR "STOP: ${dialect} dist ${CMAKE_Fortran_FLAGS}")
-
-# Populate xtb_version.fh
+# Populate xtb_version.fh with metadata
set(version ${PROJECT_VERSION})
execute_process(COMMAND git rev-parse HEAD
RESULT_VARIABLE git_return
@@ -85,7 +70,7 @@ if(git_return)
else()
string(REGEX REPLACE "\n$" "" commit ${commit})
endif()
-string(TIMESTAMP date "%m/%d/%Y")
+string(TIMESTAMP date "%Y/%m/%d")
set(author $ENV{USERNAME})
set(origin ${CMAKE_HOST_SYSTEM_NAME})
configure_file(
diff --git a/cmake/modules/Findcpcmx.cmake b/cmake/modules/Findcpcmx.cmake
index ec22b61bf..7fba27a97 100644
--- a/cmake/modules/Findcpcmx.cmake
+++ b/cmake/modules/Findcpcmx.cmake
@@ -71,17 +71,12 @@ set(_url "https://github.com/grimme-lab/CPCM-X")
if(NOT DEFINED "${_pkg}_FIND_METHOD")
set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch")
- set("_${_pkg}_FIND_METHOD")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
xtb_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}")
-if(DEFINED "_${_pkg}_FIND_METHOD")
- unset("${_pkg}_FIND_METHOD")
- unset("_${_pkg}_FIND_METHOD")
-endif()
unset(_lib)
unset(_pkg)
unset(_url)
diff --git a/cmake/modules/Findmctc-lib.cmake b/cmake/modules/Findmctc-lib.cmake
index 38b72158b..670e509c6 100644
--- a/cmake/modules/Findmctc-lib.cmake
+++ b/cmake/modules/Findmctc-lib.cmake
@@ -20,17 +20,12 @@ set(_url "https://github.com/grimme-lab/mctc-lib")
if(NOT DEFINED "${_pkg}_FIND_METHOD")
set("${_pkg}_FIND_METHOD" "cmake" "pkgconf" "subproject" "fetch")
- set("_${_pkg}_FIND_METHOD")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
xtb_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}")
-if(DEFINED "_${_pkg}_FIND_METHOD")
- unset("${_pkg}_FIND_METHOD")
- unset("_${_pkg}_FIND_METHOD")
-endif()
unset(_lib)
unset(_pkg)
unset(_url)
diff --git a/cmake/modules/Findtblite.cmake b/cmake/modules/Findtblite.cmake
index 4d7810ab9..ccaa7cc96 100644
--- a/cmake/modules/Findtblite.cmake
+++ b/cmake/modules/Findtblite.cmake
@@ -27,10 +27,6 @@ include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
xtb_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}")
-if(DEFINED "_${_pkg}_FIND_METHOD")
- unset("${_pkg}_FIND_METHOD")
- unset("_${_pkg}_FIND_METHOD")
-endif()
unset(_lib)
unset(_pkg)
unset(_url)
diff --git a/cmake/modules/Findtest-drive.cmake b/cmake/modules/Findtest-drive.cmake
index f7ba73104..5c49137e9 100644
--- a/cmake/modules/Findtest-drive.cmake
+++ b/cmake/modules/Findtest-drive.cmake
@@ -78,10 +78,6 @@ include("${CMAKE_CURRENT_LIST_DIR}/xtb-utils.cmake")
xtb_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}")
-if(DEFINED "_${_pkg}_FIND_METHOD")
- unset("${_pkg}_FIND_METHOD")
- unset("_${_pkg}_FIND_METHOD")
-endif()
unset(_lib)
unset(_pkg)
unset(_url)
diff --git a/cmake/modules/xtb-utils.cmake b/cmake/modules/xtb-utils.cmake
index 3b0604886..7c510fa34 100644
--- a/cmake/modules/xtb-utils.cmake
+++ b/cmake/modules/xtb-utils.cmake
@@ -16,124 +16,113 @@
# Handling of subproject dependencies
macro(
- "xtb_find_package"
- package
- methods
- url
+ "xtb_find_package"
+ package
+ methods
+ url
)
- string(TOLOWER "${package}" _pkg_lc)
- string(TOUPPER "${package}" _pkg_uc)
+string(TOLOWER "${package}" _pkg_lc)
+string(TOUPPER "${package}" _pkg_uc)
- foreach(method ${methods})
+# iterate through all methods
+foreach(method ${methods})
- if(TARGET "${package}::${package}")
+ if(TARGET "${package}::${package}")
break()
- endif()
+ endif()
- if("${method}" STREQUAL "cmake")
+ # cmake case
+ if("${method}" STREQUAL "cmake")
if(DEFINED "${_pkg_uc}_DIR")
- set("_${_pkg_uc}_DIR")
- set("${package}_DIR" "${_pkg_uc}_DIR")
+ set("_${_pkg_uc}_DIR")
+ set("${package}_DIR" "${_pkg_uc}_DIR")
endif()
- find_package("${package}" CONFIG)
+ find_package("${package}" CONFIG QUIET)
if("${package}_FOUND")
- message(STATUS "Found ${package} via CMake config")
- break()
+ message(STATUS "Found ${package} via CMake config")
+ break()
endif()
- endif()
- if("${method}" STREQUAL "pkgconf")
- find_package(PkgConfig QUIET)
- pkg_check_modules("${_pkg_uc}" QUIET "${package}")
+ # pkgconf case
+ elseif("${method}" STREQUAL "pkgconf")
+ find_package("PkgConfig" QUIET) # built-in Find script
+ pkg_check_modules("${_pkg_uc}" QUIET "${package}") # check if it is a pkg-config module
if("${_pkg_uc}_FOUND")
- message(STATUS "Found ${package} via pkg-config")
-
- add_library("${package}::${package}" INTERFACE IMPORTED)
- target_link_libraries(
- "${package}::${package}"
- INTERFACE
- "${${_pkg_uc}_LINK_LIBRARIES}"
- )
- target_include_directories(
- "${package}::${package}"
- INTERFACE
- "${${_pkg_uc}_INCLUDE_DIRS}"
- )
- break()
+ message(STATUS "Found ${package} via pkg-config")
+ add_library("${package}::${package}" INTERFACE IMPORTED) # interface library
+ target_link_libraries(
+ "${package}::${package}"
+ INTERFACE
+ "${${_pkg_uc}_LINK_LIBRARIES}"
+ )
+ target_include_directories(
+ "${package}::${package}"
+ INTERFACE
+ "${${_pkg_uc}_INCLUDE_DIRS}"
+ )
+ break()
endif()
- endif()
- if("${method}" STREQUAL "subproject")
+ # subproject case
+ elseif("${method}" STREQUAL "subproject")
if(NOT DEFINED "${_pkg_uc}_SUBPROJECT")
- set("_${_pkg_uc}_SUBPROJECT")
- set("${_pkg_uc}_SUBPROJECT" "subprojects/${package}")
+ set("${_pkg_uc}_SUBPROJECT" "subprojects/${package}")
endif()
set("${_pkg_uc}_SOURCE_DIR" "${PROJECT_SOURCE_DIR}/${${_pkg_uc}_SUBPROJECT}")
set("${_pkg_uc}_BINARY_DIR" "${PROJECT_BINARY_DIR}/${${_pkg_uc}_SUBPROJECT}")
+
+ # if can be configured from the subprojects dir
if(EXISTS "${${_pkg_uc}_SOURCE_DIR}/CMakeLists.txt")
- message(STATUS "Include ${package} from ${${_pkg_uc}_SUBPROJECT}")
- add_subdirectory(
- "${${_pkg_uc}_SOURCE_DIR}"
- "${${_pkg_uc}_BINARY_DIR}"
- )
-
- add_library("${package}::${package}" INTERFACE IMPORTED)
- target_link_libraries("${package}::${package}" INTERFACE "${package}")
-
- # We need the module directory in the subproject before we finish the configure stage
- if(NOT EXISTS "${${_pkg_uc}_BINARY_DIR}/include")
- file(MAKE_DIRECTORY "${${_pkg_uc}_BINARY_DIR}/include")
- endif()
-
- break()
+ message(STATUS "Include ${package} from ${${_pkg_uc}_SUBPROJECT}")
+
+ add_subdirectory(
+ "${${_pkg_uc}_SOURCE_DIR}"
+ "${${_pkg_uc}_BINARY_DIR}"
+ )
+
+ # create interface directory and manage it's dependencies
+ add_library("${package}::${package}" INTERFACE IMPORTED)
+ target_link_libraries("${package}::${package}" INTERFACE "${package}")
+
+ # We need the module directory in the subproject before we finish the configure stage
+ if(NOT EXISTS "${${_pkg_uc}_BINARY_DIR}/include")
+ file(MAKE_DIRECTORY "${${_pkg_uc}_BINARY_DIR}/include")
+ endif()
+
+ break()
endif()
- endif()
- if("${method}" STREQUAL "fetch")
+ # fetch from url case
+ elseif("${method}" STREQUAL "fetch")
message(STATUS "Retrieving ${package} from ${url}")
- include(FetchContent)
+ include(FetchContent) # module for fetching from repo
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(FETCHCONTENT_QUIET FALSE)
+ endif()
FetchContent_Declare(
- "${_pkg_lc}"
- GIT_REPOSITORY "${url}"
- GIT_TAG "HEAD"
+ "${_pkg_lc}"
+ GIT_REPOSITORY "${url}"
+ GIT_TAG "HEAD"
)
FetchContent_MakeAvailable("${_pkg_lc}")
-
+
add_library("${package}::${package}" INTERFACE IMPORTED)
target_link_libraries("${package}::${package}" INTERFACE "${package}")
- # We need the module directory in the subproject before we finish the configure stage
- FetchContent_GetProperties("${_pkg_lc}" SOURCE_DIR "${_pkg_uc}_SOURCE_DIR")
- FetchContent_GetProperties("${_pkg_lc}" BINARY_DIR "${_pkg_uc}_BINARY_DIR")
- if(NOT EXISTS "${${_pkg_uc}_BINARY_DIR}/include")
- file(MAKE_DIRECTORY "${${_pkg_uc}_BINARY_DIR}/include")
+ if(NOT EXISTS "${${_pkg_lc}_BINARY_DIR}/include")
+ file(MAKE_DIRECTORY "${${_pkg_lc}_BINARY_DIR}/include")
endif()
break()
- endif()
-
- endforeach()
-
- if(TARGET "${package}::${package}")
- set("${_pkg_uc}_FOUND" TRUE)
- else()
- set("${_pkg_uc}_FOUND" FALSE)
- endif()
+ endif()
- unset(_pkg_lc)
- unset(_pkg_uc)
+endforeach()
- if(DEFINED "_${_pkg_uc}_SUBPROJECT")
- unset("${_pkg_uc}_SUBPROJECT")
- unset("_${_pkg_uc}_SUBPROJECT")
- endif()
-
- if(DEFINED "_${_pkg_pc}_DIR")
- unset("${package}_DIR")
- unset("_${_pkg_pc}_DIR")
- endif()
+unset(_pkg_lc)
+unset(_pkg_uc)
- if(NOT TARGET "${package}::${package}")
- message(FATAL_ERROR "Could not find dependency ${package}")
- endif()
+# sanity check
+if(NOT TARGET "${package}::${package}")
+ message(FATAL_ERROR "Could not find dependency ${package}")
+endif()
endmacro()
From 7419ee4f77257c9e596796428c26083bcc432252 Mon Sep 17 00:00:00 2001
From: albert <92109627+Albkat@users.noreply.github.com>
Date: Mon, 30 Oct 2023 18:05:13 +0100
Subject: [PATCH 3/3] add embd term to scc energy
Signed-off-by: albert <92109627+Albkat@users.noreply.github.com>
---
src/scf_module.F90 | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/scf_module.F90 b/src/scf_module.F90
index 94bde4742..a81176ebb 100644
--- a/src/scf_module.F90
+++ b/src/scf_module.F90
@@ -903,7 +903,7 @@ subroutine scf(env, mol, wfn, basis, pcem, xtbData, solvation, &
if (.not.allocated(scD4)) then
energy = energy + ed
endif
- res%e_elec = eel
+ res%e_elec = eel+embd
res%e_atom = eat
res%e_rep = ep
res%e_es = ees
@@ -928,6 +928,8 @@ subroutine scf(env, mol, wfn, basis, pcem, xtbData, solvation, &
! ========================================================================
if (profile) call timer%deallocate
+ print*,"res1",res%e_total
+ print*,"ENERGY 1",energy
end subroutine scf