cmake: Respect CMAKE_MACOSX_BUNDLE and CMAKE_WIN32_EXECUTABLE
The user may set different global defaults for CMAKE_MACOSX_BUNDLE and CMAKE_WIN32_EXECUTABLE, so we shouldn't unconditionally override them on a target level. This allows cmake ~/foo/ -DCMAKE_MACOSX_BUNDLE=ON to build a project as a GUI app without needing to modify the CMakeLists.txt with target specific overrides. Change-Id: Id49adb1c0aedfe82a2b1d919d086c5112ba92b93 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
80d680e82f
commit
6a465729be
@ -184,10 +184,17 @@ function(qt_internal_add_executable name)
|
||||
set_target_properties("${name}" PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
|
||||
WIN32_EXECUTABLE "${arg_GUI}"
|
||||
MACOSX_BUNDLE "${arg_GUI}"
|
||||
)
|
||||
|
||||
if(arg_GUI)
|
||||
# Only override if GUI is set. Otherwise leave up to
|
||||
# CMake defaults, which may be set by the user elsewhere.
|
||||
set_target_properties("${name}" PROPERTIES
|
||||
MACOSX_BUNDLE ON
|
||||
WIN32_EXECUTABLE ON
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT arg_EXCEPTIONS)
|
||||
qt_internal_set_exceptions_flags("${name}" "DEFAULT")
|
||||
else()
|
||||
|
@ -576,13 +576,17 @@ function(qt_internal_add_test name)
|
||||
|
||||
# Manual tests can be bundle apps
|
||||
if(NOT arg_MANUAL)
|
||||
# Tests should not be bundles on macOS even if arg_GUI is true, because some tests make
|
||||
# assumptions about the location of helper processes, and those paths would be different
|
||||
# if a test is built as a bundle.
|
||||
set_property(TARGET "${name}" PROPERTY MACOSX_BUNDLE FALSE)
|
||||
# The same goes for WIN32_EXECUTABLE, but because it will detach from the console window
|
||||
# and not print anything.
|
||||
set_property(TARGET "${name}" PROPERTY WIN32_EXECUTABLE FALSE)
|
||||
if(NOT DEFINED CMAKE_MACOSX_BUNDLE)
|
||||
# Tests should not be bundles on macOS even if arg_GUI is true, because some tests make
|
||||
# assumptions about the location of helper processes, and those paths would be different
|
||||
# if a test is built as a bundle.
|
||||
set_property(TARGET "${name}" PROPERTY MACOSX_BUNDLE FALSE)
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_WIN32_EXECUTABLE)
|
||||
# The same goes for WIN32_EXECUTABLE, but because it will detach from the console window
|
||||
# and not print anything.
|
||||
set_property(TARGET "${name}" PROPERTY WIN32_EXECUTABLE FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Tests on iOS must be app bundles.
|
||||
|
Loading…
x
Reference in New Issue
Block a user