mirror of
https://github.com/triqs/dft_tools
synced 2024-09-12 05:38:31 +02: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
|
||||
project(APP4TRIQS VERSION 2.2.0 LANGUAGES C CXX)
|
||||
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
|
||||
|
||||
# ############
|
||||
# Load TRIQS and CPP2PY
|
||||
@ -47,6 +48,7 @@ endif()
|
||||
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)
|
||||
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
|
||||
endif()
|
||||
message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
|
||||
|
||||
@ -59,9 +61,6 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
endif()
|
||||
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
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
@ -72,7 +71,9 @@ add_compile_options(
|
||||
)
|
||||
|
||||
# Create an Interface target for compiler warnings
|
||||
if(NOT TARGET project_warnings)
|
||||
add_library(project_warnings INTERFACE)
|
||||
endif()
|
||||
install(TARGETS project_warnings EXPORT app4triqs-targets)
|
||||
target_compile_options(project_warnings
|
||||
INTERFACE
|
||||
@ -93,7 +94,7 @@ add_subdirectory(c++/app4triqs)
|
||||
|
||||
# Tests
|
||||
option(Build_Tests "Build tests" ON)
|
||||
if(Build_Tests)
|
||||
if(Build_Tests AND NOT IS_SUBPROJECT)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
@ -104,7 +105,7 @@ if(TRIQS_WITH_PYTHON_SUPPORT)
|
||||
|
||||
# Build the documentation
|
||||
option(Build_Documentation "Build documentation" OFF)
|
||||
if(Build_Documentation)
|
||||
if(Build_Documentation AND NOT IS_SUBPROJECT)
|
||||
if(NOT TRIQS_WITH_DOCUMENTATION)
|
||||
message(WARNING "TRIQS was installed without documentation! Cannot build documentation.")
|
||||
else()
|
||||
@ -123,7 +124,7 @@ add_subdirectory(share)
|
||||
# Debian Package
|
||||
|
||||
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")
|
||||
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging")
|
||||
endif()
|
||||
|
@ -1,5 +1,5 @@
|
||||
file(GLOB_RECURSE sources *.cpp)
|
||||
add_library(app4triqs_c ${sources})
|
||||
add_library(app4triqs_c STATIC ${sources})
|
||||
|
||||
# Link against triqs and enable warnings
|
||||
target_link_libraries(app4triqs_c PUBLIC triqs PRIVATE project_warnings)
|
||||
|
Loading…
Reference in New Issue
Block a user