CMake: Handle INSTALL_DIRECTORY for qt_executables

Allow to override the install directory for Qt executables.

Change-Id: I9561976eefe9c7b573bb97ddaaa39e30d3b6d9fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Tobias Hunger 2019-03-18 19:09:27 +01:00
parent 4f736db08c
commit 485e96c4ee

View File

@ -746,7 +746,7 @@ endfunction()
# Please consider to use a more specific version target like the one created
# by add_qt_test or add_qt_tool below.
function(add_qt_executable name)
qt_parse_all_arguments(arg "add_qt_executable" "GUI" "OUTPUT_DIRECTORY" "EXE_FLAGS;${__default_private_args}" ${ARGN})
qt_parse_all_arguments(arg "add_qt_executable" "GUI" "OUTPUT_DIRECTORY;INSTALL_DIRECTORY" "EXE_FLAGS;${__default_private_args}" ${ARGN})
if ("x${arg_OUTPUT_DIRECTORY}" STREQUAL "x")
set(arg_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}")
@ -755,6 +755,10 @@ function(add_qt_executable name)
get_filename_component(arg_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
ABSOLUTE BASE_DIR "${CMAKE_BINARY_DIR}")
if ("x${arg_INSTALL_DIRECTORY}" STREQUAL "x")
set(arg_INSTALL_DIRECTORY "${INSTALL_BINDIR}")
endif()
add_executable("${name}" ${arg_EXE_FLAGS})
qt_autogen_tools("${name}"
@ -782,6 +786,10 @@ function(add_qt_executable name)
WIN32_EXECUTABLE "${arg_GUI}"
MACOSX_BUNDLE "${arg_GUI}"
)
install(TARGETS "${name}"
RUNTIME DESTINATION "${arg_INSTALL_DIRECTORY}"
BUNDLE DESTINATION "${arg_INSTALL_DIRECTORY}")
endfunction()