Unverified Commit d591d86f authored by Daniel Agar's avatar Daniel Agar Committed by GitHub

initial optional cmake support (#6862)

parent 7e616472
......@@ -3,7 +3,6 @@ libs/lib/Frameworks/GStreamer.framework
*.swp
*.nfs
CMakeFiles
*Makefile*
tags
build*/
Info.plist
......@@ -86,4 +85,6 @@ src/latex/
.vagrant/
Qt*-linux*.tar.*
.vs/
libs/airmapd/include/boost
This diff is collapsed.
......@@ -63,6 +63,36 @@ pipeline {
}
}
stage('Linux Debug (cmake)') {
environment {
CCACHE_BASEDIR = "${env.WORKSPACE}"
CMAKE_BUILD_TYPE = 'Debug'
QT_VERSION = "5.11.0"
QT_MKSPEC = "gcc_64"
}
agent {
docker {
image 'mavlink/qgc-build-linux:2018-06-07'
args '-v ${CCACHE_DIR}:${CCACHE_DIR}:rw'
}
}
steps {
sh 'export'
sh 'ccache -z'
sh 'make distclean'
sh 'make submodulesclean'
sh 'make linux'
//sh 'make linux check' // TODO: needs Xvfb or similar
sh 'ccache -s'
sh 'make distclean'
}
post {
cleanup {
sh 'git clean -ff -x -d .'
}
}
}
stage('Linux Release') {
environment {
CCACHE_BASEDIR = "${env.WORKSPACE}"
......@@ -95,6 +125,35 @@ pipeline {
}
}
stage('Linux Release (cmake)') {
environment {
CCACHE_BASEDIR = "${env.WORKSPACE}"
CMAKE_BUILD_TYPE = 'Release'
QT_VERSION = "5.11.0"
QT_MKSPEC = "gcc_64"
}
agent {
docker {
image 'mavlink/qgc-build-linux:2018-06-07'
args '-v ${CCACHE_DIR}:${CCACHE_DIR}:rw'
}
}
steps {
sh 'export'
sh 'ccache -z'
sh 'make distclean'
sh 'make submodulesclean'
sh 'make linux'
sh 'ccache -s'
sh 'make distclean'
}
post {
cleanup {
sh 'git clean -ff -x -d .'
}
}
}
stage('OSX Debug') {
agent {
node {
......@@ -123,6 +182,34 @@ pipeline {
}
}
stage('OSX Debug (cmake)') {
agent {
node {
label 'mac'
}
}
environment {
CCACHE_BASEDIR = "${env.WORKSPACE}"
CMAKE_BUILD_TYPE = 'Debug'
QT_VERSION = "5.11.0"
QT_MKSPEC = "clang_64"
}
steps {
sh 'export'
sh 'ccache -z'
sh 'make distclean'
sh 'make submodulesclean'
sh 'make mac'
sh 'ccache -s'
sh 'make distclean'
}
post {
cleanup {
sh 'git clean -ff -x -d .'
}
}
}
stage('OSX Release') {
agent {
node {
......@@ -175,6 +262,34 @@ pipeline {
}
}
stage('OSX Release (cmake)') {
agent {
node {
label 'mac'
}
}
environment {
CCACHE_BASEDIR = "${env.WORKSPACE}"
CMAKE_BUILD_TYPE = 'Release'
QT_VERSION = "5.11.0"
QT_MKSPEC = "clang_64"
}
steps {
sh 'export'
sh 'ccache -z'
sh 'make distclean'
sh 'make submodulesclean'
sh 'make mac'
sh 'ccache -s'
sh 'make distclean'
}
post {
cleanup {
sh 'git clean -ff -x -d .'
}
}
}
} // parallel
} // stage('build')
} // stages
......
# Enforce the presence of the GIT repository
#
# We depend on our submodules, so we have to prevent attempts to
# compile without it being present.
ifeq ($(wildcard .git),)
$(error YOU HAVE TO USE GIT TO DOWNLOAD THIS REPOSITORY. ABORTING.)
endif
# explicity set default build target
all: linux
# Parsing
# --------------------------------------------------------------------
# assume 1st argument passed is the main target, the
# rest are arguments to pass to the makefile generated
# by cmake in the subdirectory
FIRST_ARG := $(firstword $(MAKECMDGOALS))
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
j ?= 4
NINJA_BIN := ninja
ifndef NO_NINJA_BUILD
NINJA_BUILD := $(shell $(NINJA_BIN) --version 2>/dev/null)
ifndef NINJA_BUILD
NINJA_BIN := ninja-build
NINJA_BUILD := $(shell $(NINJA_BIN) --version 2>/dev/null)
endif
endif
ifdef NINJA_BUILD
PX4_CMAKE_GENERATOR := Ninja
PX4_MAKE := $(NINJA_BIN)
ifdef VERBOSE
PX4_MAKE_ARGS := -v
else
PX4_MAKE_ARGS :=
endif
else
ifdef SYSTEMROOT
# Windows
PX4_CMAKE_GENERATOR := "MSYS\ Makefiles"
else
PX4_CMAKE_GENERATOR := "Unix\ Makefiles"
endif
PX4_MAKE = $(MAKE)
PX4_MAKE_ARGS = -j$(j) --no-print-directory
endif
CMAKE_BUILD_TYPE ?= RelWithDebInfo
SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Functions
# --------------------------------------------------------------------
# describe how to build a cmake config
define cmake-build
+@$(eval BUILD_DIR = $(SRC_DIR)/build/$@$(BUILD_DIR_SUFFIX))
+@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e $(BUILD_DIR)/Makefile ]; then rm -rf $(BUILD_DIR); fi
+@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(2) -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -G"$(PX4_CMAKE_GENERATOR)" -DQT_MKSPEC=$(1) || (rm -rf $(BUILD_DIR)); fi
+@(cd $(BUILD_DIR) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS))
endef
# Qt mkspec
# android_armv7 android_x86 gcc_64
gcc_64:
$(call cmake-build,$@,$(SRC_DIR))
android_armv7:
$(call cmake-build,$@,$(SRC_DIR))
android_x86:
$(call cmake-build,$@,$(SRC_DIR))
clang_64:
$(call cmake-build,$@,$(SRC_DIR))
xcode:
@mkdir -p build/xcode; cd build/xcode; cmake -GXcode -DCMAKE_BUILD_TYPE=RelWithDebInfo $(SRC_DIR)
linux: gcc_64
android: android_armv7
mac: clang_64
# Astyle
# --------------------------------------------------------------------
.PHONY: check_format format
check_format:
$(call colorecho,"Checking formatting with astyle")
@$(SRC_DIR)/Tools/astyle/check_code_style_all.sh
@cd $(SRC_DIR) && git diff --check
format:
$(call colorecho,"Formatting with astyle")
@$(SRC_DIR)/Tools/astyle/check_code_style_all.sh --fix
# Testing
# --------------------------------------------------------------------
.PHONY: tests tests_coverage
tests:
tests_coverage:
# Cleanup
# --------------------------------------------------------------------
.PHONY: clean submodulesclean submodulesupdate distclean
clean:
@rm -rf $(SRC_DIR)/build
submodulesclean:
@git submodule foreach --quiet --recursive git clean -ff -x -d
@git submodule update --quiet --init --recursive --force || true
@git submodule sync --recursive
@git submodule update --init --recursive --force
submodulesupdate:
@git submodule update --quiet --init --recursive || true
@git submodule sync --recursive
@git submodule update --init --recursive
distclean:
@git submodule deinit -f .
@git clean -ff -x -d -e ".project" -e ".cproject" -e ".idea" -e ".settings" -e ".vscode"
......@@ -57,7 +57,6 @@ linux {
macx-clang | macx-llvm {
message("Mac build")
CONFIG += MacBuild
DEFINES += __macos__
CONFIG += x86_64
CONFIG -= x86
equals(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 5) {
......
<?xml version="1.0"?>
<manifest android:versionName="@QT_ANDROID_APP_VERSION@" package="@QT_ANDROID_APP_PACKAGE_NAME@" android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="@QT_ANDROID_APP_VERSION_CODE@">
<application android:label="@QT_ANDROID_APP_NAME@" android:name="org.qtproject.qt5.android.bindings.QtApplication">
<activity android:label="@QT_ANDROID_APP_NAME@" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:screenOrientation="unspecified" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Messages maps -->
<!--<meta-data android:name="android.app.ministro_not_found_msg" android:value="@string/ministro_not_found_msg"/>
<meta-data android:name="android.app.ministro_needed_msg" android:value="@string/ministro_needed_msg"/>
<meta-data android:name="android.app.fatal_error_msg" android:value="@string/fatal_error_msg"/>-->
</activity>
</application>
<supports-screens android:anyDensity="true" android:normalScreens="true" android:smallScreens="true" android:largeScreens="true"/>
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0026 OLD) # allow use of the LOCATION target property
# store the current source directory for future use
set(QT_ANDROID_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
# check the JAVA_HOME environment variable
# (I couldn't find a way to set it from this script, it has to be defined outside)
set(JAVA_HOME $ENV{JAVA_HOME})
if(NOT JAVA_HOME)
message(FATAL_ERROR "The JAVA_HOME environment variable is not set. Please set it to the root directory of the JDK.")
endif()
# make sure that the Android toolchain is used
if(NOT ANDROID)
message(FATAL_ERROR "Trying to use the CMake Android package without the Android toolchain. Please use the provided toolchain (toolchain/android.toolchain.cmake)")
endif()
# find the Qt root directory
if(NOT Qt5Core_DIR)
find_package(Qt5Core REQUIRED)
endif()
get_filename_component(QT_ANDROID_QT_ROOT "${Qt5Core_DIR}/../../.." ABSOLUTE)
message(STATUS "Found Qt for Android: ${QT_ANDROID_QT_ROOT}")
# find the Android SDK
if(NOT QT_ANDROID_SDK_ROOT)
set(QT_ANDROID_SDK_ROOT $ENV{ANDROID_SDK})
if(NOT QT_ANDROID_SDK_ROOT)
message(FATAL_ERROR "Could not find the Android SDK. Please set either the ANDROID_SDK environment variable, or the QT_ANDROID_SDK_ROOT CMake variable to the root directory of the Android SDK")
endif()
endif()
string(REPLACE "\\" "/" QT_ANDROID_SDK_ROOT ${QT_ANDROID_SDK_ROOT}) # androiddeployqt doesn't like backslashes in paths
message(STATUS "Found Android SDK: ${QT_ANDROID_SDK_ROOT}")
# find the Android NDK
if(NOT QT_ANDROID_NDK_ROOT)
set(QT_ANDROID_NDK_ROOT $ENV{ANDROID_NDK})
if(NOT QT_ANDROID_NDK_ROOT)
set(QT_ANDROID_NDK_ROOT ${ANDROID_NDK})
if(NOT QT_ANDROID_NDK_ROOT)
message(FATAL_ERROR "Could not find the Android NDK. Please set either the ANDROID_NDK environment or CMake variable, or the QT_ANDROID_NDK_ROOT CMake variable to the root directory of the Android NDK")
endif()
endif()
endif()
string(REPLACE "\\" "/" QT_ANDROID_NDK_ROOT ${QT_ANDROID_NDK_ROOT}) # androiddeployqt doesn't like backslashes in paths
message(STATUS "Found Android NDK: ${QT_ANDROID_NDK_ROOT}")
include(CMakeParseArguments)
# define a macro to create an Android APK target
#
# example:
# add_qt_android_apk(my_app_apk my_app
# NAME "My App"
# VERSION_CODE 12
# PACKAGE_NAME "org.mycompany.myapp"
# PACKAGE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/my-android-sources
# BUILDTOOLS_REVISION "23.0.3"
# KEYSTORE ${CMAKE_CURRENT_LIST_DIR}/mykey.keystore myalias
# KEYSTORE_PASSWORD xxxx
# DEPENDS a_linked_target "path/to/a_linked_library.so" ...
# INSTALL
#)
#
macro(add_qt_android_apk TARGET SOURCE_TARGET)
# parse the macro arguments
cmake_parse_arguments(ARG "INSTALL" "NAME;VERSION_CODE;PACKAGE_NAME;PACKAGE_SOURCES;KEYSTORE_PASSWORD;BUILDTOOLS_REVISION" "DEPENDS;KEYSTORE" ${ARGN})
# extract the full path of the source target binary
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
get_property(QT_ANDROID_APP_PATH TARGET ${SOURCE_TARGET} PROPERTY DEBUG_LOCATION)
else()
get_property(QT_ANDROID_APP_PATH TARGET ${SOURCE_TARGET} PROPERTY LOCATION)
endif()
# define the application name
if(ARG_NAME)
set(QT_ANDROID_APP_NAME ${ARG_NAME})
else()
set(QT_ANDROID_APP_NAME ${SOURCE_TARGET})
endif()
# define the application package name
if(ARG_PACKAGE_NAME)
set(QT_ANDROID_APP_PACKAGE_NAME ${ARG_PACKAGE_NAME})
else()
set(QT_ANDROID_APP_PACKAGE_NAME org.qtproject.${SOURCE_TARGET})
endif()
# set the Android SDK build-tools revision
if(ARG_BUILDTOOLS_REVISION)
set(QT_ANDROID_SDK_BUILDTOOLS_REVISION ${ARG_BUILDTOOLS_REVISION})
else()
set(QT_ANDROID_SDK_BUILDTOOLS_REVISION "")
endif()
# define the application source package directory
if(ARG_PACKAGE_SOURCES)
set(QT_ANDROID_APP_PACKAGE_SOURCE_ROOT ${ARG_PACKAGE_SOURCES})
else()
# get version code from arguments, or generate a fixed one if not provided
set(QT_ANDROID_APP_VERSION_CODE ${ARG_VERSION_CODE})
if(NOT QT_ANDROID_APP_VERSION_CODE)
set(QT_ANDROID_APP_VERSION_CODE 1)
endif()
# try to extract the app version from the target properties, or use the version code if not provided
get_property(QT_ANDROID_APP_VERSION TARGET ${SOURCE_TARGET} PROPERTY VERSION)
if(NOT QT_ANDROID_APP_VERSION)
set(QT_ANDROID_APP_VERSION ${QT_ANDROID_APP_VERSION_CODE})
endif()
# create a subdirectory for the extra package sources
set(QT_ANDROID_APP_PACKAGE_SOURCE_ROOT "${CMAKE_CURRENT_BINARY_DIR}/package")
# generate a manifest from the template
configure_file(${QT_ANDROID_SOURCE_DIR}/AndroidManifest.xml.in ${QT_ANDROID_APP_PACKAGE_SOURCE_ROOT}/AndroidManifest.xml @ONLY)
endif()
# set the list of dependant libraries
if(ARG_DEPENDS)
foreach(LIB ${ARG_DEPENDS})
if(TARGET ${LIB})
# item is a CMake target, extract the library path
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
get_property(LIB_PATH TARGET ${LIB} PROPERTY DEBUG_LOCATION)
else()
get_property(LIB_PATH TARGET ${LIB} PROPERTY LOCATION)
endif()
set(LIB ${LIB_PATH})
endif()
if(EXTRA_LIBS)
set(EXTRA_LIBS "${EXTRA_LIBS},${LIB}")
else()
set(EXTRA_LIBS "${LIB}")
endif()
endforeach()
set(QT_ANDROID_APP_EXTRA_LIBS "\"android-extra-libs\": \"${EXTRA_LIBS}\",")
endif()
# make sure that the output directory for the Android package exists
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ABI})
# create the configuration file that will feed androiddeployqt
configure_file(${QT_ANDROID_SOURCE_DIR}/qtdeploy.json.in ${CMAKE_CURRENT_BINARY_DIR}/qtdeploy.json @ONLY)
# check if the apk must be signed
if(ARG_KEYSTORE)
set(SIGN_OPTIONS --release --sign ${ARG_KEYSTORE} --tsa http://timestamp.digicert.com)
if(ARG_KEYSTORE_PASSWORD)
set(SIGN_OPTIONS ${SIGN_OPTIONS} --storepass ${ARG_KEYSTORE_PASSWORD})
endif()
endif()
# check if the apk must be installed to the device
if(ARG_INSTALL)
set(INSTALL_OPTIONS --reinstall)
endif()
# specify the Android API level
if(ANDROID_NATIVE_API_LEVEL)
set(TARGET_LEVEL_OPTIONS --android-platform android-${ANDROID_NATIVE_API_LEVEL})
endif()
# create a custom command that will run the androiddeployqt utility to prepare the Android package
add_custom_target(
${TARGET}
ALL
DEPENDS ${SOURCE_TARGET}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ABI} # it seems that recompiled libraries are not copied if we don't remove them first
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ABI}
COMMAND ${CMAKE_COMMAND} -E copy ${QT_ANDROID_APP_PATH} ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ABI}
COMMAND ${QT_ANDROID_QT_ROOT}/bin/androiddeployqt --verbose --output ${CMAKE_CURRENT_BINARY_DIR} --input ${CMAKE_CURRENT_BINARY_DIR}/qtdeploy.json --gradle ${TARGET_LEVEL_OPTIONS} ${INSTALL_OPTIONS} ${SIGN_OPTIONS}
)
endmacro()
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
# The MIT License (MIT)
#
# Copyright (c) 2017 Nathan Osman
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
find_package(Qt5Core REQUIRED)
# Retrieve the absolute path to qmake and then use that path to find
# the macdeployqt binary
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}")
# Add commands that copy the required Qt files to the application bundle
# represented by the target
function(macdeployqt target)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${MACDEPLOYQT_EXECUTABLE}"
\"$<TARGET_FILE_DIR:${target}>/../..\"
-always-overwrite
COMMENT "Deploying Qt..."
)
endfunction()
mark_as_advanced(MACDEPLOYQT_EXECUTABLE)
# The MIT License (MIT)
#
# Copyright (c) 2017 Nathan Osman
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
find_package(Qt5Core REQUIRED)
# Retrieve the absolute path to qmake and then use that path to find
# the windeployqt binary
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
# Running this with MSVC 2015 requires CMake 3.6+
if((MSVC_VERSION VERSION_EQUAL 1900 OR MSVC_VERSION VERSION_GREATER 1900)
AND CMAKE_VERSION VERSION_LESS "3.6")
message(WARNING "Deploying with MSVC 2015+ requires CMake 3.6+")
endif()
# Add commands that copy the Qt runtime to the target's output directory after
# build and install the Qt runtime to the specified directory
function(windeployqt target directory)
# Run windeployqt immediately after build
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E
env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}"
--verbose 0
--no-compiler-runtime
--no-angle
--no-opengl-sw
\"$<TARGET_FILE:${target}>\"
)
# install(CODE ...) doesn't support generator expressions, but
# file(GENERATE ...) does - store the path in a file
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}_path"
CONTENT "$<TARGET_FILE:${target}>"
)
# Before installation, run a series of commands that copy each of the Qt
# runtime files to the appropriate directory for installation
install(CODE
"
file(READ \"${CMAKE_CURRENT_BINARY_DIR}/${target}_path\" _file)
execute_process(
COMMAND \"${CMAKE_COMMAND}\" -E
env PATH=\"${_qt_bin_dir}\" \"${WINDEPLOYQT_EXECUTABLE}\"
--dry-run
--no-compiler-runtime
--no-angle
--no-opengl-sw
--list mapping
\${_file}
OUTPUT_VARIABLE _output
OUTPUT_STRIP_TRAILING_WHITESPACE
)
separate_arguments(_files WINDOWS_COMMAND \${_output})
while(_files)
list(GET _files 0 _src)
list(GET _files 1 _dest)
execute_process(
COMMAND \"${CMAKE_COMMAND}\" -E
copy \${_src} \"\${CMAKE_INSTALL_PREFIX}/${directory}/\${_dest}\"
)
list(REMOVE_AT _files 0 1)
endwhile()
"
)
# windeployqt doesn't work correctly with the system runtime libraries,
# so we fall back to one of CMake's own modules for copying them over
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})
get_filename_component(filename "${lib}" NAME)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E
copy_if_different "${lib}" \"$<TARGET_FILE_DIR:${target}>\"
)
endforeach()
endfunction()
mark_as_advanced(WINDEPLOYQT_EXECUTABLE)
This diff is collapsed.
{
"description": "This file is to be read by androiddeployqt",
"qt": "@QT_ANDROID_QT_ROOT@",
"sdk": "@QT_ANDROID_SDK_ROOT@",
"ndk": "@QT_ANDROID_NDK_ROOT@",
"sdkBuildToolsRevision": "@QT_ANDROID_SDK_BUILDTOOLS_REVISION@",
"toolchain-prefix": "@ANDROID_TOOLCHAIN_MACHINE_NAME@",
"tool-prefix": "@ANDROID_TOOLCHAIN_MACHINE_NAME@",
"toolchain-version": "@ANDROID_COMPILER_VERSION@",
"ndk-host": "@ANDROID_NDK_HOST_SYSTEM_NAME@",
"target-architecture": "@ANDROID_ABI@",
"application-binary": "@QT_ANDROID_APP_PATH@",
"android-package": "@QT_ANDROID_APP_PACKAGE_NAME@",
"android-app-name": "@QT_ANDROID_APP_NAME@",
@QT_ANDROID_APP_EXTRA_LIBS@
"android-package-source-directory": "@QT_ANDROID_APP_PACKAGE_SOURCE_ROOT@"
}
#include "winver.h"
IDI_ICON1 ICON DISCARDABLE "@ICON_FILE@"
VS_VERSION_INFO VERSIONINFO
FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
FILEFLAGS 0x0L
FILEFLAGSMASK 0x3fL
FILEOS 0x00040004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "CompanyName", "@COMPANY@"
VALUE "FileDescription", "@PROJECT_NAME@"
VALUE "FileVersion", "@PROJECT_VERSION@"
VALUE "Legal