Fix qt_build_repo to be more robust

Check for the existence of CMakeLists.txt files before trying
to call add_subdirectory on examples, tests and src folders.

Change-Id: I7be76de5f7520c1dd181c610fd1dc2200ac74672
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
This commit is contained in:
Alexandru Croitor 2019-05-24 19:18:21 +02:00
parent d843bceb0c
commit 3122e7c01a

View File

@ -61,18 +61,17 @@ endmacro()
macro(qt_build_repo)
qt_build_repo_begin(${ARGN})
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt")
add_subdirectory(src)
endif()
if (BUILD_TESTING)
if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
find_package(Qt5 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test Xml)
add_subdirectory(tests)
endif()
if (BUILD_EXAMPLES)
# TODO: Implement me
#add_subdirectory(examples)
if (BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt")
add_subdirectory(examples)
endif()
qt_build_repo_end()