Skip to content

Commit 9c8f997

Browse files
committed
When using Slint via FetchContent, don't print a message on every re-configure
Require CMake 2.4 to intregate CMake FetchContent and find_package, according to https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html#fetchcontent-and-find-package-integration This way FetchContent_MakeAvailable will first try to call find_package(Slint) and if that fails then fall back to building via FetchContent. Fixes #16
1 parent 892aa00 commit 9c8f997

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

CMakeLists.txt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
cmake_minimum_required(VERSION 3.21)
1+
cmake_minimum_required(VERSION 3.24)
22
project(my_application LANGUAGES CXX)
33

4-
find_package(Slint QUIET)
5-
if (NOT Slint_FOUND)
6-
message("Slint could not be located in the CMake module search path. Downloading it from Git and building it locally")
7-
include(FetchContent)
8-
FetchContent_Declare(
9-
Slint
10-
GIT_REPOSITORY https://github.com/slint-ui/slint.git
11-
# `release/1` will auto-upgrade to the latest Slint >= 1.0.0 and < 2.0.0
12-
# `release/1.0` will auto-upgrade to the latest Slint >= 1.0.0 and < 1.1.0
13-
GIT_TAG release/1
14-
SOURCE_SUBDIR api/cpp
15-
)
16-
FetchContent_MakeAvailable(Slint)
17-
endif (NOT Slint_FOUND)
4+
include(FetchContent)
5+
FetchContent_Declare(
6+
Slint
7+
GIT_REPOSITORY https://github.com/slint-ui/slint.git
8+
# `release/1` will auto-upgrade to the latest Slint >= 1.0.0 and < 2.0.0
9+
# `release/1.0` will auto-upgrade to the latest Slint >= 1.0.0 and < 1.1.0
10+
GIT_TAG release/1
11+
SOURCE_SUBDIR api/cpp
12+
FIND_PACKAGE_ARGS NAMES Slint
13+
)
14+
FetchContent_MakeAvailable(Slint)
1815

1916
add_executable(my_application src/main.cpp)
2017
target_link_libraries(my_application PRIVATE Slint::Slint)

0 commit comments

Comments
 (0)