mirror of
https://github.com/triqs/dft_tools
synced 2024-12-31 16:45:49 +01:00
Adding cmake config files to install targets, Major cleaning
This commit is contained in:
parent
2b76c51f12
commit
6bf4afd316
@ -1,5 +1,5 @@
|
||||
# Version number
|
||||
set (APP4TRIQS_VERSION "1.5")
|
||||
set(APP4TRIQS_VERSION "1.5")
|
||||
|
||||
# Start configuration
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
@ -9,31 +9,28 @@ project(app4triqs CXX)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build" FORCE)
|
||||
endif()
|
||||
message( STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} -------------")
|
||||
message( STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
|
||||
|
||||
# Use shared libraries
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
|
||||
# Load TRIQS and Cpp2Py
|
||||
find_package(TRIQS 1.5 EXACT REQUIRED)
|
||||
find_package(Cpp2Py 1.5 EXACT REQUIRED)
|
||||
find_package(TRIQS ${APP4TRIQS_VERSION} EXACT REQUIRED)
|
||||
find_package(Cpp2Py ${APP4TRIQS_VERSION} EXACT REQUIRED)
|
||||
|
||||
# We will need the FindNNFT of triqs, so we adjust CMake Module Path to find it
|
||||
list(APPEND CMAKE_MODULE_PATH ${TRIQS_ROOT}/share/cmake)
|
||||
|
||||
# Default Install directory to TRIQS_ROOT if not given. Checks an absolute name is given.
|
||||
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")
|
||||
message(STATUS "No install prefix given (or invalid). Defaulting to TRIQS_ROOT")
|
||||
set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE)
|
||||
endif()
|
||||
message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} -------------")
|
||||
message(STATUS "-------- INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
|
||||
|
||||
# Macro defined in TRIQS which picks the hash of repo.
|
||||
# Fetch the git hash of app4triqs
|
||||
triqs_get_git_hash_of_source_dir(APP4TRIQS_GIT_HASH)
|
||||
message(STATUS "Git hash: ${APP4TRIQS_GIT_HASH}")
|
||||
|
||||
# Common to all targets (c++, python, tests).
|
||||
include_directories(c++)
|
||||
message(STATUS "app4triqs git hash: ${APP4TRIQS_GIT_HASH}")
|
||||
|
||||
# Set up the rpath for compiled executable
|
||||
triqs_set_rpath_for_all_targets()
|
||||
|
@ -3,17 +3,18 @@ add_library(app4triqs_c ${sources})
|
||||
|
||||
target_link_libraries(app4triqs_c PUBLIC triqs)
|
||||
target_compile_options(app4triqs_c PUBLIC -std=c++17)
|
||||
target_include_directories(app4triqs_c PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/c++>)
|
||||
|
||||
target_compile_definitions(app4triqs_c PUBLIC
|
||||
APP4TRIQS_GIT_HASH=${APP4TRIQS_GIT_HASH}
|
||||
TRIQS_GIT_HASH=${TRIQS_GIT_HASH}
|
||||
$<$<CONFIG:Debug>:DEBUG_APP4TRIQS>
|
||||
$<$<CONFIG:Debug>:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK>
|
||||
#$<$<BOOL:${MyOption}>:MYOPTION> # Add compile definintions for option
|
||||
target_compile_definitions(app4triqs_c PRIVATE
|
||||
APP4TRIQS_GIT_HASH=${APP4TRIQS_GIT_HASH}
|
||||
TRIQS_GIT_HASH=${TRIQS_GIT_HASH}
|
||||
$<$<CONFIG:Debug>:DEBUG_APP4TRIQS>
|
||||
$<$<CONFIG:Debug>:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK>
|
||||
#$<$<BOOL:${MyOption}>:MYOPTION> # Add compile definintions for option
|
||||
)
|
||||
|
||||
# Install
|
||||
install(TARGETS app4triqs_c DESTINATION lib)
|
||||
install(TARGETS app4triqs_c EXPORT app4triqs-targets DESTINATION lib)
|
||||
|
||||
# If other applications need our headers, we can install them as well
|
||||
# install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
|
||||
|
@ -30,16 +30,25 @@ execute_process(COMMAND cp_rs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY
|
||||
|
||||
add_custom_target(docs_cpp2rst)
|
||||
|
||||
get_property(TRIQS_INCLUDE_DIRS TARGET triqs PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_property(APP4TRIQS_INCLUDE_DIRS TARGET app4triqs_c PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
|
||||
set(CPP2RST_INCLUDE_DIRS ${TRIQS_INCLUDE_DIRS} ${APP4TRIQS_INCLUDE_DIRS})
|
||||
foreach(I ${CPP2RST_INCLUDE_DIRS})
|
||||
set (CPP2RST_INCLUDE_COMMAND ${CPP2RST_INCLUDE_COMMAND} --includes ${I})
|
||||
endforeach()
|
||||
|
||||
macro(generate_docs header_file)
|
||||
add_custom_command (TARGET docs_cpp2rst
|
||||
COMMAND c++2rst
|
||||
${header_file}
|
||||
-N app4triqs
|
||||
--output_directory ${CMAKE_CURRENT_BINARY_DIR}/cpp2rst_generated
|
||||
--cxxflags="-std=c++17"
|
||||
-I ${CMAKE_SOURCE_DIR}/c++
|
||||
-I ${TRIQS_ROOT}/include
|
||||
2>&1 >> cpp2rst.log
|
||||
COMMAND c++2rst
|
||||
${header_file}
|
||||
-N app4triqs
|
||||
--output_directory ${CMAKE_CURRENT_BINARY_DIR}/cpp2rst_generated
|
||||
${CPP2RST_INCLUDE_COMMAND}
|
||||
--cxxflags="-std=c++17"
|
||||
-I ${CMAKE_SOURCE_DIR}/c++
|
||||
-I ${TRIQS_ROOT}/include
|
||||
2>&1 >> cpp2rst.log
|
||||
)
|
||||
endmacro(generate_docs)
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
.. _about:
|
||||
|
||||
About app4triqs
|
||||
===============
|
||||
|
||||
An example application using cpp2py and triqs.
|
||||
|
@ -29,4 +29,4 @@ html_sidebars = {'index': ['sideb.html', 'searchbox.html']}
|
||||
|
||||
htmlhelp_basename = 'TRIQSIntdoc'
|
||||
|
||||
intersphinx_mapping = {'python': ('http://docs.python.org/2.7', None), 'triqslibs': ('http://ipht.cea.fr/triqs', None)}
|
||||
intersphinx_mapping = {'python': ('http://docs.python.org/2.7', None), 'triqslibs': ('https://triqs.ipht.cnrs.fr/unstable', None)}
|
||||
|
@ -1,12 +1,24 @@
|
||||
.. _contents:
|
||||
|
||||
Table of contents
|
||||
=================
|
||||
Documentation
|
||||
=============
|
||||
|
||||
Contents
|
||||
--------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 5
|
||||
|
||||
index
|
||||
documentation
|
||||
install
|
||||
issues
|
||||
about
|
||||
|
||||
Reference manual
|
||||
----------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 5
|
||||
|
||||
cpp2rst_generated/app4triqs/toto
|
||||
cpp2rst_generated/app4triqs/chain
|
||||
|
@ -1,12 +0,0 @@
|
||||
.. _documentation:
|
||||
|
||||
Documentation
|
||||
=============
|
||||
|
||||
Reference manual
|
||||
----------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
cpp2rst_generated/app4triqs/compute_Sigma_Hedin
|
@ -1,11 +1,11 @@
|
||||
.. _welcome:
|
||||
|
||||
App4Triqs
|
||||
app4triqs
|
||||
=========
|
||||
|
||||
An example application using cpp2py and triqs.
|
||||
|
||||
This documentation is generated based on the doc/\*.rst files and
|
||||
the comments in the sources and headers.
|
||||
This documentation is generated based on `rst <https://de.wikipedia.org/wiki/ReStructuredText>`_ files
|
||||
and the comments in the sources and headers.
|
||||
|
||||
Lets have a look at the :ref:`documentation`.
|
||||
Lets have a look at the :ref:`documentation <contents>`.
|
||||
|
@ -43,8 +43,8 @@ Version compatibility
|
||||
|
||||
Be careful that the version of the TRIQS library and of the solver must be
|
||||
compatible (more information on the :ref:`TRIQS website <triqslibs:versions>`).
|
||||
As the TRILEX project is currently still in alpha phase (unstable), it can
|
||||
only be compiled against the unstable branch of triqs.
|
||||
As app4triqs is still in alpha phase (unstable), it can only be compiled against the
|
||||
unstable branch of triqs.
|
||||
|
||||
Custom CMake options
|
||||
--------------------
|
||||
|
@ -1,25 +1,3 @@
|
||||
################################################################################
|
||||
#
|
||||
# App4Triqs: Test application for Triqs
|
||||
#
|
||||
# Copyright (C) 2018 by The Simons Foundation
|
||||
# Author: H. U.R. Strand
|
||||
#
|
||||
# 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
r"""
|
||||
DOC
|
||||
|
||||
|
@ -1,25 +1,3 @@
|
||||
################################################################################
|
||||
#
|
||||
# App4Triqs: Test application for Triqs
|
||||
#
|
||||
# Copyright (C) 2018 by The Simons Foundation
|
||||
# Author: H. U.R. Strand
|
||||
#
|
||||
# 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. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
version = "@APP4TRIQS_VERSION@"
|
||||
triqs_hash = "@TRIQS_GIT_HASH@"
|
||||
app4triqs_hash = "@APP4TRIQS_GIT_HASH@"
|
||||
|
@ -1,10 +1,16 @@
|
||||
add_subdirectory(cmake)
|
||||
|
||||
if(NOT CMAKE_INSTALL_PREFIX STREQUAL TRIQS_ROOT)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/app4triqs.modulefile.in ${CMAKE_CURRENT_BINARY_DIR}/app4triqs.modulefile @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/app4triqs.modulefile DESTINATION ${CMAKE_INSTALL_PREFIX}/share)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/app4triqsvars.sh.in ${CMAKE_CURRENT_BINARY_DIR}/app4triqsvars.sh @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/app4triqsvars.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/share)
|
||||
configure_file(app4triqs.modulefile.in app4triqs.modulefile @ONLY)
|
||||
configure_file(app4triqsvars.sh.in app4triqsvars.sh @ONLY)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/app4triqs.modulefile
|
||||
${CMAKE_CURRENT_BINARY_DIR}/app4triqsvars.sh
|
||||
DESTINATION share
|
||||
)
|
||||
|
||||
message(STATUS "***************************************************************")
|
||||
message(STATUS "* Custom install Location. Use: ")
|
||||
|
@ -8,6 +8,3 @@ export LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:$LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib:$LD_LIBRARY_PATH
|
||||
export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/@CPP2PY_PYTHON_LIB_DEST_ROOT@:$PYTHONPATH
|
||||
export CMAKE_PREFIX_PATH=@CMAKE_INSTALL_PREFIX@/share/cmake:$CMAKE_PREFIX_PATH
|
||||
|
||||
|
||||
|
||||
|
10
share/cmake/CMakeLists.txt
Normal file
10
share/cmake/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
configure_file(app4triqs-config.cmake.in app4triqs-config.cmake @ONLY)
|
||||
configure_file(app4triqs-config-version.cmake.in app4triqs-config-version.cmake @ONLY)
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/app4triqs-config.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/app4triqs-config-version.cmake
|
||||
DESTINATION share/cmake
|
||||
)
|
||||
|
||||
install(EXPORT app4triqs-targets DESTINATION share/cmake)
|
13
share/cmake/app4triqs-config-version.cmake.in
Normal file
13
share/cmake/app4triqs-config-version.cmake.in
Normal file
@ -0,0 +1,13 @@
|
||||
set(PACKAGE_VERSION @APP4TRIQS_VERSION@)
|
||||
|
||||
if (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
|
||||
if (PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
endif()
|
||||
|
||||
if (PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
endif()
|
20
share/cmake/app4triqs-config.cmake.in
Normal file
20
share/cmake/app4triqs-config.cmake.in
Normal file
@ -0,0 +1,20 @@
|
||||
# Multiple inclusion guard
|
||||
if (NOT APP4TRIQS_FOUND)
|
||||
set(APP4TRIQS_FOUND True)
|
||||
|
||||
# version
|
||||
set(APP4TRIQS_VERSION @APP4TRIQS_VERSION@)
|
||||
set(APP4TRIQS_GIT_HASH @APP4TRIQS_GIT_HASH@)
|
||||
|
||||
# Root of the installation
|
||||
set(APP4TRIQS_ROOT @CMAKE_INSTALL_PREFIX@)
|
||||
|
||||
# include the exported targets of this project
|
||||
include(@CMAKE_INSTALL_PREFIX@/share/cmake/app4triqs-targets.cmake)
|
||||
|
||||
MESSAGE(STATUS "Found APP4TRIQSConfig.cmake with version ${APP4TRIQS_VERSION}, hash = ${APP4TRIQS_GIT_HASH}")
|
||||
|
||||
# Documentation
|
||||
set(APP4TRIQS_WITH_DOCUMENTATION @Build_Documentation@)
|
||||
|
||||
endif (NOT APP4TRIQS_FOUND)
|
Loading…
Reference in New Issue
Block a user