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) macro(qt_build_repo)
qt_build_repo_begin(${ARGN}) qt_build_repo_begin(${ARGN})
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src") if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt")
add_subdirectory(src) add_subdirectory(src)
endif() 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) find_package(Qt5 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test Xml)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
if (BUILD_EXAMPLES) if (BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt")
# TODO: Implement me add_subdirectory(examples)
#add_subdirectory(examples)
endif() endif()
qt_build_repo_end() qt_build_repo_end()