From bd5096d012327d4acb44449464cb00c488450cc5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 17:05:41 +0100 Subject: Add the QtMain windows library to the CMake files. Change-Id: Iff8b9bdd4b069721103e1cd5854e56b6116d7549 Reviewed-by: Andreas Holzammer Reviewed-by: Oswald Buddenhagen Reviewed-by: Alexander Neundorf Reviewed-by: Stephen Kelly --- mkspecs/features/create_cmake.prf | 9 +++++ src/corelib/Qt5CoreConfigExtras.cmake.in | 23 +++++++++++++ tests/manual/cmake/CMakeLists.txt | 1 + tests/manual/cmake/pass8/CMakeLists.txt | 20 +++++++++++ tests/manual/cmake/pass8/myobject.cpp | 54 ++++++++++++++++++++++++++++++ tests/manual/cmake/pass8/myobject.h | 57 ++++++++++++++++++++++++++++++++ 6 files changed, 164 insertions(+) create mode 100644 tests/manual/cmake/pass8/CMakeLists.txt create mode 100644 tests/manual/cmake/pass8/myobject.cpp create mode 100644 tests/manual/cmake/pass8/myobject.h diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 3ae4ddc83b..1f9eded772 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -58,6 +58,15 @@ macx { CMAKE_IMPLIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}$$eval(QT.$${MODULE}.MAJOR_VERSION).lib } CMAKE_BIN_SUFFIX = ".exe" + + CMAKE_WINDOWS_BUILD = "true" + win32-g++ { + CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}d.a + CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a + } else { + CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}d.lib + CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib + } } else { !isEmpty(CMAKE_STATIC_TYPE) { CMAKE_LIB_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.a diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 4b5ac73bce..4873391f52 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -20,3 +20,26 @@ list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) !!IF !isEmpty(QT_LIBINFIX) set(QT_LIBINFIX \"$${QT_LIBINFIX}\") !!ENDIF + +!!IF !isEmpty(CMAKE_WINDOWS_BUILD) +set(Qt5Core_QTMAIN_LIBRARIES Qt5::WinMain) + +if (NOT _Qt5WinMain_target) + set(_Qt5WinMain_target 1) + add_library(Qt5::WinMain STATIC IMPORTED) +endif() + +!!IF !isEmpty(debug_type) +set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(Qt5::WinMain PROPERTIES + IMPORTED_LOCATION_DEBUG "${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}" +) +!!ENDIF + +!!IF !isEmpty(release_type) +set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(Qt5::WinMain PROPERTIES + IMPORTED_LOCATION_RELEASE \"${_qt5_install_prefix}/$$CMAKE_LIB_DIR/$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\" +) +!!ENDIF +!!ENDIF diff --git a/tests/manual/cmake/CMakeLists.txt b/tests/manual/cmake/CMakeLists.txt index 930936a7b5..2d0164a47b 100644 --- a/tests/manual/cmake/CMakeLists.txt +++ b/tests/manual/cmake/CMakeLists.txt @@ -88,3 +88,4 @@ expect_fail(fail4) expect_fail(fail5) expect_pass("pass(needsquoting)6") expect_pass(pass7) +expect_pass(pass8) diff --git a/tests/manual/cmake/pass8/CMakeLists.txt b/tests/manual/cmake/pass8/CMakeLists.txt new file mode 100644 index 0000000000..735b1bd26e --- /dev/null +++ b/tests/manual/cmake/pass8/CMakeLists.txt @@ -0,0 +1,20 @@ + +cmake_minimum_required(VERSION 2.8) + +project(pass8) + +find_package(Qt5Core REQUIRED) + +include_directories(${Qt5Core_INCLUDE_DIRS}) + +add_definitions(${Qt5Core_DEFINITIONS}) + +qt5_wrap_cpp(moc_files myobject.h) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +# On non-windows, the WIN32 is harmless, and Qt5Core_QTMAIN_LIBRARIES is empty. +# We test that it is harmless on those, and test that it builds on Windows. +# It wouldn't build if WIN32 is used and Qt5Core_QTMAIN_LIBRARIES is empty. +add_executable(myobject WIN32 myobject.cpp ${moc_files} ) +target_link_libraries(myobject ${Qt5Core_LIBRARIES} ${Qt5Core_QTMAIN_LIBRARIES}) diff --git a/tests/manual/cmake/pass8/myobject.cpp b/tests/manual/cmake/pass8/myobject.cpp new file mode 100644 index 0000000000..b6287b2540 --- /dev/null +++ b/tests/manual/cmake/pass8/myobject.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myobject.h" + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + MyObject myObject; + return 0; +} diff --git a/tests/manual/cmake/pass8/myobject.h b/tests/manual/cmake/pass8/myobject.h new file mode 100644 index 0000000000..71a65ee801 --- /dev/null +++ b/tests/manual/cmake/pass8/myobject.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYOBJECT_H +#define MYOBJECT_H + +#include + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0); + +signals: + void someSignal(); +}; + +#endif -- cgit v1.2.3