Skip to content

Instantly share code, notes, and snippets.

@cristianadam
cristianadam / configure-qt.cmake
Last active May 4, 2021 13:30
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()
@cristianadam
cristianadam / configure-small.cmake
Last active April 5, 2022 10:21
Qt Creator CMake configuration for a small build
if (CMAKE_ARGC LESS 4)
message("Usage cmake -P " ${CMAKE_ARGV2} " <platform e.g. mingw/msvc>")
return()
endif()
if (CMAKE_ARGV3 STREQUAL "mingw")
set(QT_PLATFORM mingw_64)
elseif(CMAKE_ARGV3 STREQUAL "msvc")
set(QT_PLATFORM msvc2019_64)
endif()
@cristianadam
cristianadam / PreLoad.cmake
Created December 15, 2020 11:51
PreLoad.cmake to add to your sources so that CMake would create fileApi JSON files for your IDE's CMake project loading
foreach(file cache-v2 cmakeFiles-v1 codemodel-v2)
file(WRITE "${CMAKE_BINARY_DIR}/.cmake/api/v1/query/${file}" "")
endforeach()
@cristianadam
cristianadam / download_qt5.cmake
Created October 30, 2020 10:31
CMake script to download qt5. Just need to run `cmake -P download_qt5.cmake`. Tested on Windows, Linux, macOS. For Mingw use `cmake -P download_qt5.cmake mingw`
set(qt_version "5.15.1")
string(REPLACE "." "" qt_version_dotless "${qt_version}")
if (WIN32)
set(url_os "windows_x86")
if (CMAKE_ARG_3 STREQUAL "mingw")
set(qt_package_arch_suffix "win64_mingw81")
set(qt_dir_prefix "${qt_version}/mingw81_64")
set(qt_package_suffix "-Windows-Windows_10-Mingw-Windows-Windows_10-X86_64")
else()
@cristianadam
cristianadam / download_qt6.cmake
Last active February 13, 2023 17:55
CMake script to download qt6 snapshots and examples. Just need to run cmake -P download_qt6.cmake. Tested on Windows, Linux, macOS.
set(qt_version 6.4.2)
string(REPLACE "." "" qt_version_dotless "${qt_version}")
if (WIN32)
set(url_os "windows_x86")
set(qt_package_arch_suffix "win64_msvc2019_64")
set(qt_dir_prefix "${qt_version}/msvc2019_64")
set(qt_package_suffix "-Windows-Windows_10_21H2-MSVC2019-Windows-Windows_10_21H2-X86_64")
elseif(APPLE)
set(url_os "mac_x64")
@cristianadam
cristianadam / macOS-on-VirtualBox.md
Last active September 12, 2021 05:54
Push-button installer of macOS on VirtualBox
@cristianadam
cristianadam / ccache-master-clang9-include_mtime.log
Created July 26, 2020 17:48
ccache master running with a CMake project having precompiled headers and Clang-Mingw 9 (include_mtime)
[.696641 8612 ] === CCACHE master.1cbaa89d STARTED =========================================
[.696641 8612 ] failed to rename C:/Projects/github/ccache-test/.ccache/stats to C:/Projects/github/ccache-test/.ccache/stats.ccache.rm.tmp: The system cannot find the file specified.
(2)
[.697640 8612 ] Unlink C:/Projects/github/ccache-test/.ccache/stats via C:/Projects/github/ccache-test/.ccache/stats.ccache.rm.tmp
[.697640 8612 ] Unlink failed: Invalid argument
[.765881 19292] === CCACHE master.1cbaa89d STARTED =========================================
[.765881 19292] Config: (environment) base_dir = C:/Projects/github/ccache-test
[.765881 19292] Config: (environment) cache_dir = C:/Projects/github/ccache-test/.ccache
[.765881 19292] Config: (default) cache_dir_levels = 2
@cristianadam
cristianadam / ccache-master-clang9.log
Created July 26, 2020 17:46
ccache master running with a CMake project having precompiled headers and Clang-Mingw 9
[.942520 16720] === CCACHE master.1cbaa89d STARTED =========================================
[.943504 16720] failed to rename C:/Projects/github/ccache-test/.ccache/stats to C:/Projects/github/ccache-test/.ccache/stats.ccache.rm.tmp: The system cannot find the file specified.
(2)
[.943504 16720] Unlink C:/Projects/github/ccache-test/.ccache/stats via C:/Projects/github/ccache-test/.ccache/stats.ccache.rm.tmp
[.943504 16720] Unlink failed: Invalid argument
[.011564 6596 ] === CCACHE master.1cbaa89d STARTED =========================================
[.011564 6596 ] Config: (environment) base_dir = C:/Projects/github/ccache-test
[.011564 6596 ] Config: (environment) cache_dir = C:/Projects/github/ccache-test/.ccache
[.011564 6596 ] Config: (default) cache_dir_levels = 2
@cristianadam
cristianadam / build-source-directory.cmake
Last active July 23, 2020 09:46
CMake Script which builds all source files into one executable. Directory name is set as the name of the project.
cmake_minimum_required(VERSION 3.15)
get_filename_component(name ${CMAKE_CURRENT_LIST_DIR} NAME)
project(${name})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Get all source files, CONFIGURE_DEPENDS makes sure that if you add
# new files and build, they will be picked up. Tested with Ninja
@cristianadam
cristianadam / setup_android.cmake
Last active July 21, 2022 12:55
CMake script to download OpenJDK and Android Command Line Tools. Execute with: cmake -P setup_android.cmake
# CMake script to download OpenJDK and Android Command Line Tools.
# Execute with: cmake -P setup_android.cmake
# Tested with Qt 6.3.1 and Qt Creator 8.0
set(JDK_VERSION "11.0.9.1+1")
set(ANDROID_CMDTOOLS_VERSION "8092744")
set(ANDROID_PLATFORM "android-31")
set(BUILD_TOOLS "31.0.0")