3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-10 16:13:47 +01:00

[cmake] Make sure testing options propagate to subprojects without EXCLUDE_FROM_ALL

This commit is contained in:
Nils Wentzell 2020-04-29 17:56:09 -04:00
parent 5c1ec4c67d
commit 8206a43651
2 changed files with 12 additions and 4 deletions

View File

@ -20,10 +20,13 @@
# ##############################################################################
cmake_minimum_required(VERSION 3.3.2 FATAL_ERROR)
cmake_policy(SET CMP0057 NEW)
cmake_policy(VERSION 3.3.2)
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
# ############
# Define Project
@ -67,6 +70,12 @@ if(NOT IS_SUBPROJECT)
message(STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
endif()
# Testing
option(Build_Tests "Build tests" ON)
if(Build_Tests)
enable_testing()
endif()
# Export the list of compile-commands into compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@ -103,9 +112,7 @@ add_subdirectory(deps)
add_subdirectory(c++/app4triqs)
# Tests
option(Build_Tests "Build tests" ON)
if(Build_Tests AND NOT IS_SUBPROJECT)
enable_testing()
if(Build_Tests)
add_subdirectory(test)
endif()

View File

@ -45,6 +45,7 @@ function(external_dependency)
message(STATUS " =============== Configuring Dependency ${ARGV0} =============== ")
if(ARG_EXCLUDE_FROM_ALL)
set(subdir_opts EXCLUDE_FROM_ALL)
set(Build_Tests OFF)
endif()
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0})
message(STATUS "Found sources for dependency ${ARGV0} at ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.")