summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-12-07 14:13:45 (GMT)
committerBrad King <brad.king@kitware.com>2017-12-07 14:13:45 (GMT)
commit066fe644ee4468bb59861ecb97306780b03fcade (patch)
treef7cea61a450d75c2147e98f9e64049dffeb9f06b
parentafae027d6398462906e762da29f306f41d21c6ee (diff)
parente4ccc68429d6a187f7e09d560a81e3b36cd06328 (diff)
downloadCMake-066fe644ee4468bb59861ecb97306780b03fcade.zip
CMake-066fe644ee4468bb59861ecb97306780b03fcade.tar.gz
CMake-066fe644ee4468bb59861ecb97306780b03fcade.tar.bz2
Merge branch 'automoc-apple-framework' into release-3.10
Merge-request: !1561
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx47
-rw-r--r--Tests/QtAutogen/CMakeLists.txt6
-rw-r--r--Tests/QtAutogen/macosFW/CMakeLists.txt20
-rw-r--r--Tests/QtAutogen/macosFW/src/CMakeLists.txt33
-rw-r--r--Tests/QtAutogen/macosFW/src/macos_fw_lib.cpp17
-rw-r--r--Tests/QtAutogen/macosFW/src/macos_fw_lib.h18
-rw-r--r--Tests/QtAutogen/macosFW/test/CMakeLists.txt19
-rw-r--r--Tests/QtAutogen/macosFW/test/testMacosFWLib.cpp42
-rw-r--r--Tests/QtAutogen/macosFW/test/testMacosFWLib.h7
9 files changed, 185 insertions, 24 deletions
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index c7550e6..b02d872 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -1046,40 +1046,39 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
target->Target->AddPreBuildCommand(cc);
} else {
- // Convert file dependencies std::set to std::vector
- std::vector<std::string> autogenDepends(autogenDependFiles.begin(),
- autogenDependFiles.end());
-
// Add link library target dependencies to the autogen target dependencies
- for (std::string const& config : configsList) {
- cmLinkImplementationLibraries const* libs =
- target->GetLinkImplementationLibraries(config);
- if (libs != nullptr) {
- for (cmLinkItem const& item : libs->Libraries) {
- cmGeneratorTarget const* libTarget = item.Target;
- if ((libTarget != nullptr) &&
- !StaticLibraryCycle(target, libTarget, config)) {
- std::string util;
- if (configsList.size() > 1) {
- util += "$<$<CONFIG:";
- util += config;
- util += ">:";
- }
- util += libTarget->GetName();
- if (configsList.size() > 1) {
- util += ">";
+ {
+ // add_dependencies/addUtility do not support generator expressions.
+ // We depend only on the libraries found in all configs therefore.
+ std::map<cmGeneratorTarget const*, std::size_t> commonTargets;
+ for (std::string const& config : configsList) {
+ cmLinkImplementationLibraries const* libs =
+ target->GetLinkImplementationLibraries(config);
+ if (libs != nullptr) {
+ for (cmLinkItem const& item : libs->Libraries) {
+ cmGeneratorTarget const* libTarget = item.Target;
+ if ((libTarget != nullptr) &&
+ !StaticLibraryCycle(target, libTarget, config)) {
+ // Increment target config count
+ commonTargets[libTarget]++;
}
- autogenDepends.push_back(util);
}
}
}
+ for (auto const& item : commonTargets) {
+ if (item.second == configsList.size()) {
+ autogenDependTargets.insert(item.first->Target);
+ }
+ }
}
// Create autogen target
cmTarget* autogenTarget = makefile->AddUtilityCommand(
autogenTargetName, true, workingDirectory.c_str(),
- /*byproducts=*/autogenProvides, autogenDepends, commandLines, false,
- autogenComment.c_str());
+ /*byproducts=*/autogenProvides,
+ std::vector<std::string>(autogenDependFiles.begin(),
+ autogenDependFiles.end()),
+ commandLines, false, autogenComment.c_str());
// Create autogen generator target
localGen->AddGeneratorTarget(
new cmGeneratorTarget(autogenTarget, localGen));
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 32c2950..dff9d0c 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -215,6 +215,12 @@ add_subdirectory(uicInclude)
add_subdirectory(objectLibrary)
# -- Test
+# MacOS Framework
+if(APPLE AND (NOT QT_TEST_VERSION STREQUAL 4))
+ add_subdirectory(macosFW)
+endif()
+
+# -- Test
# Source files with the same basename in different subdirectories
add_subdirectory(sameName)
diff --git a/Tests/QtAutogen/macosFW/CMakeLists.txt b/Tests/QtAutogen/macosFW/CMakeLists.txt
new file mode 100644
index 0000000..114d9ba
--- /dev/null
+++ b/Tests/QtAutogen/macosFW/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.8)
+project(macos-fw-test)
+
+find_package(Qt5Test REQUIRED)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
+set(CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
+
+if(POLICY CMP0042) # in CMake 3.0.0+
+ set (CMAKE_MACOSX_RPATH OFF) # otherwise ON by default
+endif(POLICY CMP0042)
+
+if(POLICY CMP0068) # in CMake 3.9+
+ cmake_policy(SET CMP0068 NEW)
+endif(POLICY CMP0068)
+
+add_subdirectory(src)
+add_subdirectory(test)
diff --git a/Tests/QtAutogen/macosFW/src/CMakeLists.txt b/Tests/QtAutogen/macosFW/src/CMakeLists.txt
new file mode 100644
index 0000000..a02be00
--- /dev/null
+++ b/Tests/QtAutogen/macosFW/src/CMakeLists.txt
@@ -0,0 +1,33 @@
+set(MACOS_FW_LIB_VERSION "0.1")
+set(MACOS_FW_LIB_SRCS
+ macos_fw_lib.cpp
+)
+set(MACOS_FW_LIB_HDRS
+ macos_fw_lib.h
+)
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+)
+
+add_library(macos_fw_lib SHARED
+ ${MACOS_FW_LIB_SRCS}
+ ${MACOS_FW_LIB_HDRS}
+)
+set_target_properties(macos_fw_lib PROPERTIES AUTOMOC TRUE)
+set_target_properties(macos_fw_lib PROPERTIES
+ CLEAN_DIRECT_OUTPUT 1
+ FRAMEWORK 1
+ FRAMEWORK_VERSION ${MACOS_FW_LIB_VERSION}
+ VERSION ${MACOS_FW_LIB_VERSION}
+ SOVERSION ${MACOS_FW_LIB_VERSION}
+ MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MACOS_FW_LIB_VERSION}
+ MACOSX_FRAMEWORK_IDENTIFIER org.macos.fw_lib
+ POSITION_INDEPENDENT_CODE ON
+ PUBLIC_HEADER "${MACOS_FW_LIB_HDRS}"
+)
+target_link_libraries(macos_fw_lib
+ Qt5::Core
+)
diff --git a/Tests/QtAutogen/macosFW/src/macos_fw_lib.cpp b/Tests/QtAutogen/macosFW/src/macos_fw_lib.cpp
new file mode 100644
index 0000000..881a8c9
--- /dev/null
+++ b/Tests/QtAutogen/macosFW/src/macos_fw_lib.cpp
@@ -0,0 +1,17 @@
+#include "macos_fw_lib.h"
+
+#include <QString>
+#include <QtGlobal>
+
+MacosFWLib::MacosFWLib()
+{
+}
+
+MacosFWLib::~MacosFWLib()
+{
+}
+
+QString MacosFWLib::qtVersionString() const
+{
+ return QString(qVersion());
+}
diff --git a/Tests/QtAutogen/macosFW/src/macos_fw_lib.h b/Tests/QtAutogen/macosFW/src/macos_fw_lib.h
new file mode 100644
index 0000000..e66e0ea
--- /dev/null
+++ b/Tests/QtAutogen/macosFW/src/macos_fw_lib.h
@@ -0,0 +1,18 @@
+#ifndef MACOSFWLIB_H
+#define MACOSFWLIB_H
+
+#include <QObject>
+#include <QString>
+
+class __attribute__((visibility("default"))) MacosFWLib : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit MacosFWLib();
+ ~MacosFWLib();
+
+ QString qtVersionString() const;
+};
+
+#endif // MACOSFWLIB_H
diff --git a/Tests/QtAutogen/macosFW/test/CMakeLists.txt b/Tests/QtAutogen/macosFW/test/CMakeLists.txt
new file mode 100644
index 0000000..521c184
--- /dev/null
+++ b/Tests/QtAutogen/macosFW/test/CMakeLists.txt
@@ -0,0 +1,19 @@
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../src
+)
+include_directories(SYSTEM
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+)
+
+set(testname AutomocMacosFWLib)
+add_executable(${testname} testMacosFWLib.cpp)
+set_target_properties(${testname} PROPERTIES AUTOMOC TRUE)
+target_link_libraries(${testname}
+ Qt5::Core
+ Qt5::Widgets
+ Qt5::Test
+ macos_fw_lib
+)
diff --git a/Tests/QtAutogen/macosFW/test/testMacosFWLib.cpp b/Tests/QtAutogen/macosFW/test/testMacosFWLib.cpp
new file mode 100644
index 0000000..3476d61
--- /dev/null
+++ b/Tests/QtAutogen/macosFW/test/testMacosFWLib.cpp
@@ -0,0 +1,42 @@
+#include <QObject>
+#include <QString>
+
+#include "macos_fw_lib.h"
+#include "testMacosFWLib.h"
+
+class TestMacosFWLib : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init() {}
+ void cleanup() {}
+
+ void testQtVersion();
+};
+
+void TestMacosFWLib::initTestCase()
+{
+}
+
+void TestMacosFWLib::cleanupTestCase()
+{
+}
+
+void TestMacosFWLib::testQtVersion()
+{
+ MacosFWLib* testLib = new MacosFWLib();
+ QVERIFY(testLib->qtVersionString().contains("5."));
+ testLib->deleteLater();
+}
+
+int main(int argc, char* argv[])
+{
+ QApplication app(argc, argv, false);
+ MacosFWLib testObject;
+ return QTest::qExec(&testObject, argc, argv);
+}
+
+#include "testMacosFWLib.moc"
diff --git a/Tests/QtAutogen/macosFW/test/testMacosFWLib.h b/Tests/QtAutogen/macosFW/test/testMacosFWLib.h
new file mode 100644
index 0000000..1fe8dae
--- /dev/null
+++ b/Tests/QtAutogen/macosFW/test/testMacosFWLib.h
@@ -0,0 +1,7 @@
+#ifndef TESTMACOSFWLIB_H
+#define TESTMACOSFWLIB_H
+
+#include "qapplication.h"
+#include <QtTest/QtTest>
+
+#endif // TESTMACOSFWLIB_H