aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-03-17 10:57:26 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-03-17 10:57:26 +0100
commit46e96b3318900b561928be304f4a9e252f2785a4 (patch)
tree64f0fa7b3478f733652981310e581b073ef25a28 /CMakeLists.txt
parent4c50201a2048b7ffcc1b7086c9617112cb540501 (diff)
downloadQtXpl2-46e96b3318900b561928be304f4a9e252f2785a4.tar.gz
QtXpl2-46e96b3318900b561928be304f4a9e252f2785a4.zip
Guard top-level-only CMake settings behind PROJECT_IS_TOP_LEVEL
Allow QtXpl2 to be consumed as a submodule via add_subdirectory() without conflicting with the parent project's C++ standard, qt_standard_project_setup(), QML tooling, or RPATH settings.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt33
1 files changed, 19 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6562716..8cb8618 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,26 +1,31 @@
cmake_minimum_required(VERSION 3.16)
project(QtXpl2 LANGUAGES CXX)
-set(CMAKE_CXX_STANDARD 17)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+if(PROJECT_IS_TOP_LEVEL)
+ set(CMAKE_CXX_STANDARD 17)
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+endif()
find_package(Qt6 6.10.2 REQUIRED COMPONENTS Core Network Qml Quick)
-qt_standard_project_setup()
qt_policy(SET QTP0001 NEW)
-# QML import path so Qt Creator / qmlls can resolve modules.
-set(QML_IMPORT_PATH
- "${CMAKE_CURRENT_BINARY_DIR}/qml"
- CACHE STRING "Path to locally built QML modules")
+if(PROJECT_IS_TOP_LEVEL)
+ qt_standard_project_setup()
-# Generate .qmlls.ini for QML language server
-set(QT_QML_GENERATE_QMLLS_INI
- ON
- CACHE BOOL "")
+ # QML import path so Qt Creator / qmlls can resolve modules.
+ set(QML_IMPORT_PATH
+ "${CMAKE_CURRENT_BINARY_DIR}/qml"
+ CACHE STRING "Path to locally built QML modules")
-# Let the demo executable find the library at run time.
-set(CMAKE_BUILD_RPATH "${PROJECT_BINARY_DIR}/qml/Xpl2")
+ # Generate .qmlls.ini for QML language server
+ set(QT_QML_GENERATE_QMLLS_INI
+ ON
+ CACHE BOOL "")
+
+ # Let the demo executable find the library at run time.
+ set(CMAKE_BUILD_RPATH "${PROJECT_BINARY_DIR}/qml/Xpl2")
+endif()
add_subdirectory(src)