2020-07-27 08:17:04 +00:00
|
|
|
# This function creates a CMake target for a Qt internal app.
|
|
|
|
# Such projects had a load(qt_app) command.
|
|
|
|
function(qt_internal_add_app target)
|
|
|
|
qt_parse_all_arguments(arg
|
|
|
|
"qt_internal_add_app"
|
2021-02-26 10:04:00 +00:00
|
|
|
"NO_INSTALL;INSTALL_VERSIONED_LINK"
|
2022-02-22 12:49:24 +00:00
|
|
|
"${__default_target_info_args};INSTALL_DIR"
|
2020-07-27 08:17:04 +00:00
|
|
|
"${__default_private_args}"
|
|
|
|
${ARGN})
|
|
|
|
|
2022-02-22 12:49:24 +00:00
|
|
|
if(DEFINED arg_INSTALL_DIR)
|
|
|
|
set(forward_install_dir INSTALL_DIRECTORY ${arg_INSTALL_DIR})
|
|
|
|
else()
|
|
|
|
set(forward_install_dir "")
|
|
|
|
set(arg_INSTALL_DIR ${INSTALL_BINDIR})
|
|
|
|
endif()
|
|
|
|
set(output_directory "${QT_BUILD_DIR}/${arg_INSTALL_DIR}")
|
2020-07-27 08:17:04 +00:00
|
|
|
|
|
|
|
set(no_install "")
|
|
|
|
if(arg_NO_INSTALL)
|
|
|
|
set(no_install NO_INSTALL)
|
|
|
|
endif()
|
|
|
|
|
2020-09-22 08:02:27 +00:00
|
|
|
qt_internal_add_executable("${target}"
|
2020-11-06 20:48:08 +00:00
|
|
|
QT_APP
|
2020-07-27 08:17:04 +00:00
|
|
|
DELAY_RC
|
|
|
|
DELAY_TARGET_INFO
|
|
|
|
OUTPUT_DIRECTORY "${output_directory}"
|
|
|
|
${no_install}
|
2022-02-22 12:49:24 +00:00
|
|
|
${forward_install_dir}
|
2020-07-27 08:17:04 +00:00
|
|
|
SOURCES ${arg_SOURCES}
|
|
|
|
INCLUDE_DIRECTORIES
|
|
|
|
${arg_INCLUDE_DIRECTORIES}
|
|
|
|
DEFINES
|
|
|
|
${arg_DEFINES}
|
|
|
|
LIBRARIES ${arg_LIBRARIES} Qt::PlatformAppInternal
|
|
|
|
COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
|
|
|
|
LINK_OPTIONS ${arg_LINK_OPTIONS}
|
|
|
|
MOC_OPTIONS ${arg_MOC_OPTIONS}
|
|
|
|
ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
|
|
|
|
DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
|
|
|
|
TARGET_VERSION "${arg_TARGET_VERSION}"
|
|
|
|
TARGET_PRODUCT "${arg_TARGET_PRODUCT}"
|
|
|
|
TARGET_DESCRIPTION "${arg_TARGET_DESCRIPTION}"
|
|
|
|
TARGET_COMPANY "${arg_TARGET_COMPANY}"
|
|
|
|
TARGET_COPYRIGHT "${arg_TARGET_COPYRIGHT}"
|
|
|
|
)
|
|
|
|
qt_internal_add_target_aliases("${target}")
|
CMake: Don't use std=gnu++11 when building Qt internal targets
The logic is a bit involved in qmake.
The Qt internal qt_common.prf adds CONFIG += strict_c++ which applies
to qt modules, qt plugins, qml plugins, qt helper libs, winmain and
qt_apps, qt_tools, but NOT tests (which is important because the tests
on Windows MinGW fail to build without the GNU extensions).
Then default_post.prf checks for the strict_c++ value and either uses
the strict or non-strict C++ standard flags. default_post.prf is
loaded for all qmake projects, not just the Qt internal ones.
Now CMake doesn't provide a transitive based option to disable C++
GNU extensions with a mechanism similar to target_compile_features.
It only provides the CXX_EXTENSIONS property and it's associated
CMAKE_CXX_EXTENSIONS variable. We can't set the variable at a
directory scope, because that is too coarse grained.
So we rely on setting the property via a function in every relevant
qt_add_<target> function.
Now the naming of the function is weird.
We name the function as qt_internal_<...>, because it's not meant to be
used by Qt users.
We prepend an underscore to the name because we need to place it in
Qt6CoreMacros, so that the function can be called by
qt_add_qml_module which IS a public function.
That's because in Qt5 load(qml_plugin) was private API, but in Qt 6 +
CMake we decided to make qt_add_qml_module() as public API.
Change-Id: Id014626b087d590e25cb46843f93d0c67fc36e44
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-04 09:29:00 +00:00
|
|
|
_qt_internal_apply_strict_cpp("${target}")
|
2021-07-07 14:04:17 +00:00
|
|
|
qt_internal_adjust_main_config_runtime_output_dir("${target}" "${output_directory}")
|
2020-07-27 08:17:04 +00:00
|
|
|
|
|
|
|
# To mimic the default behaviors of qt_app.prf, we by default enable GUI Windows applications,
|
|
|
|
# but don't enable macOS bundles.
|
|
|
|
# Bundles are enabled in a separate set_target_properties call if an Info.plist file
|
|
|
|
# is provided.
|
|
|
|
# Similary, the Windows GUI flag is disabled in a separate call
|
|
|
|
# if CONFIG += console was encountered during conversion.
|
|
|
|
set_target_properties("${target}" PROPERTIES WIN32_EXECUTABLE TRUE)
|
|
|
|
|
2021-02-11 13:01:58 +00:00
|
|
|
# Consider every app as user facing tool.
|
|
|
|
set_property(GLOBAL APPEND PROPERTY QT_USER_FACING_TOOL_TARGETS ${target})
|
|
|
|
|
2021-02-26 10:04:00 +00:00
|
|
|
# Install versioned link if requested.
|
|
|
|
if(NOT arg_NO_INSTALL AND arg_INSTALL_VERSIONED_LINK)
|
2022-02-22 12:49:24 +00:00
|
|
|
qt_internal_install_versioned_link("${arg_INSTALL_DIR}" ${target})
|
2021-02-26 10:04:00 +00:00
|
|
|
endif()
|
|
|
|
|
2020-07-27 08:17:04 +00:00
|
|
|
qt_add_list_file_finalizer(qt_internal_finalize_app ${target})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_get_title_case value out_var)
|
|
|
|
if(NOT value)
|
|
|
|
set(${out_var} "" PARENT_SCOPE)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
string(SUBSTRING "${value}" 0 1 first_char)
|
|
|
|
string(TOUPPER "${first_char}" first_char_upper)
|
|
|
|
string(SUBSTRING "${target}" 1 -1 rest_of_value)
|
|
|
|
set(title_value "${first_char_upper}${rest_of_value}")
|
|
|
|
set(${out_var} "${title_value}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_update_app_target_info_properties target)
|
|
|
|
# First update the delayed properties with any values that might have been set after the
|
|
|
|
# qt_internal_add_app() call.
|
|
|
|
qt_internal_update_delayed_target_info_properties(${target})
|
|
|
|
|
|
|
|
# Set defaults in case if no values were set.
|
|
|
|
get_target_property(target_version ${target} QT_DELAYED_TARGET_VERSION)
|
|
|
|
if(NOT target_version)
|
|
|
|
set_target_properties(${target} PROPERTIES QT_DELAYED_TARGET_VERSION "${PROJECT_VERSION}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_target_property(target_description ${target} QT_DELAYED_TARGET_DESCRIPTION)
|
|
|
|
if(NOT target_description)
|
|
|
|
qt_internal_get_title_case("${target}" upper_name)
|
|
|
|
set_target_properties(${target} PROPERTIES QT_DELAYED_TARGET_DESCRIPTION "Qt ${upper_name}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Finally set the final values.
|
|
|
|
qt_internal_set_target_info_properties_from_delayed_properties("${target}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qt_internal_finalize_app target)
|
|
|
|
qt_internal_update_app_target_info_properties("${target}")
|
|
|
|
|
|
|
|
if(WIN32)
|
2020-10-14 11:20:55 +00:00
|
|
|
_qt_internal_generate_win32_rc_file("${target}")
|
2020-07-27 08:17:04 +00:00
|
|
|
endif()
|
2020-09-10 15:45:45 +00:00
|
|
|
|
|
|
|
# Rpaths need to be applied in the finalizer, because the MACOSX_BUNDLE property might be
|
|
|
|
# set after a qt_internal_add_app call.
|
|
|
|
qt_apply_rpaths(TARGET "${target}" INSTALL_PATH "${INSTALL_BINDIR}" RELATIVE_RPATH)
|
2022-04-14 16:04:41 +00:00
|
|
|
qt_internal_apply_staging_prefix_build_rpath_workaround()
|
2020-07-27 08:17:04 +00:00
|
|
|
endfunction()
|