2020-06-10 17:45:53 +02:00
|
|
|
# ##############################################################################
|
|
|
|
#
|
|
|
|
# triqs_dft_tools - An example application using triqs and cpp2py
|
|
|
|
#
|
|
|
|
# Copyright (C) ...
|
|
|
|
#
|
|
|
|
# triqs_dft_tools is free software: you can redistribute it and/or modify it under the
|
|
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
|
|
# Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# triqs_dft_tools is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along with
|
|
|
|
# triqs_dft_tools (in the file COPYING.txt in this directory). If not, see
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# ##############################################################################
|
|
|
|
|
2023-06-22 21:03:38 +02:00
|
|
|
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
|
|
|
cmake_policy(VERSION 3.20)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# ############
|
|
|
|
# Define Project
|
2023-06-22 21:16:35 +02:00
|
|
|
project(triqs_dft_tools VERSION 3.2.0 LANGUAGES C CXX Fortran)
|
2020-06-10 17:45:53 +02:00
|
|
|
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
|
2017-12-07 15:56:05 +01:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# ############
|
|
|
|
# Load TRIQS and CPP2PY
|
2023-06-22 21:03:38 +02:00
|
|
|
find_package(TRIQS 3.2 REQUIRED)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Get the git hash & print status
|
|
|
|
triqs_get_git_hash_of_source_dir(PROJECT_GIT_HASH)
|
|
|
|
message(STATUS "${PROJECT_NAME} version : ${PROJECT_VERSION}")
|
|
|
|
message(STATUS "${PROJECT_NAME} Git hash: ${PROJECT_GIT_HASH}")
|
|
|
|
|
|
|
|
# Enforce Consistent Versioning
|
|
|
|
if(NOT ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} VERSION_EQUAL ${TRIQS_VERSION_MAJOR}.${TRIQS_VERSION_MINOR})
|
|
|
|
message(FATAL_ERROR "The ${PROJECT_NAME} version ${PROJECT_VERSION} is not compatible with TRIQS version ${TRIQS_VERSION}.")
|
2016-02-07 10:41:53 +01:00
|
|
|
endif()
|
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Default Install directory to TRIQS_ROOT if not given or invalid.
|
2017-12-07 15:56:05 +01:00
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR (NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX}))
|
2020-06-10 17:45:53 +02:00
|
|
|
message(STATUS "No install prefix given (or invalid). Defaulting to TRIQS_ROOT")
|
2017-12-07 15:56:05 +01:00
|
|
|
set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE)
|
2020-06-10 17:45:53 +02:00
|
|
|
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
|
|
|
|
endif()
|
|
|
|
if(NOT IS_SUBPROJECT)
|
|
|
|
message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
|
2017-12-07 15:56:05 +01:00
|
|
|
endif()
|
2020-06-10 17:45:53 +02:00
|
|
|
set(${PROJECT_NAME}_BINARY_DIR ${PROJECT_BINARY_DIR} CACHE STRING "Binary directory of the ${PROJECT_NAME} Project")
|
2013-09-04 16:54:12 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Make additional Find Modules available
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/share/cmake/Modules)
|
2016-03-24 11:40:12 +01:00
|
|
|
|
2021-02-01 21:02:57 +01:00
|
|
|
# ############
|
|
|
|
# CMake Options
|
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Default to Release build type
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build" FORCE)
|
|
|
|
endif()
|
|
|
|
if(NOT IS_SUBPROJECT)
|
|
|
|
message(STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
|
|
|
|
endif()
|
2018-09-06 15:09:30 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Python Support
|
|
|
|
option(PythonSupport "Build with Python support" ON)
|
|
|
|
if(PythonSupport AND NOT TRIQS_WITH_PYTHON_SUPPORT)
|
|
|
|
message(FATAL_ERROR "TRIQS was installed without Python support. Cannot build the Python Interface. Disable the build with -DPythonSupport=OFF")
|
|
|
|
endif()
|
2018-09-06 15:09:30 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Documentation
|
|
|
|
option(Build_Documentation "Build documentation" OFF)
|
2023-07-26 21:36:55 +02:00
|
|
|
if(NOT IS_SUBPROJECT AND (Build_Documentation AND NOT PythonSupport))
|
2021-02-09 22:39:07 +01:00
|
|
|
message(FATAL_ERROR "Build_Documentation=ON requires PythonSupport to be enabled")
|
|
|
|
endif()
|
2018-09-06 15:09:30 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Testing
|
|
|
|
option(Build_Tests "Build tests" ON)
|
|
|
|
if(Build_Tests)
|
|
|
|
enable_testing()
|
2018-09-06 15:09:30 +02:00
|
|
|
endif()
|
|
|
|
|
2021-02-01 21:02:57 +01:00
|
|
|
# Build static libraries by default
|
|
|
|
option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF)
|
|
|
|
|
|
|
|
# ############
|
|
|
|
# Global Compilation Settings
|
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Export the list of compile-commands into compile_commands.json
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2021-02-01 21:02:57 +01:00
|
|
|
# Disable compiler extensions
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
|
|
|
# Provide additional debugging information for Debug builds
|
2020-06-18 19:58:55 +02:00
|
|
|
add_compile_options($<$<CONFIG:Debug>:-ggdb3>)
|
2020-06-10 17:45:53 +02:00
|
|
|
|
|
|
|
# Create an Interface target for compiler warnings
|
|
|
|
add_library(${PROJECT_NAME}_warnings INTERFACE)
|
|
|
|
target_compile_options(${PROJECT_NAME}_warnings
|
|
|
|
INTERFACE
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
2023-06-06 16:43:32 +02:00
|
|
|
-Wfloat-conversion
|
2020-06-10 17:45:53 +02:00
|
|
|
-Wpedantic
|
|
|
|
-Wno-sign-compare
|
2020-09-10 16:11:41 +02:00
|
|
|
$<$<CXX_COMPILER_ID:GNU>:-Wno-comma-subscript>
|
2020-06-10 17:45:53 +02:00
|
|
|
$<$<CXX_COMPILER_ID:GNU>:-Wshadow=local>
|
|
|
|
$<$<CXX_COMPILER_ID:GNU>:-Wno-attributes>
|
2023-08-24 18:38:37 +02:00
|
|
|
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
|
|
|
|
$<$<CXX_COMPILER_ID:AppleClang,Clang,IntelLLVM>:-Wno-deprecated-comma-subscript>
|
|
|
|
$<$<CXX_COMPILER_ID:AppleClang,Clang,IntelLLVM>:-Wno-unknown-warning-option>
|
|
|
|
$<$<CXX_COMPILER_ID:AppleClang,Clang,IntelLLVM>:-Wshadow>
|
|
|
|
$<$<CXX_COMPILER_ID:AppleClang,Clang,IntelLLVM>:-Wno-gcc-compat>
|
|
|
|
$<$<CXX_COMPILER_ID:AppleClang,Clang,IntelLLVM>:-Wno-c++20-extensions>
|
|
|
|
$<$<CXX_COMPILER_ID:AppleClang,Clang,IntelLLVM>:-Wno-c++20-compat>
|
|
|
|
$<$<CXX_COMPILER_ID:IntelLLVM>:-Wno-tautological-constant-compare>
|
2020-06-10 17:45:53 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# #############
|
|
|
|
# Build Project
|
|
|
|
|
|
|
|
# Find / Build dependencies
|
|
|
|
add_subdirectory(deps)
|
|
|
|
|
|
|
|
# Build and install the library
|
|
|
|
add_subdirectory(c++/${PROJECT_NAME})
|
|
|
|
|
|
|
|
# add here stuff for the Fortran part in DFTTools
|
|
|
|
add_subdirectory(fortran/dmftproj)
|
2018-09-06 15:09:30 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Tests
|
|
|
|
if(Build_Tests)
|
|
|
|
add_subdirectory(test)
|
2018-01-22 23:34:20 +01:00
|
|
|
endif()
|
2017-12-07 15:56:05 +01:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# Python
|
|
|
|
if(PythonSupport)
|
|
|
|
add_subdirectory(python/${PROJECT_NAME})
|
2023-01-04 23:16:57 +01:00
|
|
|
# elk binary i/o code for wrappers
|
|
|
|
add_subdirectory(python/${PROJECT_NAME}/converters/elktools/elkwrappers)
|
2020-06-10 17:45:53 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Docs
|
2023-07-26 20:55:30 +02:00
|
|
|
if(NOT IS_SUBPROJECT AND Build_Documentation)
|
2013-08-07 16:40:18 +02:00
|
|
|
add_subdirectory(doc)
|
2018-03-13 13:23:52 +01:00
|
|
|
endif()
|
2018-05-21 16:44:01 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
# dfttols vasp interface bash scripts
|
|
|
|
add_subdirectory(bin)
|
|
|
|
|
|
|
|
# Additional configuration files
|
|
|
|
add_subdirectory(share)
|
|
|
|
|
|
|
|
# #############
|
|
|
|
# Debian Package
|
|
|
|
|
2018-05-21 16:44:01 +02:00
|
|
|
option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF)
|
2020-06-10 17:45:53 +02:00
|
|
|
if(BUILD_DEBIAN_PACKAGE AND NOT IS_SUBPROJECT)
|
2018-05-21 16:44:01 +02:00
|
|
|
if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
|
|
|
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging")
|
|
|
|
endif()
|
2020-06-10 17:45:53 +02:00
|
|
|
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
|
|
|
set(CPACK_GENERATOR "DEB")
|
|
|
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
|
|
|
set(CPACK_PACKAGE_CONTACT "https://github.com/TRIQS/${PROJECT_NAME}")
|
|
|
|
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CMAKE_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2023-06-22 21:03:38 +02:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "triqs (>= 3.2)")
|
2020-06-10 17:45:53 +02:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
|
|
|
|
include(CPack)
|
2018-05-21 16:44:01 +02:00
|
|
|
endif()
|