Fix CMake build when Qt5 is partially found

Thanks kerio for report
This commit is contained in:
Alexey Sokolov
2016-01-16 16:36:32 +00:00
parent 561a18054c
commit a0c05b38f8
4 changed files with 79 additions and 5 deletions
+16 -4
View File
@@ -67,10 +67,19 @@ target_include_directories(unittest_bin PRIVATE
"${GMOCK_ROOT}" "${GMOCK_ROOT}/include")
add_custom_target(unittest COMMAND unittest_bin)
find_package(Qt5Network 5.4 QUIET HINTS ${brew_qt5})
if(Qt5Network_FOUND)
find_package_message(qt "Found Qt ${Qt5Network_VERSION}"
"1;${Qt5Network_VERSION}")
try_compile(qt5_findable
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/qt5check"
"${PROJECT_SOURCE_DIR}/cmake/qt5check" qt5check
CMAKE_FLAGS "-DQt5_HINTS=${brew_qt5}"
OUTPUT_VARIABLE _Qt5Check_tryout)
if(qt5_findable)
file(APPEND
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log"
"Output of Qt5 check:\n${_Qt5Check_tryout}\n")
string(REGEX REPLACE ".*QT5_VERSION_BEGIN:" "" qt5_version
"${_Qt5Check_tryout}")
string(REGEX REPLACE ":QT5_VERSION_END.*" "" qt5_version "${qt5_version}")
find_package_message(qt "Found Qt ${qt5_version}" "1;${qt5_version}")
# Use different compiler flags, because Qt fails with sanitizers,
# and we don't need sanitizers to test the test itself anyway.
externalproject_add(inttest_bin
@@ -92,6 +101,9 @@ if(Qt5Network_FOUND)
"${CMAKE_CURRENT_BINARY_DIR}/integration/inttest")
add_dependencies(inttest inttest_bin)
else()
file(APPEND
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
"Error in Qt5 check:\n${_Qt5Check_tryout}\n")
find_package_message(qt
"Qt >= 5.4 not found, integration testing will be disabled" "0")
endif()
+1 -1
View File
@@ -24,7 +24,7 @@ set(CMAKE_THREAD_PREFER_PTHREAD true)
set(THREADS_PREFER_PTHREAD_FLAG true)
find_package(Threads REQUIRED)
find_package(Qt5Network 5.4 HINTS ${Qt5_HINTS})
find_package(Qt5Network 5.4 REQUIRED HINTS ${Qt5_HINTS})
# Force the simple internal regex engine to get consistent behavior on all
# platforms. See