forked from qt-creator/qt-creator
CMake: update project templates to work with Android for Qt 6
Qt 6 introduces qt_add_executable() function, which for Android make sure to call few Android specific functions like: * qt_android_generate_deployment_settings() * qt_android_add_apk_target() * qt_android_apply_arch_suffix() Using add_library() only the user would otherwise need to reimplement what's already implemented in add_qt_gui_executable(). Task-number: QTCREATORBUG-24681 Change-Id: Iec3984139844fe1cbac2d9a583b3c40bdaa308a0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -34,22 +34,28 @@ find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
|
|||||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
|
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
if(ANDROID)
|
set(PROJECT_SOURCES
|
||||||
add_library(%{ProjectName} SHARED
|
|
||||||
%{MainCppFileName}
|
%{MainCppFileName}
|
||||||
qml.qrc
|
qml.qrc
|
||||||
@if %{HasTranslation}
|
@if %{HasTranslation}
|
||||||
${TS_FILES}
|
${TS_FILES}
|
||||||
@endif
|
@endif
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
qt_add_executable(%{ProjectName}
|
||||||
|
${PROJECT_SOURCES}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_executable(%{ProjectName}
|
if(ANDROID)
|
||||||
%{MainCppFileName}
|
add_library(%{ProjectName} SHARED
|
||||||
qml.qrc
|
${PROJECT_SOURCES}
|
||||||
@if %{HasTranslation}
|
|
||||||
${TS_FILES}
|
|
||||||
@endif
|
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
add_executable(%{ProjectName}
|
||||||
|
${PROJECT_SOURCES}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(%{ProjectName}
|
target_compile_definitions(%{ProjectName}
|
||||||
|
@@ -34,8 +34,7 @@ find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
|
|||||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
|
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
if(ANDROID)
|
set(PROJECT_SOURCES
|
||||||
add_library(%{ProjectName} SHARED
|
|
||||||
%{MainFileName}
|
%{MainFileName}
|
||||||
%{SrcFileName}
|
%{SrcFileName}
|
||||||
%{HdrFileName}
|
%{HdrFileName}
|
||||||
@@ -45,19 +44,22 @@ if(ANDROID)
|
|||||||
@if %{HasTranslation}
|
@if %{HasTranslation}
|
||||||
${TS_FILES}
|
${TS_FILES}
|
||||||
@endif
|
@endif
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
qt_add_executable(%{ProjectName}
|
||||||
|
${PROJECT_SOURCES}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_executable(%{ProjectName}
|
if(ANDROID)
|
||||||
%{MainFileName}
|
add_library(%{ProjectName} SHARED
|
||||||
%{SrcFileName}
|
${PROJECT_SOURCES}
|
||||||
%{HdrFileName}
|
|
||||||
@if %{GenerateForm}
|
|
||||||
%{FormFileName}
|
|
||||||
@endif
|
|
||||||
@if %{HasTranslation}
|
|
||||||
${TS_FILES}
|
|
||||||
@endif
|
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
add_executable(%{ProjectName}
|
||||||
|
${PROJECT_SOURCES}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
|
Reference in New Issue
Block a user