aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2018-01-18 10:51:18 -0800
committerGitHub <noreply@github.com>2018-01-18 10:51:18 -0800
commitd35866018a43c108b2fa04587917c8d53740d4e6 (patch)
treec0f4ea145071bc6da23a99862b5004e2b6ed6af0 /scripts
parentb4c041df93663f1abc82d0cfb79420fc02d4546e (diff)
parentb47b4346f8c5b09cfb9826a083fc2d034a2ea9b4 (diff)
downloadvcpkg-d35866018a43c108b2fa04587917c8d53740d4e6.tar.gz
vcpkg-d35866018a43c108b2fa04587917c8d53740d4e6.zip
Merge pull request #1993 from Barath-Kannan/qt5_modular
Qt5 modular
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cmake/vcpkg_build_qmake.cmake83
-rw-r--r--scripts/cmake/vcpkg_common_functions.cmake1
-rw-r--r--scripts/cmake/vcpkg_configure_qmake.cmake41
-rw-r--r--scripts/cmake/vcpkg_replace_string.cmake14
4 files changed, 107 insertions, 32 deletions
diff --git a/scripts/cmake/vcpkg_build_qmake.cmake b/scripts/cmake/vcpkg_build_qmake.cmake
index 1c6358654..194ab8206 100644
--- a/scripts/cmake/vcpkg_build_qmake.cmake
+++ b/scripts/cmake/vcpkg_build_qmake.cmake
@@ -1,32 +1,81 @@
#.rst:
# .. command:: vcpkg_build_qmake
#
-# Build a qmake-based project, previously configured using vcpkg_configure_qmake .
-# As the CONFIG qmake option is assumed to be "debug_and_release" (the default value on Windows, see [1]),
-# both the debug and release libraries are build in the same build tree.
+# Build a qmake-based project, previously configured using vcpkg_configure_qmake.
#
# ::
# vcpkg_build_qmake()
#
-#
-# [1] : http://doc.qt.io/qt-5/qmake-variable-reference.html
function(vcpkg_build_qmake)
+ cmake_parse_arguments(_csc "SKIP_MAKEFILES" "BUILD_LOGNAME" "TARGETS;RELEASE_TARGETS;DEBUG_TARGETS" ${ARGN})
vcpkg_find_acquire_program(JOM)
# Make sure that the linker finds the libraries used
- set(ENV_LIB_BACKUP ENV{LIB})
- set(ENV{LIB} "${CURRENT_INSTALLED_DIR}/lib;${CURRENT_INSTALLED_DIR}/debug/lib;$ENV{LIB}")
+ set(ENV_PATH_BACKUP "$ENV{PATH}")
- message(STATUS "Package ${TARGET_TRIPLET}")
- vcpkg_execute_required_process_repeat(
- COUNT 2
- COMMAND ${JOM}
- WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}
- LOGNAME package-${TARGET_TRIPLET}
- )
- message(STATUS "Package ${TARGET_TRIPLET} done")
+ set(DEBUG_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
+ set(RELEASE_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
+
+ file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR)
+
+ list(APPEND _csc_RELEASE_TARGETS ${_csc_TARGETS})
+ list(APPEND _csc_DEBUG_TARGETS ${_csc_TARGETS})
+
+ if(NOT _csc_BUILD_LOGNAME)
+ set(_csc_BUILD_LOGNAME build)
+ endif()
+
+ function(run_jom TARGETS LOG_PREFIX LOG_SUFFIX)
+ message(STATUS "Package ${LOG_PREFIX}-${TARGET_TRIPLET}-${LOG_SUFFIX}")
+ vcpkg_execute_required_process(
+ COMMAND ${JOM} ${TARGETS}
+ WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${LOG_SUFFIX}
+ LOGNAME package-${LOG_PREFIX}-${TARGET_TRIPLET}-${LOG_SUFFIX}
+ )
+ message(STATUS "Package ${LOG_PREFIX}-${TARGET_TRIPLET}-${LOG_SUFFIX} done")
+ endfunction()
+
+ # This fixes issues on machines with default codepages that are not ASCII compatible, such as some CJK encodings
+ set(ENV_CL_BACKUP "$ENV{_CL_}")
+ set(ENV{_CL_} "/utf-8")
+
+ #First generate the makefiles so we can modify them
+ set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/debug/lib;${CURRENT_INSTALLED_DIR}/debug/bin;${CURRENT_INSTALLED_DIR}/tools/qt5;${ENV_PATH_BACKUP}")
+ if(NOT _csc_SKIP_MAKEFILES)
+ run_jom(qmake_all makefiles dbg)
+
+ #Store debug makefiles path
+ file(GLOB_RECURSE DEBUG_MAKEFILES ${DEBUG_DIR}/*Makefile*)
+
+ foreach(DEBUG_MAKEFILE ${DEBUG_MAKEFILES})
+ file(READ "${DEBUG_MAKEFILE}" _contents)
+ string(REPLACE "zlib.lib" "zlibd.lib" _contents "${_contents}")
+ string(REPLACE "installed\\${TARGET_TRIPLET}\\lib" "installed\\${TARGET_TRIPLET}\\debug\\lib" _contents "${_contents}")
+ string(REPLACE "/LIBPATH:${NATIVE_INSTALLED_DIR}\\debug\\lib qtmaind.lib" "shell32.lib /LIBPATH:${NATIVE_INSTALLED_DIR}\\debug\\lib\\manual-link qtmaind.lib /LIBPATH:${NATIVE_INSTALLED_DIR}\\debug\\lib" _contents "${_contents}")
+ file(WRITE "${DEBUG_MAKEFILE}" "${_contents}")
+ endforeach()
+ endif()
+
+ run_jom("${_csc_DEBUG_TARGETS}" ${_csc_BUILD_LOGNAME} dbg)
+
+ set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/lib;${CURRENT_INSTALLED_DIR}/bin;${CURRENT_INSTALLED_DIR}/tools/qt5;${ENV_PATH_BACKUP}")
+ if(NOT _csc_SKIP_MAKEFILES)
+ run_jom(qmake_all makefiles rel)
+
+ #Store release makefile path
+ file(GLOB_RECURSE RELEASE_MAKEFILES ${RELEASE_DIR}/*Makefile*)
+
+ foreach(RELEASE_MAKEFILE ${RELEASE_MAKEFILES})
+ file(READ "${RELEASE_MAKEFILE}" _contents)
+ string(REPLACE "/LIBPATH:${NATIVE_INSTALLED_DIR}\\lib qtmain.lib" "shell32.lib /LIBPATH:${NATIVE_INSTALLED_DIR}\\lib\\manual-link qtmain.lib /LIBPATH:${NATIVE_INSTALLED_DIR}\\lib" _contents "${_contents}")
+ file(WRITE "${RELEASE_MAKEFILE}" "${_contents}")
+ endforeach()
+ endif()
+
+ run_jom("${_csc_RELEASE_TARGETS}" ${_csc_BUILD_LOGNAME} rel)
- # Restore the original value of ENV{LIB}
- set(ENV{LIB} ENV_LIB_BACKUP)
+ # Restore the original value of ENV{PATH}
+ set(ENV{PATH} "${ENV_PATH_BACKUP}")
+ set(ENV{_CL_} "${ENV_CL_BACKUP}")
endfunction()
diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake
index 7ef87f2ea..27dd0732d 100644
--- a/scripts/cmake/vcpkg_common_functions.cmake
+++ b/scripts/cmake/vcpkg_common_functions.cmake
@@ -21,3 +21,4 @@ include(vcpkg_copy_tool_dependencies)
include(vcpkg_get_program_files_32_bit)
include(vcpkg_get_program_files_platform_bitness)
include(vcpkg_get_windows_sdk)
+include(vcpkg_replace_string) \ No newline at end of file
diff --git a/scripts/cmake/vcpkg_configure_qmake.cmake b/scripts/cmake/vcpkg_configure_qmake.cmake
index 037197e48..4cc7bc9f7 100644
--- a/scripts/cmake/vcpkg_configure_qmake.cmake
+++ b/scripts/cmake/vcpkg_configure_qmake.cmake
@@ -2,11 +2,6 @@
# .. command:: vcpkg_configure_qmake
#
# Configure a qmake-based project.
-# It is assume that the qmake project CONFIG variable is
-# "debug_and_release" (the default value on Windows, see [1]).
-# Using this option, only one Makefile for building both Release and Debug
-# libraries is generated, that then can be run using the vcpkg_build_qmake
-# command.
#
# ::
# vcpkg_configure_qmake(SOURCE_PATH <pro_file_path>
@@ -17,28 +12,44 @@
# The path to the *.pro qmake project file.
# ``OPTIONS``
# The options passed to qmake.
-#
-# [1] : http://doc.qt.io/qt-5/qmake-variable-reference.html
function(vcpkg_configure_qmake)
cmake_parse_arguments(_csc "" "SOURCE_PATH" "OPTIONS" ${ARGN})
- # Find qmake exectuable
+ # Find qmake executable
find_program(QMAKE_COMMAND NAMES qmake.exe PATHS ${CURRENT_INSTALLED_DIR}/tools/qt5)
if(NOT QMAKE_COMMAND)
message(FATAL_ERROR "vcpkg_configure_qmake: unable to find qmake.")
endif()
+ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
+ list(APPEND _csc_OPTIONS CONFIG+=staticlib)
+ endif()
+
# Cleanup build directories
- file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET})
+ file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
- message(STATUS "Configuring ${TARGET_TRIPLET}")
- file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET})
+ configure_file(${CURRENT_INSTALLED_DIR}/tools/qt5/qt_release.conf ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/qt.conf)
+
+ message(STATUS "Configuring ${TARGET_TRIPLET}-rel")
+ file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process(
- COMMAND ${QMAKE_COMMAND} ${_csc_OPTIONS} -d ${_csc_SOURCE_PATH}
- WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}
- LOGNAME config-${TARGET_TRIPLET}
+ COMMAND ${QMAKE_COMMAND} CONFIG-=debug CONFIG+=release ${_csc_OPTIONS} -d ${_csc_SOURCE_PATH} -qtconf "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/qt.conf"
+ WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
+ LOGNAME config-${TARGET_TRIPLET}-rel
)
- message(STATUS "Configuring ${TARGET_TRIPLET} done")
+ message(STATUS "Configuring ${TARGET_TRIPLET}-rel done")
+
+ configure_file(${CURRENT_INSTALLED_DIR}/tools/qt5/qt_debug.conf ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/qt.conf)
+
+ message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
+ file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
+ vcpkg_execute_required_process(
+ COMMAND ${QMAKE_COMMAND} CONFIG-=release CONFIG+=debug ${_csc_OPTIONS} -d ${_csc_SOURCE_PATH} -qtconf "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/qt.conf"
+ WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
+ LOGNAME config-${TARGET_TRIPLET}-dbg
+ )
+ message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
+
endfunction() \ No newline at end of file
diff --git a/scripts/cmake/vcpkg_replace_string.cmake b/scripts/cmake/vcpkg_replace_string.cmake
new file mode 100644
index 000000000..3eb18d0bf
--- /dev/null
+++ b/scripts/cmake/vcpkg_replace_string.cmake
@@ -0,0 +1,14 @@
+#.rst:
+# .. command:: vcpkg_replace_string
+#
+# Replace a string in a file.
+#
+# ::
+# vcpkg_replace_string(filename match_string replace_string)
+#
+#
+function(vcpkg_replace_string filename match_string replace_string)
+ file(READ ${filename} _contents)
+ string(REPLACE "${match_string}" "${replace_string}" _contents "${_contents}")
+ file(WRITE ${filename} "${_contents}")
+endfunction()