aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/CMakeLists.txt
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@qt.io>2022-04-21 14:10:09 +0200
committerCristian Adam <cristian.adam@qt.io>2022-04-29 07:16:53 +0000
commit88781a003ffd5f699f70b06d2d99325cf4e60c0f (patch)
tree2b4c888fbcdf57a870302d4d6e68cefef7e19a62 /src/app/CMakeLists.txt
parent58b0a5056c3afe922a2fe8570735da03fb9c3db5 (diff)
CMake: Qt Creator Static build support
This adds the build system feature that allows Qt Creator's libraries and plugins to be compiled statically. Fixes some symbol clashes when all plugins are linked into the same executable. Support for actually loading static plugins will be added in a separate commit. The feature is controlled by QTC_STATIC_BUILD which by default is OFF. Change-Id: I1fab7953c43e42dc75619e35660029ee067106df Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/app/CMakeLists.txt')
-rw-r--r--src/app/CMakeLists.txt33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt
index e30d9fe6ab..58fa147c51 100644
--- a/src/app/CMakeLists.txt
+++ b/src/app/CMakeLists.txt
@@ -35,6 +35,39 @@ if (NOT TARGET qtcreator)
return()
endif()
+if (QTC_STATIC_BUILD)
+ set(plugins_to_import "")
+ set(source_file_content "#include <QtPlugin>\n")
+ foreach(plugin IN LISTS __QTC_PLUGINS)
+ if(TARGET ${plugin})
+ list(APPEND plugins_to_import "${plugin}")
+ # TODO ${plugin}Plugin is not correct for all plugins as the class name
+ get_target_property(plugin_class ${plugin} QTC_PLUGIN_CLASS_NAME)
+ string(APPEND source_file_content "Q_IMPORT_PLUGIN(${plugin_class})\n")
+ endif()
+ endforeach()
+
+ string(APPEND source_file_content
+ "struct ResourcesInitializer {\n"
+ " ResourcesInitializer() {\n")
+ foreach(resource_file IN LISTS __QTC_RESOURCE_FILES)
+ string(APPEND source_file_content " Q_INIT_RESOURCE(${resource_file});\n")
+ endforeach()
+ string(APPEND source_file_content
+ " }\n"
+ "} g_resources_initializer;\n")
+
+ file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/plugin_imports.cpp"
+ CONTENT "${source_file_content}"
+ )
+ extend_qtc_target(qtcreator
+ DEPENDS ${plugins_to_import}
+ SOURCES "${CMAKE_CURRENT_BINARY_DIR}/plugin_imports.cpp"
+ )
+
+endif()
+
if (WIN32)
set(RC_APPLICATION_NAME "${IDE_DISPLAY_NAME}")
set(RC_VERSION "${IDE_VERSION}.0")