summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-05-31 16:30:09 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-05-31 14:49:34 +0000
commitd53f22e2fbcd860622d4f51ab46dc821c17766a7 (patch)
treef409e90cad3ba879f29a27c9c1797978b3bc7264 /cmake
parentb99e4387f66fe8f89fb7470c0dec5f6378a94c7d (diff)
Improve qconfig.cpp generation
We used to copy a qconfig.cpp.in file verbatim. Add some plumbing to actually compute the strings and their lengths as it is done in qtbase/configure.pri. Also make sure to replace the hardcoded linux mkspec with one that is automatically determined. Of course both the detection of the mkspec, and the hardcoded strings for include, lib, etc. should be fixed in the future. This is a stepping stone to allow building a Qt application using the qmake built by CMake. Change-Id: I2e6754f44b20b09b09d14fd85785d56288e6517b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake73
1 files changed, 65 insertions, 8 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 184cb5e19f..ff430dd119 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -64,33 +64,41 @@ SET(CMAKE_INSTALL_RPATH "${_default_install_rpath}" CACHE PATH "RPATH for instal
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Platform define path, etc.
+set(QT_QMAKE_TARGET_MKSPEC "")
if(WIN32)
set(QT_DEFAULT_PLATFORM_DEFINITIONS UNICODE _UNICODE WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS WIN64 _WIN64)
endif()
if(MSVC)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/win32-msvc)
+ set(QT_QMAKE_TARGET_MKSPEC win32-msvc)
elseif(CLANG)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/win32-clang)
+ set(QT_QMAKE_TARGET_MKSPEC win32-clang)
elseif(MINGW)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/win32-g++)
+ set(QT_QMAKE_TARGET_MKSPEC win32-g++)
list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS _WIN32_WINNT=0x0601)
endif()
elseif(LINUX)
if(GCC)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/linux-g++)
+ set(QT_QMAKE_TARGET_MKSPEC linux-g++)
elseif(CLANG)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/linux-clang)
+ set(QT_QMAKE_TARGET_MKSPEC linux-clang)
endif()
elseif(ANDROID)
if(GCC)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/android-g++)
+ set(QT_QMAKE_TARGET_MKSPEC android-g++)
elseif(CLANG)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/android-clang)
+ set(QT_QMAKE_TARGET_MKSPEC android-clang)
endif()
elseif(APPLE)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/macx-clang)
+ set(QT_QMAKE_TARGET_MKSPEC macx-clang)
+endif()
+
+# TODO: Fixme to be correct.
+set(QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}")
+
+if(QT_QMAKE_TARGET_MKSPEC)
+ set(QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/${QT_QMAKE_TARGET_MKSPEC})
endif()
if(NOT DEFINED QT_DEFAULT_PLATFORM_DEFINITIONS)
@@ -2081,3 +2089,52 @@ function(qt_process_qlalr input_file_list consuming_target flags)
endforeach()
endfunction()
+macro(qt_add_string_to_qconfig_cpp str)
+ string(LENGTH "${str}" length)
+ string(APPEND QT_CONFIG_STRS " \"${str}\\0\"\n")
+ string(APPEND QT_CONFIG_STR_OFFSETS " ${QT_CONFIG_STR_OFFSET},\n")
+ math(EXPR QT_CONFIG_STR_OFFSET "${QT_CONFIG_STR_OFFSET}+${length}+1")
+endmacro()
+
+function(qt_generate_qconfig_cpp)
+ set(QT_CONFIG_STR_OFFSET "0")
+ set(QT_CONFIG_STR_OFFSETS "")
+ set(QT_CONFIG_STRS "")
+
+ # Start first part.
+ qt_add_string_to_qconfig_cpp("doc")
+ qt_add_string_to_qconfig_cpp("include")
+ qt_add_string_to_qconfig_cpp("lib")
+ qt_add_string_to_qconfig_cpp("libexec")
+ qt_add_string_to_qconfig_cpp("bin")
+ qt_add_string_to_qconfig_cpp("plugins")
+ qt_add_string_to_qconfig_cpp("imports")
+ qt_add_string_to_qconfig_cpp("qml")
+ qt_add_string_to_qconfig_cpp(".")
+ qt_add_string_to_qconfig_cpp(".")
+ qt_add_string_to_qconfig_cpp("translations")
+ qt_add_string_to_qconfig_cpp("examples")
+ qt_add_string_to_qconfig_cpp("tests")
+
+ # Save first part.
+ set(QT_CONFIG_STR_OFFSETS_FIRST "${QT_CONFIG_STR_OFFSETS}")
+ set(QT_CONFIG_STRS_FIRST "${QT_CONFIG_STRS}")
+
+ # Start second part.
+ set(QT_CONFIG_STR_OFFSETS "")
+ set(QT_CONFIG_STRS "")
+
+ qt_add_string_to_qconfig_cpp("")
+ qt_add_string_to_qconfig_cpp("false")
+ qt_add_string_to_qconfig_cpp("bin")
+ qt_add_string_to_qconfig_cpp("lib")
+ qt_add_string_to_qconfig_cpp(".")
+ qt_add_string_to_qconfig_cpp("${QT_QMAKE_TARGET_MKSPEC}")
+ qt_add_string_to_qconfig_cpp("${QT_QMAKE_HOST_MKSPEC}")
+
+ # Save second part.
+ set(QT_CONFIG_STR_OFFSETS_SECOND "${QT_CONFIG_STR_OFFSETS}")
+ set(QT_CONFIG_STRS_SECOND "${QT_CONFIG_STRS}")
+
+ configure_file(global/qconfig.cpp.in global/qconfig.cpp @ONLY)
+endfunction()