Qmldesigner: Simplify template CMakeLists.txt

The CMakeLists.txt file generated with a new MCU project in QDS was
made to work with many older Qt for MCUs versions. Since some of these
are more than 2 years old now, we can simplify the file to work with
the newer versions only.

Task-number: QDS-13049
Change-Id: I63e5464aa7c8ebcb5d443c4eed189f5e8e595f72
Reviewed-by: Aleksei German <aleksei.german@qt.io>
Reviewed-by: Yasser Grimes <yasser.grimes@qt.io>
This commit is contained in:
Sivert Krøvel
2024-08-15 15:31:49 +02:00
parent 9f6221d3cd
commit 45cebed389

View File

@@ -6,77 +6,11 @@ if (NOT TARGET Qul::Core)
find_package(Qul)
endif()
if (Qul_VERSION VERSION_GREATER_EQUAL "2.4")
qul_add_target(%{ProjectName} QML_PROJECT %{ProjectName}.qmlproject GENERATE_ENTRYPOINT)
app_target_setup_os(%{ProjectName})
else()
if (Qul_VERSION VERSION_GREATER_EQUAL "1.7")
qul_add_target(%{ProjectName})
else()
add_executable(%{ProjectName})
target_link_libraries(%{ProjectName}
Qul::QuickUltralite
Qul::QuickUltralitePlatform)
endif()
if (Qul_VERSION VERSION_GREATER_EQUAL "2.0")
file(GLOB_RECURSE fontSources "${CMAKE_CURRENT_SOURCE_DIR}/fonts/*.ttf")
set_property(TARGET %{ProjectName} APPEND PROPERTY QUL_FONT_FILES ${fontSources})
elseif (Qul_VERSION VERSION_GREATER_EQUAL "1.7")
set_property(TARGET %{ProjectName} APPEND PROPERTY QUL_FONTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fonts")
else()
set(QUL_FONTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fonts,${QUL_FONTS_DIR}")
endif()
# Using recurse search to find image files in project directory
# Excluding MCUDefaultStyle because it exists for compatibility purposes with QDS
file(GLOB_RECURSE imgSources "*.png" "*.svg" "*.jpg" "*.jpeg")
list(FILTER imgSources EXCLUDE REGEX ".*/MCUDefaultStyle/.*")
if(imgSources)
qul_add_resource(%{ProjectName} FILES ${imgSources})
endif()
# Registering singletons as qml module
qul_add_qml_module(ConstantsModule
URI Constants
QML_FILES
imports/Constants/Constants.qml
)
message(WARNING "It is recommended to replace the recursive search with the actual list of .qml files in your project.")
file(GLOB_RECURSE qmlSources "*.qml")
# Excluding Constants folder because it is part of another qml module
list(FILTER qmlSources EXCLUDE REGEX ".*/imports/Constants/.*")
# Excluding MCUDefaultStyle because it exists for compatibility purposes with QDS
list(FILTER qmlSources EXCLUDE REGEX ".*/MCUDefaultStyle/.*")
# Excluding binary directory because it can break builds in source dir
list(FILTER qmlSources EXCLUDE REGEX "${CMAKE_CURRENT_BINARY_DIR}/.*")
qul_target_qml_sources(%{ProjectName} ${qmlSources})
if (Qul_VERSION VERSION_GREATER_EQUAL "2.0")
target_link_libraries(%{ProjectName} PRIVATE
Qul::Timeline
Qul::Controls
Qul::Shapes
ConstantsModule)
else()
target_link_libraries(%{ProjectName}
Qul::QuickUltraliteTimeline
Qul::QuickUltraliteControlsStyleDefault
ConstantsModule)
if (Qul_VERSION VERSION_GREATER_EQUAL "1.8")
target_link_libraries(%{ProjectName}
Qul::QuickUltraliteShapes)
endif()
endif()
app_target_setup_os(%{ProjectName})
if (Qul_VERSION VERSION_GREATER_EQUAL "1.7")
app_target_default_entrypoint(%{ProjectName} %{RootItemName})
else()
app_target_default_main(%{ProjectName} %{RootItemName})
endif()
if (Qul_VERSION LESS "2.4")
message(WARNING "The current Qt for MCUs version is '${Qul_VERSION}'."
"This CMake project was made for Qt for MCUs 2.4 and newer, "
"and might not work as expected.")
endif()
qul_add_target(%{ProjectName} QML_PROJECT %{ProjectName}.qmlproject GENERATE_ENTRYPOINT)
app_target_setup_os(%{ProjectName})