Skip to content

Commit c2900f6

Browse files
authored
Update CMake template (#169)
1 parent c25f747 commit c2900f6

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

projects/CMake/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

projects/CMake/CMakeLists.txt

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1-
cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
1+
cmake_minimum_required(VERSION 3.14)
22
project(raylib_cpp_example)
33

44
# raylib
55
find_package(raylib QUIET)
66
if (NOT raylib_FOUND)
77
include(FetchContent)
8-
FetchContent_Declare(
8+
FetchContent_Declare(
99
raylib
1010
GIT_REPOSITORY https://github.com/raysan5/raylib.git
1111
GIT_TAG 4.0.0
1212
)
13-
FetchContent_GetProperties(raylib)
14-
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
15-
set(FETCHCONTENT_QUIET NO)
16-
FetchContent_Populate(raylib)
17-
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
18-
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
19-
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
20-
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
21-
endif()
13+
FetchContent_MakeAvailable(raylib)
2214
endif()
2315

2416
# raylib-cpp
@@ -28,20 +20,14 @@ if (NOT raylib_cpp_FOUND)
2820
FetchContent_Declare(
2921
raylib_cpp
3022
GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git
31-
GIT_TAG v4.0.4
23+
GIT_TAG v4.1.0
3224
)
33-
FetchContent_GetProperties(raylib_cpp)
34-
if (NOT raylib_cpp_POPULATED) # Have we downloaded raylib-cpp yet?
35-
set(FETCHCONTENT_QUIET NO)
36-
FetchContent_Populate(raylib_cpp)
37-
add_subdirectory(${raylib_cpp_SOURCE_DIR} ${raylib_cpp_BINARY_DIR})
38-
endif()
25+
FetchContent_MakeAvailable(raylib_cpp)
3926
endif()
4027

4128
# This is the main part:
42-
set(PROJECT_NAME raylib_cpp_example)
43-
set(PROJECT_SOURCES main.cpp)
44-
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES})
29+
set(SOURCES main.cpp)
30+
add_executable(${PROJECT_NAME} ${SOURCES})
4531
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
4632
target_link_libraries(${PROJECT_NAME} PUBLIC raylib raylib_cpp)
4733

0 commit comments

Comments
 (0)