2019-04-16 17:09:27 +02:00
# Start configuration
2019-04-26 20:25:58 +02:00
cmake_minimum_required ( VERSION 3.0.2 FATAL_ERROR )
project ( triqs_dft_tools C CXX Fortran )
2019-04-16 17:09:27 +02:00
if ( POLICY CMP0074 )
cmake_policy ( SET CMP0074 NEW )
endif ( )
2017-12-07 15:56:05 +01:00
# Default to Release build type
if ( NOT CMAKE_BUILD_TYPE )
set ( CMAKE_BUILD_TYPE Release CACHE STRING "Type of build" FORCE )
endif ( )
2019-04-26 20:25:58 +02:00
message ( STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------" )
2013-07-23 19:49:42 +02:00
2017-12-07 15:56:05 +01:00
# Use shared libraries
set ( BUILD_SHARED_LIBS ON )
# Load TRIQS and Cpp2Py
2019-07-02 16:54:38 +02:00
find_package ( TRIQS 2.2 REQUIRED )
2019-04-16 23:04:27 +02:00
find_package ( Cpp2Py 1.6 REQUIRED )
2013-07-23 19:49:42 +02:00
2016-02-07 10:41:53 +01:00
if ( NOT ${ TRIQS_WITH_PYTHON_SUPPORT } )
MESSAGE ( FATAL_ERROR "dft_tools require Python support in TRIQS" )
endif ( )
2017-12-07 15:56:05 +01:00
# 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" )
set ( CMAKE_INSTALL_PREFIX ${ TRIQS_ROOT } CACHE PATH "default install path" FORCE )
endif ( )
message ( STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} -------------" )
2013-09-04 16:54:12 +02:00
2019-04-16 17:09:27 +02:00
# Define the dft_tools version numbers and get the git hash
set ( DFT_TOOLS_VERSION_MAJOR 2 )
2019-07-02 16:54:38 +02:00
set ( DFT_TOOLS_VERSION_MINOR 2 )
2019-04-16 17:09:27 +02:00
set ( DFT_TOOLS_VERSION_PATCH 0 )
set ( DFT_TOOLS_VERSION ${ DFT_TOOLS_VERSION_MAJOR } . ${ DFT_TOOLS_VERSION_MINOR } . ${ DFT_TOOLS_VERSION_PATCH } )
2017-12-07 15:56:05 +01:00
triqs_get_git_hash_of_source_dir ( DFT_TOOLS_GIT_HASH )
2019-04-16 17:09:27 +02:00
message ( STATUS "Dft_tools version : ${DFT_TOOLS_VERSION}" )
2017-12-07 15:56:05 +01:00
message ( STATUS "Git hash: ${DFT_TOOLS_GIT_HASH}" )
2013-07-23 19:49:42 +02:00
add_subdirectory ( fortran/dmftproj )
2016-03-24 11:40:12 +01:00
# Add the compiling options (-D... ) for C++
message ( STATUS "TRIQS : Adding compilation flags detected by the library (C++11/14, libc++, etc...) " )
add_subdirectory ( c++ )
2018-09-06 13:48:24 +02:00
add_subdirectory ( python python/triqs_dft_tools )
2016-03-11 11:35:19 +01:00
add_subdirectory ( shells )
2017-12-07 15:56:05 +01:00
2018-01-22 23:34:20 +01:00
#------------------------
# tests
#------------------------
2018-09-06 15:09:30 +02:00
option ( TEST_COVERAGE "Analyze the coverage of tests" OFF )
# perform tests with coverage info
if ( ${ TEST_COVERAGE } )
# we try to locate the coverage program
find_program ( PYTHON_COVERAGE python-coverage )
find_program ( PYTHON_COVERAGE coverage )
if ( NOT PYTHON_COVERAGE )
message ( FATAL_ERROR "Program coverage (or python-coverage) not found.\nEither set PYTHON_COVERAGE explicitly or disable TEST_COVERAGE!\nYou need to install the python package coverage, e.g. with\n pip install coverage\nor with\n apt install python-coverage" )
endif ( )
message ( STATUS "Setting up test coverage" )
add_custom_target ( coverage ${ PYTHON_COVERAGE } combine --append .coverage plovasp/.coverage || true COMMAND ${ PYTHON_COVERAGE } html COMMAND echo "Open ${CMAKE_BINARY_DIR}/test/htmlcov/index.html in browser!" WORKING_DIRECTORY ${ CMAKE_BINARY_DIR } /test )
endif ( )
2018-01-22 23:34:20 +01:00
enable_testing ( )
2018-09-06 15:09:30 +02:00
2018-01-22 23:34:20 +01:00
option ( Build_Tests "Build the tests of the library " ON )
if ( Build_Tests )
message ( STATUS "-------- Preparing tests -------------" )
add_subdirectory ( test )
endif ( )
2017-12-07 15:56:05 +01:00
2018-01-22 23:34:20 +01:00
#------------------------
# Documentation
#------------------------
2018-03-13 13:23:52 +01:00
option ( Build_Documentation "Build documentation" OFF )
if ( ${ Build_Documentation } )
2018-02-02 15:56:08 +01:00
if ( NOT ${ TRIQS_WITH_DOCUMENTATION } )
2013-08-07 16:40:18 +02:00
message ( "Error: TRIQS library has not been compiled with its documentation" )
endif ( )
add_subdirectory ( doc )
2018-03-13 13:23:52 +01:00
endif ( )
2018-05-21 16:44:01 +02:00
#--------------------------------------------------------
# Packaging
#--------------------------------------------------------
option ( BUILD_DEBIAN_PACKAGE "Build a deb package" OFF )
if ( BUILD_DEBIAN_PACKAGE )
if ( NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr" )
message ( FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging" )
endif ( )
SET ( CPACK_GENERATOR "DEB" )
SET ( CPACK_PACKAGE_VERSION ${ DFT_TOOLS_VERSION } )
SET ( CPACK_PACKAGE_CONTACT "https://github.com/TRIQS/dft_tools" )
EXECUTE_PROCESS ( COMMAND dpkg --print-architecture OUTPUT_VARIABLE CMAKE_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE )
2019-07-02 16:54:38 +02:00
SET ( CPACK_DEBIAN_PACKAGE_DEPENDS "triqs (>= 2.2)" )
2019-04-26 20:25:58 +02:00
SET ( CPACK_DEBIAN_PACKAGE_CONFLICTS "dft_tools" )
2018-05-29 21:28:36 +02:00
SET ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
SET ( CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON )
2018-05-21 16:44:01 +02:00
INCLUDE ( CPack )
endif ( )