From 6bf4afd316acc4f064b18915a6faf23715d1a5bb Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Fri, 23 Mar 2018 16:59:38 +0100 Subject: [PATCH] Adding cmake config files to install targets, Major cleaning --- CMakeLists.txt | 19 ++++++-------- c++/app4triqs/CMakeLists.txt | 17 +++++++------ doc/CMakeLists.txt | 25 +++++++++++++------ doc/about.rst | 3 +++ doc/conf.py.in | 2 +- doc/contents.rst | 18 ++++++++++--- doc/documentation.rst | 12 --------- doc/index.rst | 8 +++--- doc/install.rst | 4 +-- python/app4triqs/__init__.py | 22 ---------------- python/app4triqs/version.py.in | 22 ---------------- share/CMakeLists.txt | 16 ++++++++---- share/app4triqsvars.sh.in | 3 --- share/cmake/CMakeLists.txt | 10 ++++++++ share/cmake/app4triqs-config-version.cmake.in | 13 ++++++++++ share/cmake/app4triqs-config.cmake.in | 20 +++++++++++++++ 16 files changed, 113 insertions(+), 101 deletions(-) delete mode 100644 doc/documentation.rst create mode 100644 share/cmake/CMakeLists.txt create mode 100644 share/cmake/app4triqs-config-version.cmake.in create mode 100644 share/cmake/app4triqs-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 78e5d33d..854ebccb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/c++/app4triqs/CMakeLists.txt b/c++/app4triqs/CMakeLists.txt index 449b23ee..fefb6564 100644 --- a/c++/app4triqs/CMakeLists.txt +++ b/c++/app4triqs/CMakeLists.txt @@ -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 $) -target_compile_definitions(app4triqs_c PUBLIC - APP4TRIQS_GIT_HASH=${APP4TRIQS_GIT_HASH} - TRIQS_GIT_HASH=${TRIQS_GIT_HASH} - $<$:DEBUG_APP4TRIQS> - $<$:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK> - #$<$:MYOPTION> # Add compile definintions for option +target_compile_definitions(app4triqs_c PRIVATE + APP4TRIQS_GIT_HASH=${APP4TRIQS_GIT_HASH} + TRIQS_GIT_HASH=${TRIQS_GIT_HASH} + $<$:DEBUG_APP4TRIQS> + $<$:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK> + #$<$: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") diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 05eed6c9..658139b9 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -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) diff --git a/doc/about.rst b/doc/about.rst index 8fc7917d..c0ec4464 100644 --- a/doc/about.rst +++ b/doc/about.rst @@ -1,3 +1,6 @@ .. _about: +About app4triqs +=============== + An example application using cpp2py and triqs. diff --git a/doc/conf.py.in b/doc/conf.py.in index 0bdc06f9..cc68de4d 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -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)} diff --git a/doc/contents.rst b/doc/contents.rst index 109c3171..16954194 100644 --- a/doc/contents.rst +++ b/doc/contents.rst @@ -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 diff --git a/doc/documentation.rst b/doc/documentation.rst deleted file mode 100644 index 6bec32ee..00000000 --- a/doc/documentation.rst +++ /dev/null @@ -1,12 +0,0 @@ -.. _documentation: - -Documentation -============= - -Reference manual ----------------- - -.. toctree:: - :maxdepth: 1 - - cpp2rst_generated/app4triqs/compute_Sigma_Hedin diff --git a/doc/index.rst b/doc/index.rst index 6e5c1710..d342e1ad 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -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 `_ 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 `. diff --git a/doc/install.rst b/doc/install.rst index 4cfb66a3..ed132b75 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -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 `). -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 -------------------- diff --git a/python/app4triqs/__init__.py b/python/app4triqs/__init__.py index a44ad9d7..d00e4749 100644 --- a/python/app4triqs/__init__.py +++ b/python/app4triqs/__init__.py @@ -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 . -# -################################################################################ - r""" DOC diff --git a/python/app4triqs/version.py.in b/python/app4triqs/version.py.in index b28d0875..dfcc5436 100644 --- a/python/app4triqs/version.py.in +++ b/python/app4triqs/version.py.in @@ -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 . -# -################################################################################ - version = "@APP4TRIQS_VERSION@" triqs_hash = "@TRIQS_GIT_HASH@" app4triqs_hash = "@APP4TRIQS_GIT_HASH@" diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 734a9a5d..c12791b6 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -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: ") diff --git a/share/app4triqsvars.sh.in b/share/app4triqsvars.sh.in index ff0abab6..8bab403f 100644 --- a/share/app4triqsvars.sh.in +++ b/share/app4triqsvars.sh.in @@ -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 - - - diff --git a/share/cmake/CMakeLists.txt b/share/cmake/CMakeLists.txt new file mode 100644 index 00000000..0ebacec0 --- /dev/null +++ b/share/cmake/CMakeLists.txt @@ -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) diff --git a/share/cmake/app4triqs-config-version.cmake.in b/share/cmake/app4triqs-config-version.cmake.in new file mode 100644 index 00000000..9d1cb5c4 --- /dev/null +++ b/share/cmake/app4triqs-config-version.cmake.in @@ -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() diff --git a/share/cmake/app4triqs-config.cmake.in b/share/cmake/app4triqs-config.cmake.in new file mode 100644 index 00000000..90d20551 --- /dev/null +++ b/share/cmake/app4triqs-config.cmake.in @@ -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)