2017-01-06 06:38:01 +08:00
|
|
|
#.rst:
|
|
|
|
# .. command:: vcpkg_build_qmake
|
|
|
|
#
|
2018-01-18 23:36:07 +08:00
|
|
|
# Build a qmake-based project, previously configured using vcpkg_configure_qmake.
|
2017-01-06 06:38:01 +08:00
|
|
|
#
|
|
|
|
# ::
|
|
|
|
# vcpkg_build_qmake()
|
|
|
|
#
|
|
|
|
|
|
|
|
function(vcpkg_build_qmake)
|
2018-01-18 23:36:07 +08:00
|
|
|
cmake_parse_arguments(_csc "SKIP_MAKEFILES" "BUILD_LOGNAME" "TARGETS;RELEASE_TARGETS;DEBUG_TARGETS" ${ARGN})
|
2019-03-14 21:33:48 +08:00
|
|
|
|
|
|
|
if(CMAKE_HOST_WIN32)
|
2019-06-20 03:08:02 +08:00
|
|
|
set(_PATHSEP ";")
|
2019-03-14 21:33:48 +08:00
|
|
|
vcpkg_find_acquire_program(JOM)
|
|
|
|
set(INVOKE "${JOM}")
|
|
|
|
else()
|
2019-06-20 03:08:02 +08:00
|
|
|
set(_PATHSEP ":")
|
2019-03-14 21:33:48 +08:00
|
|
|
find_program(MAKE make)
|
|
|
|
set(INVOKE "${MAKE}")
|
|
|
|
endif()
|
2017-01-06 06:38:01 +08:00
|
|
|
|
|
|
|
# Make sure that the linker finds the libraries used
|
2017-10-16 20:04:16 +08:00
|
|
|
set(ENV_PATH_BACKUP "$ENV{PATH}")
|
2017-01-06 06:38:01 +08:00
|
|
|
|
2019-05-01 00:29:41 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
|
|
set(DEBUG_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
|
|
|
set(RELEASE_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
|
|
|
|
endif()
|
2018-01-18 23:36:07 +08:00
|
|
|
|
|
|
|
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR)
|
|
|
|
|
2019-05-01 00:29:41 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
|
|
|
list(APPEND _csc_RELEASE_TARGETS ${_csc_TARGETS})
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
|
|
|
list(APPEND _csc_DEBUG_TARGETS ${_csc_TARGETS})
|
|
|
|
endif()
|
2018-01-18 23:36:07 +08:00
|
|
|
|
|
|
|
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(
|
2019-03-14 21:33:48 +08:00
|
|
|
COMMAND ${INVOKE} ${TARGETS}
|
2018-01-18 23:36:07 +08:00
|
|
|
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${LOG_SUFFIX}
|
|
|
|
LOGNAME package-${LOG_PREFIX}-${TARGET_TRIPLET}-${LOG_SUFFIX}
|
|
|
|
)
|
|
|
|
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
|
2019-05-01 00:29:41 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
2019-06-20 03:08:02 +08:00
|
|
|
set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/debug/lib${_PATHSEP}${CURRENT_INSTALLED_DIR}/debug/bin${_PATHSEP}${CURRENT_INSTALLED_DIR}/tools/qt5${_PATHSEP}${ENV_PATH_BACKUP}")
|
2019-05-01 00:29:41 +08:00
|
|
|
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" "/LIBPATH:${NATIVE_INSTALLED_DIR}\\debug\\lib\\manual-link /LIBPATH:${NATIVE_INSTALLED_DIR}\\debug\\lib shell32.lib" _contents "${_contents}")
|
|
|
|
string(REPLACE "tools\\qt5\\qmlcachegen.exe" "tools\\qt5-declarative\\qmlcachegen.exe" _contents "${_contents}")
|
|
|
|
string(REPLACE "tools/qt5/qmlcachegen" "tools/qt5-declarative/qmlcachegen" _contents "${_contents}")
|
|
|
|
string(REPLACE "debug\\lib\\Qt5Bootstrap.lib" "tools\\qt5\\Qt5Bootstrap.lib" _contents "${_contents}")
|
|
|
|
string(REPLACE "lib\\Qt5Bootstrap.lib" "tools\\qt5\\Qt5Bootstrap.lib" _contents "${_contents}")
|
|
|
|
string(REPLACE " Qt5Bootstrap.lib " " ${NATIVE_INSTALLED_DIR}\\tools\\qt5\\Qt5Bootstrap.lib Ole32.lib Netapi32.lib Advapi32.lib ${NATIVE_INSTALLED_DIR}\\lib\\zlib.lib Shell32.lib " _contents "${_contents}")
|
|
|
|
file(WRITE "${DEBUG_MAKEFILE}" "${_contents}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
run_jom("${_csc_DEBUG_TARGETS}" ${_csc_BUILD_LOGNAME} dbg)
|
2018-01-18 23:36:07 +08:00
|
|
|
endif()
|
|
|
|
|
2019-05-01 00:29:41 +08:00
|
|
|
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
2019-06-20 03:08:02 +08:00
|
|
|
set(ENV{PATH} "${CURRENT_INSTALLED_DIR}/lib${_PATHSEP}${CURRENT_INSTALLED_DIR}/bin${_PATHSEP}${CURRENT_INSTALLED_DIR}/tools/qt5${_PATHSEP}${ENV_PATH_BACKUP}")
|
2019-05-01 00:29:41 +08:00
|
|
|
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" "/LIBPATH:${NATIVE_INSTALLED_DIR}\\lib\\manual-link /LIBPATH:${NATIVE_INSTALLED_DIR}\\lib shell32.lib" _contents "${_contents}")
|
|
|
|
string(REPLACE "tools\\qt5\\qmlcachegen.exe" "tools\\qt5-declarative\\qmlcachegen.exe" _contents "${_contents}")
|
|
|
|
string(REPLACE "tools/qt5/qmlcachegen" "tools/qt5-declarative/qmlcachegen" _contents "${_contents}")
|
|
|
|
string(REPLACE "debug\\lib\\Qt5Bootstrap.lib" "tools\\qt5\\Qt5Bootstrap.lib" _contents "${_contents}")
|
|
|
|
string(REPLACE "lib\\Qt5Bootstrap.lib" "tools\\qt5\\Qt5Bootstrap.lib" _contents "${_contents}")
|
|
|
|
string(REPLACE " Qt5Bootstrap.lib " " ${NATIVE_INSTALLED_DIR}\\tools\\qt5\\Qt5Bootstrap.lib Ole32.lib Netapi32.lib Advapi32.lib ${NATIVE_INSTALLED_DIR}\\lib\\zlib.lib Shell32.lib " _contents "${_contents}")
|
|
|
|
file(WRITE "${RELEASE_MAKEFILE}" "${_contents}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
run_jom("${_csc_RELEASE_TARGETS}" ${_csc_BUILD_LOGNAME} rel)
|
2018-01-18 23:36:07 +08:00
|
|
|
endif()
|
2017-01-06 06:38:01 +08:00
|
|
|
|
2017-10-15 21:40:25 +08:00
|
|
|
# Restore the original value of ENV{PATH}
|
2017-10-16 20:04:16 +08:00
|
|
|
set(ENV{PATH} "${ENV_PATH_BACKUP}")
|
2018-01-18 23:36:07 +08:00
|
|
|
set(ENV{_CL_} "${ENV_CL_BACKUP}")
|
2017-01-06 06:38:01 +08:00
|
|
|
endfunction()
|