summaryrefslogtreecommitdiffstats
path: root/Modules/FindQt4.cmake
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2012-11-20 13:53:41 (GMT)
committerBrad King <brad.king@kitware.com>2013-01-23 19:15:41 (GMT)
commite3b5eb6b23e5d2b6034e1c13716abb73ab6b3397 (patch)
tree835263e83ceabd38952b943b25d83a6efb0cf78d /Modules/FindQt4.cmake
parent6c8d8afe344aa2e0ba0c5c881d397a28a559dcbd (diff)
downloadCMake-e3b5eb6b23e5d2b6034e1c13716abb73ab6b3397.zip
CMake-e3b5eb6b23e5d2b6034e1c13716abb73ab6b3397.tar.gz
CMake-e3b5eb6b23e5d2b6034e1c13716abb73ab6b3397.tar.bz2
Automatically link to the qtmain library when linking to QtCore.
When using QAxServer, ensure that the qtmain library is excluded by reporting an error at CMake time if it is not.
Diffstat (limited to 'Modules/FindQt4.cmake')
-rw-r--r--Modules/FindQt4.cmake28
1 files changed, 28 insertions, 0 deletions
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index 7baa11b..35420b4 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -65,6 +65,12 @@
# is much more flexible, but requires that FindQt4.cmake is executed before
# such an exported dependency file is processed.
#
+# Note that if using IMPORTED targets, the qtmain.lib static library is
+# automatically linked on Windows. To disable that globally, set the
+# QT4_NO_LINK_QTMAIN variable before finding Qt4. To disable that for a
+# particular executable, set the QT4_NO_LINK_QTMAIN target property to
+# True on the executable.
+#
# QT_INCLUDE_DIRS_NO_SYSTEM
# If this variable is set to TRUE, the Qt include directories
# in the QT_USE_FILE will NOT have the SYSTEM keyword set.
@@ -1009,7 +1015,14 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
# platform dependent libraries
if(Q_WS_WIN)
_QT4_ADJUST_LIB_VARS(qtmain)
+
_QT4_ADJUST_LIB_VARS(QAxServer)
+ set_property(TARGET Qt4::QAxServer PROPERTY
+ INTERFACE_QT4_NO_LINK_QTMAIN ON
+ )
+ set_property(TARGET Qt4::QAxServer APPEND PROPERTY
+ COMPATIBLE_INTERFACE_BOOL QT4_NO_LINK_QTMAIN)
+
_QT4_ADJUST_LIB_VARS(QAxContainer)
endif()
@@ -1049,6 +1062,21 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
_qt4_add_target_private_depends(phonon DBus)
endif()
+ if (WIN32 AND NOT QT4_NO_LINK_QTMAIN)
+ set(_isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
+ set(_isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>)
+ set(_isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:QT4_NO_LINK_QTMAIN>>>)
+ set(_isPolicyNEW $<TARGET_POLICY:CMP0020>)
+ set_property(TARGET Qt4::QtCore APPEND PROPERTY
+ IMPORTED_LINK_INTERFACE_LIBRARIES
+ $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt4::qtmain>
+ )
+ unset(_isExe)
+ unset(_isWin32)
+ unset(_isNotExcluded)
+ unset(_isPolicyNEW)
+ endif()
+
#######################################
#
# Check the executables of Qt