mirror of
https://github.com/triqs/dft_tools
synced 2024-11-18 12:03:50 +01:00
[cmake] Fix various issues occuring when using a skeleton based app as a subproject
This commit is contained in:
parent
7b91cfbbb3
commit
7b8b71e984
@ -27,6 +27,7 @@ endif()
|
|||||||
# ############
|
# ############
|
||||||
# Define Project
|
# Define Project
|
||||||
project(APP4TRIQS VERSION 2.2.0 LANGUAGES C CXX)
|
project(APP4TRIQS VERSION 2.2.0 LANGUAGES C CXX)
|
||||||
|
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
|
||||||
|
|
||||||
# ############
|
# ############
|
||||||
# Load TRIQS and CPP2PY
|
# Load TRIQS and CPP2PY
|
||||||
@ -47,6 +48,7 @@ endif()
|
|||||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR (NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX}))
|
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)
|
set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE)
|
||||||
|
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
|
message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
|
||||||
|
|
||||||
@ -59,9 +61,6 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
endif()
|
endif()
|
||||||
message(STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
|
message(STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
|
||||||
|
|
||||||
# Build static libraries
|
|
||||||
set(BUILD_SHARED_LIBS OFF)
|
|
||||||
|
|
||||||
# Export the list of compile-commands into compile_commands.json
|
# Export the list of compile-commands into compile_commands.json
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
@ -72,7 +71,9 @@ add_compile_options(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Create an Interface target for compiler warnings
|
# Create an Interface target for compiler warnings
|
||||||
add_library(project_warnings INTERFACE)
|
if(NOT TARGET project_warnings)
|
||||||
|
add_library(project_warnings INTERFACE)
|
||||||
|
endif()
|
||||||
install(TARGETS project_warnings EXPORT app4triqs-targets)
|
install(TARGETS project_warnings EXPORT app4triqs-targets)
|
||||||
target_compile_options(project_warnings
|
target_compile_options(project_warnings
|
||||||
INTERFACE
|
INTERFACE
|
||||||
@ -93,7 +94,7 @@ add_subdirectory(c++/app4triqs)
|
|||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
option(Build_Tests "Build tests" ON)
|
option(Build_Tests "Build tests" ON)
|
||||||
if(Build_Tests)
|
if(Build_Tests AND NOT IS_SUBPROJECT)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
@ -104,7 +105,7 @@ if(TRIQS_WITH_PYTHON_SUPPORT)
|
|||||||
|
|
||||||
# Build the documentation
|
# Build the documentation
|
||||||
option(Build_Documentation "Build documentation" OFF)
|
option(Build_Documentation "Build documentation" OFF)
|
||||||
if(Build_Documentation)
|
if(Build_Documentation AND NOT IS_SUBPROJECT)
|
||||||
if(NOT TRIQS_WITH_DOCUMENTATION)
|
if(NOT TRIQS_WITH_DOCUMENTATION)
|
||||||
message(WARNING "TRIQS was installed without documentation! Cannot build documentation.")
|
message(WARNING "TRIQS was installed without documentation! Cannot build documentation.")
|
||||||
else()
|
else()
|
||||||
@ -123,7 +124,7 @@ add_subdirectory(share)
|
|||||||
# Debian Package
|
# Debian Package
|
||||||
|
|
||||||
option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF)
|
option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF)
|
||||||
if(BUILD_DEBIAN_PACKAGE)
|
if(BUILD_DEBIAN_PACKAGE AND NOT IS_SUBPROJECT)
|
||||||
if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
||||||
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging")
|
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging")
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
file(GLOB_RECURSE sources *.cpp)
|
file(GLOB_RECURSE sources *.cpp)
|
||||||
add_library(app4triqs_c ${sources})
|
add_library(app4triqs_c STATIC ${sources})
|
||||||
|
|
||||||
# Link against triqs and enable warnings
|
# Link against triqs and enable warnings
|
||||||
target_link_libraries(app4triqs_c PUBLIC triqs PRIVATE project_warnings)
|
target_link_libraries(app4triqs_c PUBLIC triqs PRIVATE project_warnings)
|
||||||
|
Loading…
Reference in New Issue
Block a user