Apply cmake-format

This commit is contained in:
Martchus 2019-05-04 20:59:19 +02:00
parent 850101dce6
commit d8333f3793
5 changed files with 56 additions and 57 deletions

View File

@ -171,7 +171,8 @@ else ()
endif ()
# find c++utilities
set(CONFIGURATION_PACKAGE_SUFFIX "" CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities")
set(CONFIGURATION_PACKAGE_SUFFIX ""
CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities")
find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED)
use_cpp_utilities()

View File

@ -239,11 +239,9 @@ else ()
endif ()
endif ()
set(ANDROID_APK_BINARY_PATH
"${ANDROID_APK_BUILD_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}/lib${META_TARGET_NAME}.so")
set(ANDROID_APK_BINARY_PATH "${ANDROID_APK_BUILD_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}/lib${META_TARGET_NAME}.so")
add_custom_command(OUTPUT "${ANDROID_APK_BINARY_PATH}"
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${META_TARGET_NAME}>"
"${ANDROID_APK_BINARY_PATH}"
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${META_TARGET_NAME}>" "${ANDROID_APK_BINARY_PATH}"
COMMENT "Preparing build dir for Android APK"
DEPENDS "${META_TARGET_NAME}" COMMAND_EXPAND_LISTS
VERBATIM)
@ -262,9 +260,7 @@ add_custom_command(
"${ANDROID_DEPLOYMENT_JSON_FILE};${ANDROID_APK_BINARY_PATH};${ANDROID_APK_FILES};${ANDROID_APK_BINARY_DIRS_DEPENDS}"
COMMAND_EXPAND_LISTS
VERBATIM)
add_custom_target("${META_TARGET_NAME}_apk"
COMMENT "Android APK"
DEPENDS "${ANDROID_APK_FILE_PATH}")
add_custom_target("${META_TARGET_NAME}_apk" COMMENT "Android APK" DEPENDS "${ANDROID_APK_FILE_PATH}")
if (NOT TARGET apk)
add_custom_target(apk)
endif ()
@ -279,8 +275,7 @@ endif ()
install(FILES "${ANDROID_APK_FILE_PATH}" DESTINATION "share/apk" RENAME "${ANDROID_APK_FINAL_NAME}" COMPONENT apk)
add_custom_target("${META_TARGET_NAME}_install_apk"
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=apk -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
add_dependencies("${META_TARGET_NAME}_install_apk"
"${META_TARGET_NAME}_apk")
add_dependencies("${META_TARGET_NAME}_install_apk" "${META_TARGET_NAME}_apk")
if (NOT TARGET install-apk)
add_custom_target(install-apk)
endif ()

View File

@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
# applies Qt specific configuration
# notes: For GUI applications, QtGuiConfig must be included before.
# This module must always be included before AppTarget/LibraryTarget.
# applies Qt specific configuration notes: For GUI applications, QtGuiConfig must be included before. This module must always
# be included before AppTarget/LibraryTarget.
# ensure generated sources are processed by AUTOMOC and AUTOUIC
if (POLICY CMP0071)
@ -25,9 +24,8 @@ include(ListToString)
include(TemplateFinder)
include(QtLinkage)
# add the Core module as it is always required and also add additional Qt/KF modules
# which must have been specified before if required
# note: The Gui/Widgets/Quick modules should be added by including QtGuiConfig.
# add the Core module as it is always required and also add additional Qt/KF modules which must have been specified before if
# required note: The Gui/Widgets/Quick modules should be added by including QtGuiConfig.
set(QT_REPOS ${ADDITIONAL_QT_REPOS} base)
set(QT_MODULES ${ADDITIONAL_QT_MODULES} Core)
set(KF_MODULES ${ADDITIONAL_KF_MODULES})
@ -61,7 +59,7 @@ foreach (MODULE ${QT_MODULES})
unset(MODULE_OPTIONS)
if ("${MODULE}" IN_LIST META_PUBLIC_QT_MODULES)
list(APPEND MODULE_OPTIONS VISIBILITY PUBLIC)
endif()
endif ()
use_qt_module(PREFIX "${QT_PACKAGE_PREFIX}" MODULE "${MODULE}" ${MODULE_OPTIONS})
endforeach ()
set(KF_PACKAGE_PREFIX "KF5" CACHE STRING "specifies the prefix for KDE Frameworks packages")
@ -69,14 +67,14 @@ foreach (MODULE ${KF_MODULES})
unset(MODULE_OPTIONS)
if ("${MODULE}" IN_LIST META_PUBLIC_KF_MODULES)
list(APPEND MODULE_OPTIONS VISIBILITY PUBLIC)
endif()
endif ()
use_qt_module(PREFIX "${KF_PACKAGE_PREFIX}" MODULE "${MODULE}" ${MODULE_OPTIONS})
endforeach ()
# hack for using static Qt via "StaticQt5" prefix: find regular Qt5Core module as well so Qt version is defined
if (QT_PACKAGE_PREFIX STREQUAL "StaticQt5")
find_package(Qt5Core)
endif()
endif ()
# find transitively required Qt/KF modules
foreach (MODULE ${IMPORTED_QT_MODULES})
@ -104,7 +102,7 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
else ()
message(WARNING "The required platform plugin for your platform is unknown an can not be linked in statically.")
endif ()
endif()
endif ()
# ensure all available widget style plugins are built-in when creating a Qt Widgets application note: required since Qt
# 5.10 because the styles have been "pluginized" (see commit 4f3249f)
@ -120,7 +118,11 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
# allow importing image format plugins via config.h
if (USED_WIDGET_STYLE_PLUGINS)
list_to_string(" " "\\\n Q_IMPORT_PLUGIN(Q" "Plugin)" "${USED_WIDGET_STYLE_PLUGINS}" WIDGET_STYLE_PLUGINS_ARRAY)
list_to_string(" "
"\\\n Q_IMPORT_PLUGIN(Q"
"Plugin)"
"${USED_WIDGET_STYLE_PLUGINS}"
WIDGET_STYLE_PLUGINS_ARRAY)
endif ()
endif ()
@ -141,7 +143,11 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
endif ()
# ensure SVG plugins are built-in if configured
if ((SVG_SUPPORT OR SVG_ICON_SUPPORT) AND NOT Svg IN_LIST QT_MODULES)
if ((SVG_SUPPORT OR SVG_ICON_SUPPORT)
AND NOT
Svg
IN_LIST
QT_MODULES)
use_qt_module(PREFIX "${QT_PACKAGE_PREFIX}" MODULE Svg)
endif ()
if (SVG_SUPPORT)

View File

@ -13,7 +13,7 @@ endif ()
if (NOT WIDGETS_GUI AND NOT QUICK_GUI)
message(STATUS "GUI is completely disabled.")
return()
endif()
endif ()
list(APPEND ADDITIONAL_QT_MODULES Gui)

View File

@ -27,84 +27,81 @@ macro (use_qt_module)
# validate values
if (NOT ARGS_PREFIX)
message(FATAL_ERROR "use_qt_module called without PREFIX.")
endif()
endif ()
if (NOT ARGS_MODULE)
message(FATAL_ERROR "use_qt_module called without MODULE.")
endif()
endif ()
if (ARGS_VISIBILITY)
validate_visibility(${ARGS_VISIBILITY})
else()
set (ARGS_VISIBILITY PRIVATE)
endif()
else ()
set(ARGS_VISIBILITY PRIVATE)
endif ()
if (NOT ARGS_LIBRARIES_VARIABLE)
set (ARGS_LIBRARIES_VARIABLE "${ARGS_VISIBILITY}_LIBRARIES")
endif()
set(ARGS_LIBRARIES_VARIABLE "${ARGS_VISIBILITY}_LIBRARIES")
endif ()
if (NOT ARGS_TARGETS)
if (${MODULE}_MODULE_TARGETS)
set(ARGS_TARGETS "${${MODULE}_MODULE_TARGETS}")
else()
else ()
set(ARGS_TARGETS "${ARGS_PREFIX}::${ARGS_MODULE}")
endif()
endif()
endif ()
endif ()
if (ARGS_ONLY_PLUGINS AND NOT ARGS_PLUGINS)
message(FATAL_ERROR "ONLY_PLUGINS specified but no plugins.")
endif()
endif ()
# find and use module
if (NOT ONLY_PLUGINS)
find_package("${ARGS_PREFIX}${ARGS_MODULE}" "${META_QT5_VERSION}" REQUIRED)
foreach(TARGET ${ARGS_TARGETS})
foreach (TARGET ${ARGS_TARGETS})
if (NOT TARGET "${TARGET}")
message(FATAL_ERROR "The ${ARGS_PREFIX}${ARGS_MODULE} does not provide the target ${TARGET}.")
endif()
endif ()
if ("${TARGET}" IN_LIST "${ARGS_LIBRARIES_VARIABLE}")
continue()
endif()
endif ()
set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};${TARGET}")
set("PKG_CONFIG_${ARGS_PREFIX}_${ARGS_MODULE}" "${ARGS_PREFIX}${ARGS_MODULE}")
message(
STATUS
"Linking ${META_TARGET_NAME} against Qt 5 module ${TARGET}."
)
message(STATUS "Linking ${META_TARGET_NAME} against Qt 5 module ${TARGET}.")
# hack for "StaticQt5": re-assign INTERFACE_LINK_LIBRARIES_RELEASE to INTERFACE_LINK_LIBRARIES
get_target_property("${ARGS_MODULE}_INTERFACE_LINK_LIBRARIES_RELEASE" "${TARGET}" INTERFACE_LINK_LIBRARIES_RELEASE)
get_target_property("${ARGS_MODULE}_INTERFACE_LINK_LIBRARIES_RELEASE" "${TARGET}"
INTERFACE_LINK_LIBRARIES_RELEASE)
if ("${ARGS_MODULE}_INTERFACE_LINK_LIBRARIES_RELEASE")
set_target_properties("${TARGET}" PROPERTIES INTERFACE_LINK_LIBRARIES "${${ARGS_MODULE}_INTERFACE_LINK_LIBRARIES_RELEASE}")
set_target_properties("${TARGET}"
PROPERTIES INTERFACE_LINK_LIBRARIES
"${${ARGS_MODULE}_INTERFACE_LINK_LIBRARIES_RELEASE}")
endif ()
endforeach()
endif()
endforeach ()
endif ()
# find and use plugins
foreach (PLUGIN ${ARGS_PLUGINS})
if (NOT TARGET "${ARGS_PREFIX}::Q${PLUGIN}Plugin")
find_package("${PREFIX}${MODULE}" "${META_QT5_VERSION}" REQUIRED)
endif()
endif ()
if (NOT TARGET "${ARGS_PREFIX}::Q${PLUGIN}Plugin")
message(FATAL_ERROR "The ${ARGS_PREFIX}${MODULE} does not provide the target ${ARGS_PREFIX}::Q${PLUGIN}Plugin.")
endif()
endif ()
if ("${ARGS_PREFIX}::Q${PLUGIN}Plugin" IN_LIST "${ARGS_LIBRARIES_VARIABLE}")
continue()
endif()
endif ()
set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};${ARGS_PREFIX}::Q${PLUGIN}Plugin")
message(
STATUS
"Linking ${META_TARGET_NAME} against Qt 5 plugin ${ARGS_PREFIX}::Q${PLUGIN}Plugin."
)
endforeach()
message(STATUS "Linking ${META_TARGET_NAME} against Qt 5 plugin ${ARGS_PREFIX}::Q${PLUGIN}Plugin.")
endforeach ()
# unset variables (can not simply use a function because Qt's variables need to be exported)
foreach (ARGUMENT ${OPTIONAL_ARGS} ${ONE_VALUE_ARGS} ${MULTI_VALUE_ARGS})
unset(ARGS_${ARGUMENT})
endforeach()
endmacro()
endforeach ()
endmacro ()
# define function to make qmake variable available within CMake
function (query_qmake_variable QMAKE_VARIABLE)
# prevent queries for variables already known
if (NOT "${${QMAKE_VARIABLE}}" STREQUAL "")
return()
endif()
endif ()
# execute qmake
get_target_property(QMAKE_BIN Qt5::qmake IMPORTED_LOCATION)
@ -128,4 +125,4 @@ function (query_qmake_variable QMAKE_VARIABLE)
# export variable to parent scope
set("${QMAKE_VARIABLE}" "${${QMAKE_VARIABLE}}" PARENT_SCOPE)
message(STATUS "qmake variable ${QMAKE_VARIABLE} is ${${QMAKE_VARIABLE}}")
endfunction()
endfunction ()