Skip to content

Instantly share code, notes, and snippets.

@cristianadam
Last active May 4, 2021 13:30
Show Gist options
  • Save cristianadam/0c19752cabd818b13efa954538f5e81b to your computer and use it in GitHub Desktop.
Save cristianadam/0c19752cabd818b13efa954538f5e81b to your computer and use it in GitHub Desktop.
Script that builds Qt6. Run as: cmake -P configure-qt.cmake msvc "qtbase;qtdeclarative;qttools" and so on.
if (CMAKE_ARGC LESS 4)
message("Usage cmake -P " ${CMAKE_ARGV2} " <platform e.g. mingw/msvc> <module;list>")
return()
endif()
if (CMAKE_ARGV3 STREQUAL "clang")
set(ENV{CC} clang)
set(ENV{CXX} clang++)
endif()
foreach(module ${CMAKE_ARGV4})
execute_process(COMMAND
${CMAKE_COMMAND} -E time
${CMAKE_COMMAND}
-D "CMAKE_PREFIX_PATH=c:/llvm/qt/${CMAKE_ARGV3};${CMAKE_CURRENT_LIST_DIR}/install-${CMAKE_ARGV3}"
-D "CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_LIST_DIR}/install-${CMAKE_ARGV3}"
-G Ninja
-D CMAKE_BUILD_TYPE=Release
-D QT_BUILD_EXAMPLES=OFF
-D QT_BUILD_TESTS=ON
-D FEATURE_system_zlib=OFF
-D FEATURE_sql_mysql=OFF
-D FEATURE_sql_odbc=OFF
-D FEATURE_sql_psql=OFF
-D FEATURE_system_sqlite=OFF
-D INPUT_harfbuzz=qt
-D INPUT_pcre=qt
-D INPUT_freetype=qt
-D INPUT_libpng=qt
-D INPUT_libjpeg=qt
-S repo/${module}
-B build-${CMAKE_ARGV3}-${module}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Failed to configure ${module}.")
endif()
execute_process(COMMAND
${CMAKE_COMMAND} -E time
${CMAKE_COMMAND}
--build build-${CMAKE_ARGV3}-${module}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Failed to build ${module}.")
endif()
execute_process(COMMAND
${CMAKE_COMMAND} -E time
${CMAKE_COMMAND}
--install build-${CMAKE_ARGV3}-${module}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Failed to install ${module}.")
endif()
endforeach()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment