2019-06-26 19:45:34 +02:00
|
|
|
# ##############################################################################
|
|
|
|
#
|
|
|
|
# app4triqs - An example application using triqs and cpp2py
|
|
|
|
#
|
|
|
|
# Copyright (C) ...
|
|
|
|
#
|
|
|
|
# app4triqs 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.
|
|
|
|
#
|
|
|
|
# app4triqs 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
|
|
|
|
# app4triqs (in the file COPYING.txt in this directory). If not, see
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# ##############################################################################
|
|
|
|
|
2020-04-28 22:34:00 +02:00
|
|
|
cmake_minimum_required(VERSION 3.3.2 FATAL_ERROR)
|
|
|
|
cmake_policy(SET CMP0057 NEW)
|
2018-11-20 23:53:10 +01:00
|
|
|
if(POLICY CMP0074)
|
|
|
|
cmake_policy(SET CMP0074 NEW)
|
|
|
|
endif()
|
2018-03-22 18:11:39 +01:00
|
|
|
|
2019-06-26 19:45:34 +02:00
|
|
|
# ############
|
|
|
|
# Define Project
|
2020-04-29 21:30:54 +02:00
|
|
|
project(APP4TRIQS VERSION 3.0.0 LANGUAGES C CXX)
|
2019-12-02 23:53:17 +01:00
|
|
|
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
|
2019-06-26 19:45:34 +02:00
|
|
|
|
|
|
|
# ############
|
|
|
|
# Load TRIQS and CPP2PY
|
2020-04-29 21:30:54 +02:00
|
|
|
find_package(TRIQS 3.0 REQUIRED)
|
2019-06-26 19:45:34 +02:00
|
|
|
|
|
|
|
# Get the git hash & print status
|
2019-07-16 17:54:32 +02:00
|
|
|
triqs_get_git_hash_of_source_dir(PROJECT_GIT_HASH)
|
2019-06-26 19:45:34 +02:00
|
|
|
message(STATUS "${PROJECT_NAME} version : ${PROJECT_VERSION}")
|
2019-07-16 17:54:32 +02:00
|
|
|
message(STATUS "${PROJECT_NAME} Git hash: ${PROJECT_GIT_HASH}")
|
2019-06-26 19:45:34 +02:00
|
|
|
|
|
|
|
# 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}.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Default Install directory to TRIQS_ROOT if not given or invalid.
|
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR (NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX}))
|
|
|
|
message(STATUS "No install prefix given (or invalid). Defaulting to TRIQS_ROOT")
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE)
|
2019-12-02 23:53:17 +01:00
|
|
|
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
|
2019-06-26 19:45:34 +02:00
|
|
|
endif()
|
2020-04-22 21:05:24 +02:00
|
|
|
if(NOT IS_SUBPROJECT)
|
|
|
|
message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
|
|
|
|
endif()
|
2020-04-24 23:51:19 +02:00
|
|
|
set(APP4TRIQS_BINARY_DIR ${PROJECT_BINARY_DIR} CACHE STRING "Binary directory of the APP4TRIQS Project")
|
2019-06-26 19:45:34 +02:00
|
|
|
|
2020-04-22 21:04:30 +02:00
|
|
|
|
2019-06-26 19:45:34 +02:00
|
|
|
# ############
|
|
|
|
# Options
|
|
|
|
|
2018-03-22 18:11:39 +01:00
|
|
|
# Default to Release build type
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build" FORCE)
|
|
|
|
endif()
|
2020-04-22 21:05:24 +02:00
|
|
|
if(NOT IS_SUBPROJECT)
|
|
|
|
message(STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
|
|
|
|
endif()
|
2018-03-22 18:11:39 +01:00
|
|
|
|
2018-11-26 18:03:54 +01:00
|
|
|
# Export the list of compile-commands into compile_commands.json
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2019-06-26 17:06:04 +02:00
|
|
|
# Global compiler options
|
2020-04-24 23:51:19 +02:00
|
|
|
option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF)
|
2019-04-22 17:24:53 +02:00
|
|
|
add_compile_options(
|
2019-06-26 17:06:04 +02:00
|
|
|
$<$<CONFIG:Debug>:-Og>
|
|
|
|
$<$<CONFIG:Debug>:-ggdb3>
|
|
|
|
)
|
|
|
|
|
|
|
|
# Create an Interface target for compiler warnings
|
2020-04-29 21:31:36 +02:00
|
|
|
add_library(app4triqs_warnings INTERFACE)
|
|
|
|
target_compile_options(app4triqs_warnings
|
|
|
|
INTERFACE
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wpedantic
|
|
|
|
-Wno-sign-compare
|
|
|
|
$<$<CXX_COMPILER_ID:GNU>:-Wshadow=local>
|
|
|
|
$<$<CXX_COMPILER_ID:GNU>:-Wno-attributes>
|
|
|
|
$<$<CXX_COMPILER_ID:Clang>:-Wshadow>
|
|
|
|
$<$<CXX_COMPILER_ID:Clang>:-Wno-gcc-compat>
|
|
|
|
$<$<CXX_COMPILER_ID:AppleClang>:-Wshadow>
|
|
|
|
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-gcc-compat>
|
|
|
|
)
|
2018-03-25 19:57:55 +02:00
|
|
|
|
2019-06-26 19:45:34 +02:00
|
|
|
# #############
|
|
|
|
# Build Project
|
2018-03-22 18:11:39 +01:00
|
|
|
|
2020-04-24 23:52:27 +02:00
|
|
|
# Find / Build dependencies
|
|
|
|
add_subdirectory(deps)
|
|
|
|
|
2018-03-25 19:00:54 +02:00
|
|
|
# Build and install the app4triqs library
|
2018-03-22 18:11:39 +01:00
|
|
|
add_subdirectory(c++/app4triqs)
|
2018-03-25 19:00:54 +02:00
|
|
|
|
2018-03-22 18:11:39 +01:00
|
|
|
# Tests
|
2018-10-11 23:17:53 +02:00
|
|
|
option(Build_Tests "Build tests" ON)
|
2019-12-02 23:53:17 +01:00
|
|
|
if(Build_Tests AND NOT IS_SUBPROJECT)
|
2018-10-11 23:17:53 +02:00
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2018-03-22 18:11:39 +01:00
|
|
|
|
2019-04-03 00:07:03 +02:00
|
|
|
if(TRIQS_WITH_PYTHON_SUPPORT)
|
|
|
|
# Python interface
|
|
|
|
add_subdirectory(python/app4triqs)
|
2018-03-22 18:11:39 +01:00
|
|
|
|
2019-04-03 00:07:03 +02:00
|
|
|
# Build the documentation
|
|
|
|
option(Build_Documentation "Build documentation" OFF)
|
2019-12-02 23:53:17 +01:00
|
|
|
if(Build_Documentation AND NOT IS_SUBPROJECT)
|
2019-04-03 00:07:03 +02:00
|
|
|
if(NOT TRIQS_WITH_DOCUMENTATION)
|
2019-06-26 19:45:34 +02:00
|
|
|
message(WARNING "TRIQS was installed without documentation! Cannot build documentation.")
|
2019-04-03 00:07:03 +02:00
|
|
|
else()
|
|
|
|
message(STATUS "Documentation Build enabled")
|
|
|
|
add_subdirectory(doc)
|
|
|
|
endif()
|
2018-03-22 18:11:39 +01:00
|
|
|
endif()
|
2019-04-03 00:07:03 +02:00
|
|
|
else()
|
2019-06-26 19:45:34 +02:00
|
|
|
message(WARNING "TRIQS was installed without Python support. Cannot build the Python Interface and Documentation.")
|
2018-03-22 18:11:39 +01:00
|
|
|
endif()
|
2018-05-14 21:26:28 +02:00
|
|
|
|
2019-04-03 00:07:03 +02:00
|
|
|
# Additional configuration files
|
|
|
|
add_subdirectory(share)
|
|
|
|
|
2020-04-24 23:51:19 +02:00
|
|
|
|
2019-06-26 19:45:34 +02:00
|
|
|
# #############
|
2019-04-03 00:07:03 +02:00
|
|
|
# Debian Package
|
2019-06-26 19:45:34 +02:00
|
|
|
|
2018-05-14 21:26:28 +02:00
|
|
|
option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF)
|
2019-12-02 23:53:17 +01:00
|
|
|
if(BUILD_DEBIAN_PACKAGE AND NOT IS_SUBPROJECT)
|
2018-05-14 21:26:28 +02:00
|
|
|
if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
|
|
|
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging")
|
|
|
|
endif()
|
2019-06-26 19:45:34 +02:00
|
|
|
set(CPACK_PACKAGE_NAME app4triqs)
|
2019-06-26 17:35:20 +02:00
|
|
|
set(CPACK_GENERATOR "DEB")
|
|
|
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
|
|
|
set(CPACK_PACKAGE_CONTACT "https://github.com/TRIQS/app4triqs")
|
|
|
|
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CMAKE_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "triqs (>= 2.2)")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON)
|
|
|
|
include(CPack)
|
2018-05-14 21:26:28 +02:00
|
|
|
endif()
|
2019-06-26 19:45:34 +02:00
|
|
|
|