summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuild.cmake
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@gmail.com>2019-05-03 15:46:02 +0200
committerCristian Adam <cristian.adam@gmail.com>2019-05-04 20:56:17 +0000
commit1a92808a7890129dca6df3ca3ec8374841a9fe58 (patch)
tree5f8f0cf826eacb010dbad1e4977c9f3ba62ceebf /cmake/QtBuild.cmake
parent6b2de61bf973dc8c0f245ba4dfdb791faa15b428 (diff)
Add support for MinGW
Tested with MinGW 7.3.0 64 from Qt 5.12 installation. The CMake 3rd party libraries I used from hunter project (with some package, and target names changes) Change-Id: Ie89555a6cd8bdb7182f9b2dd2c3c39784c523ead Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r--cmake/QtBuild.cmake30
1 files changed, 26 insertions, 4 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 7c776fcda7..dc52c7d72b 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -65,6 +65,9 @@ if(WIN32)
set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/win32-msvc)
elseif(CLANG)
set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/win32-clang)
+ elseif(MINGW)
+ set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/win32-g++)
+ list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS _WIN32_WINNT=0x0601)
endif()
elseif(LINUX)
if(GCC)
@@ -278,7 +281,7 @@ function(qt_internal_add_link_flags_no_undefined target)
if (GCC OR CLANG)
if(APPLE)
set(no_undefined_flag "-Wl,-undefined,error")
- elseif(LINUX)
+ elseif(LINUX OR MINGW)
set(no_undefined_flag "-Wl,--no-undefined")
else()
message(FATAL_ERROR "Platform linker doesn't support erroring upon encountering undefined symbols. Target:\"${target}\".")
@@ -1449,7 +1452,10 @@ endfunction()
macro(qt_find_package)
# Get the target names we expect to be provided by the package.
- cmake_parse_arguments(arg "" "" "PROVIDED_TARGETS;COMPONENTS" ${ARGN})
+ set(options CONFIG NO_MODULE MODULE REQUIRED)
+ set(oneValueArgs)
+ set(multiValueArgs PROVIDED_TARGETS COMPONENTS)
+ cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Get the version if specified.
set(package_version "")
@@ -1464,8 +1470,24 @@ macro(qt_find_package)
list(APPEND arg_UNPARSED_ARGUMENTS "COMPONENTS;${arg_COMPONENTS}")
endif()
- # Call original function without our custom arguments.
- find_package(${arg_UNPARSED_ARGUMENTS})
+ if(NOT (arg_CONFIG OR arg_NO_MODULE OR arg_MODULE))
+ # Try to find a config package first in quiet mode
+ set(config_package_arg ${arg_UNPARSED_ARGUMENTS})
+ list(APPEND config_package_arg "CONFIG;QUIET")
+ find_package(${config_package_arg})
+ endif()
+
+ # Ensure the options are back in the original unparsed arguments
+ foreach(opt IN LISTS options)
+ if(arg_${opt})
+ list(APPEND arg_UNPARSED_ARGUMENTS ${opt})
+ endif()
+ endforeach()
+
+ if (NOT ${ARGV0}_FOUND)
+ # Call original function without our custom arguments.
+ find_package(${arg_UNPARSED_ARGUMENTS})
+ endif()
if(${ARGV0}_FOUND AND arg_PROVIDED_TARGETS)
# If package was found, associate each target with its package name. This will be used