Allow in-tree builds where Catch2 is just a subproject

Closes #1773
Closes #1774
This commit is contained in:
Martin Hořeňovský 2019-10-18 18:47:57 +02:00
parent ae14a47360
commit 01ef7076f5
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -6,12 +6,16 @@ if(NOT DEFINED PROJECT_NAME)
set(NOT_SUBPROJECT ON) set(NOT_SUBPROJECT ON)
endif() endif()
project(Catch2 LANGUAGES CXX VERSION 2.10.0) # Catch2's build breaks if done in-tree. You probably should not build
# things in tree anyway, but we can allow projects that include Catch2
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) # as a subproject to build in-tree as long as it is not in our tree.
if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt") message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
endif() endif()
project(Catch2 LANGUAGES CXX VERSION 2.10.0)
# Provide path for scripts # Provide path for scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")