Skip to content

Commit

Permalink
[qt5] Add -j to make to parallelize on Linux and MacOS (#11111)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal committed May 4, 2020
1 parent 48decf7 commit 7db401c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 45 deletions.
2 changes: 1 addition & 1 deletion ports/qt5-base/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: qt5-base
Version: 5.12.8
Version: 5.12.8-2
Homepage: https://www.qt.io/
Description: Qt5 Application Framework Base Module. Includes Core, GUI, Widgets, Networking, SQL, Concurrent and other essential qt components.
Build-Depends: zlib, libjpeg-turbo, libpng, freetype, pcre2, harfbuzz, sqlite3, libpq, double-conversion, openssl, angle (!windows), egl-registry, icu (!uwp), fontconfig (!windows)
Expand Down
43 changes: 7 additions & 36 deletions ports/qt5-base/cmake/install_qt.cmake
Original file line number Diff line number Diff line change
@@ -1,38 +1,12 @@
include(qt_fix_makefile_install)

function(install_qt)
cmake_parse_arguments(_bc "DISABLE_PARALLEL" "" "" ${ARGN})

if (_bc_DISABLE_PARALLEL)
set(NUMBER_OF_PROCESSORS "1")
else()
if(DEFINED ENV{NUMBER_OF_PROCESSORS})
set(NUMBER_OF_PROCESSORS $ENV{NUMBER_OF_PROCESSORS})
elseif(VCPKG_TARGET_IS_OSX)
execute_process(
COMMAND sysctl -n hw.ncpu
OUTPUT_VARIABLE NUMBER_OF_PROCESSORS
)
string(REPLACE "\n" "" NUMBER_OF_PROCESSORS "${NUMBER_OF_PROCESSORS}")
string(REPLACE " " "" NUMBER_OF_PROCESSORS "${NUMBER_OF_PROCESSORS}")
else()
execute_process(
COMMAND nproc
OUTPUT_VARIABLE NUMBER_OF_PROCESSORS
)
string(REPLACE "\n" "" NUMBER_OF_PROCESSORS "${NUMBER_OF_PROCESSORS}")
string(REPLACE " " "" NUMBER_OF_PROCESSORS "${NUMBER_OF_PROCESSORS}")
endif()
endif()

message(STATUS "NUMBER_OF_PROCESSORS is ${NUMBER_OF_PROCESSORS}")

if(CMAKE_HOST_WIN32)
vcpkg_find_acquire_program(JOM)
set(INVOKE "${JOM}" /J ${NUMBER_OF_PROCESSORS})
set(INVOKE "${JOM}" /J ${VCPKG_CONCURRENCY})
else()
find_program(MAKE make)
set(INVOKE "${MAKE}" -j${NUMBER_OF_PROCESSORS})
set(INVOKE "${MAKE}" -j${VCPKG_CONCURRENCY})
set(INVOKE_SINGLE "${MAKE}" -j1)
endif()
vcpkg_find_acquire_program(PYTHON3)
Expand Down Expand Up @@ -71,10 +45,10 @@ function(install_qt)
set(_build_type_${_buildname} "release")
endif()
unset(_buildname)

foreach(_buildname ${BUILDTYPES})
set(_build_triplet ${TARGET_TRIPLET}-${_short_name_${_buildname}})

vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${_path_suffix_${_buildname}}/bin")

if(VCPKG_TARGET_IS_OSX)
Expand All @@ -86,14 +60,14 @@ function(install_qt)
LOGNAME cleaning-1-${_build_triplet}
)
endif()

message(STATUS "Building ${_build_triplet}")
vcpkg_execute_required_process(
COMMAND ${INVOKE}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${_build_triplet}
LOGNAME build-${_build_triplet}
)

if(VCPKG_TARGET_IS_OSX)
# For some reason there will be an error on MacOSX without this clean!
message(STATUS "Cleaning after build before install ${_build_triplet}")
Expand All @@ -103,7 +77,7 @@ function(install_qt)
LOGNAME cleaning-2-${_build_triplet}
)
endif()

message(STATUS "Fixing makefile installation path ${_build_triplet}")
qt_fix_makefile_install("${CURRENT_BUILDTREES_DIR}/${_build_triplet}")
message(STATUS "Installing ${_build_triplet}")
Expand All @@ -115,7 +89,4 @@ function(install_qt)
message(STATUS "Package ${_build_triplet} done")
set(ENV{PATH} "${_path}")
endforeach()



endfunction()
15 changes: 7 additions & 8 deletions scripts/cmake/vcpkg_build_qmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# ::
# vcpkg_build_qmake()
#

function(vcpkg_build_qmake)
cmake_parse_arguments(_csc "SKIP_MAKEFILES" "BUILD_LOGNAME" "TARGETS;RELEASE_TARGETS;DEBUG_TARGETS" ${ARGN})

Expand All @@ -18,9 +17,9 @@ function(vcpkg_build_qmake)
set(INVOKE "${MAKE}")
endif()

# Make sure that the linker finds the libraries used
# Make sure that the linker finds the libraries used
set(ENV_PATH_BACKUP "$ENV{PATH}")

file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR)

if(NOT _csc_BUILD_LOGNAME)
Expand All @@ -30,7 +29,7 @@ function(vcpkg_build_qmake)
function(run_jom TARGETS LOG_PREFIX LOG_SUFFIX)
message(STATUS "Package ${LOG_PREFIX}-${TARGET_TRIPLET}-${LOG_SUFFIX}")
vcpkg_execute_required_process(
COMMAND ${INVOKE} ${TARGETS}
COMMAND ${INVOKE} -j ${VCPKG_CONCURRENCY} ${TARGETS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${LOG_SUFFIX}
LOGNAME package-${LOG_PREFIX}-${TARGET_TRIPLET}-${LOG_SUFFIX}
)
Expand All @@ -46,16 +45,16 @@ function(vcpkg_build_qmake)
set(_buildname "DEBUG")
list(APPEND BUILDTYPES ${_buildname})
set(_short_name_${_buildname} "dbg")
set(_path_suffix_${_buildname} "/debug")
set(_path_suffix_${_buildname} "/debug")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
set(_buildname "RELEASE")
list(APPEND BUILDTYPES ${_buildname})
set(_short_name_${_buildname} "rel")
set(_path_suffix_${_buildname} "")
set(_path_suffix_${_buildname} "")
endif()
unset(_buildname)

foreach(_buildname ${BUILDTYPES})
set(_BUILD_PREFIX "${_path_suffix_${_buildname}}")
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${_BUILD_PREFIX}/bin")
Expand All @@ -67,7 +66,7 @@ function(vcpkg_build_qmake)
run_jom("${_csc_${_buildname}_TARGETS}" ${_csc_BUILD_LOGNAME} ${_short_name_${_buildname}})
unset(_BUILD_PREFIX)
endforeach()

# Restore the original value of ENV{PATH}
set(ENV{PATH} "${ENV_PATH_BACKUP}")
set(ENV{_CL_} "${ENV_CL_BACKUP}")
Expand Down

0 comments on commit 7db401c

Please sign in to comment.