From c2900f60fa6785531a7e428e87962e77e28aa044 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 17 Feb 2022 01:32:49 -0500 Subject: [PATCH] Update CMake template (#169) --- projects/CMake/.gitignore | 1 + projects/CMake/CMakeLists.txt | 28 +++++++--------------------- 2 files changed, 8 insertions(+), 21 deletions(-) create mode 100644 projects/CMake/.gitignore diff --git a/projects/CMake/.gitignore b/projects/CMake/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/projects/CMake/.gitignore @@ -0,0 +1 @@ +/build diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index f92c744..2706db4 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -1,24 +1,16 @@ -cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+ +cmake_minimum_required(VERSION 3.14) project(raylib_cpp_example) # raylib find_package(raylib QUIET) if (NOT raylib_FOUND) include(FetchContent) - FetchContent_Declare( + FetchContent_Declare( raylib GIT_REPOSITORY https://github.com/raysan5/raylib.git GIT_TAG 4.0.0 ) - FetchContent_GetProperties(raylib) - if (NOT raylib_POPULATED) # Have we downloaded raylib yet? - set(FETCHCONTENT_QUIET NO) - FetchContent_Populate(raylib) - set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) - set(BUILD_GAMES OFF CACHE BOOL "" FORCE) - set(BUILD_TESTING OFF CACHE BOOL "" FORCE) - add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR}) - endif() + FetchContent_MakeAvailable(raylib) endif() # raylib-cpp @@ -28,20 +20,14 @@ if (NOT raylib_cpp_FOUND) FetchContent_Declare( raylib_cpp GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git - GIT_TAG v4.0.4 + GIT_TAG v4.1.0 ) - FetchContent_GetProperties(raylib_cpp) - if (NOT raylib_cpp_POPULATED) # Have we downloaded raylib-cpp yet? - set(FETCHCONTENT_QUIET NO) - FetchContent_Populate(raylib_cpp) - add_subdirectory(${raylib_cpp_SOURCE_DIR} ${raylib_cpp_BINARY_DIR}) - endif() + FetchContent_MakeAvailable(raylib_cpp) endif() # This is the main part: -set(PROJECT_NAME raylib_cpp_example) -set(PROJECT_SOURCES main.cpp) -add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}) +set(SOURCES main.cpp) +add_executable(${PROJECT_NAME} ${SOURCES}) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} PUBLIC raylib raylib_cpp)