mirror of
https://github.com/znc/znc.git
synced 2026-08-07 17:33:34 +02:00
Really fix cmake build when qt5 is not fully found
try_compile() errors out instead of just returning false when underlying CMakeLists.txt fails :-( Thanks kerio again
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# This is subproject because of the following error in FreeBSD after run of
|
||||
# pkg autoremove so only runtime dependencies are installed.
|
||||
#
|
||||
# CMake Error at /usr/local/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:15 (message):
|
||||
# The imported target "Qt5::Core" references the file
|
||||
# "/usr/local/lib/qt5/bin/qmake"
|
||||
# but this file does not exist. Possible reasons include:
|
||||
# * The file was deleted, renamed, or moved to another location.
|
||||
# * An install or uninstall procedure did not complete successfully.
|
||||
# * The installation package was faulty and contained
|
||||
# "/usr/local/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake"
|
||||
# but not all the files it references.
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(qt5check)
|
||||
set(CMAKE_VERBOSE_MAKEFILE true)
|
||||
|
||||
find_package(Qt5Network 5.4 REQUIRED HINTS ${Qt5_HINTS})
|
||||
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Qt5::Network)
|
||||
|
||||
add_custom_target(msg ALL COMMAND "${CMAKE_COMMAND}" -E echo
|
||||
"QT5_VERSION_BEGIN:${Qt5Network_VERSION}:QT5_VERSION_END" VERBATIM)
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2016 ZNC, see the NOTICE file for details.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <QTcpServer>
|
||||
|
||||
int main() {
|
||||
QTcpServer server;
|
||||
server.listen(QHostAddress::LocalHost, 1234);
|
||||
}
|
||||
+20
-40
@@ -67,43 +67,23 @@ target_include_directories(unittest_bin PRIVATE
|
||||
"${GMOCK_ROOT}" "${GMOCK_ROOT}/include")
|
||||
add_custom_target(unittest COMMAND unittest_bin)
|
||||
|
||||
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
|
||||
EXCLUDE_FROM_ALL true
|
||||
BUILD_ALWAYS true
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/integration"
|
||||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/integration"
|
||||
INSTALL_COMMAND ""
|
||||
CMAKE_CACHE_ARGS
|
||||
# Note the space in the end: protect from CXXFLAGS env var, but
|
||||
# still support custom flags
|
||||
"-DCMAKE_CXX_FLAGS:string=${INTEGRATION_TEST_CXX_FLAGS} "
|
||||
"-DGTEST_ROOT:path=${GTEST_ROOT}"
|
||||
"-DGMOCK_ROOT:path=${GMOCK_ROOT}"
|
||||
"-DZNC_BIN_DIR:path=${CMAKE_INSTALL_FULL_BINDIR}"
|
||||
"-DZNC_SRC_DIR:path=${PROJECT_SOURCE_DIR}"
|
||||
"-DQt5_HINTS:path=${brew_qt5}")
|
||||
add_custom_target(inttest COMMAND
|
||||
"${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()
|
||||
# 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
|
||||
EXCLUDE_FROM_ALL true
|
||||
BUILD_ALWAYS true
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/integration"
|
||||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/integration"
|
||||
INSTALL_COMMAND ""
|
||||
CMAKE_CACHE_ARGS
|
||||
# Note the space in the end: protect from CXXFLAGS env var, but
|
||||
# still support custom flags
|
||||
"-DCMAKE_CXX_FLAGS:string=${INTEGRATION_TEST_CXX_FLAGS} "
|
||||
"-DGTEST_ROOT:path=${GTEST_ROOT}"
|
||||
"-DGMOCK_ROOT:path=${GMOCK_ROOT}"
|
||||
"-DZNC_BIN_DIR:path=${CMAKE_INSTALL_FULL_BINDIR}"
|
||||
"-DZNC_SRC_DIR:path=${PROJECT_SOURCE_DIR}"
|
||||
"-DQt5_HINTS:path=${brew_qt5}")
|
||||
add_custom_target(inttest COMMAND
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/integration/inttest")
|
||||
add_dependencies(inttest inttest_bin)
|
||||
|
||||
Reference in New Issue
Block a user