From 9bd174ad0cb5987d060b265fdc27a68058c0a508 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 11 Apr 2020 13:23:24 -0400 Subject: [PATCH] Switch to submodule for the raylib dependency Fixes #26 --- .gitmodules | 3 +++ CMakeLists.txt | 30 +++++++++++++++++++++++++----- README.md | 1 + cmake/CTestCustom.cmake | 3 +++ cmake/FindRaylib.cmake | 17 ----------------- examples/CMakeLists.txt | 2 +- lib/libraylib-cpp.cpp | 3 ++- projects/CMake/CMakeLists.txt | 6 +++--- vendor/raylib | 1 + 9 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 .gitmodules create mode 100644 cmake/CTestCustom.cmake delete mode 100644 cmake/FindRaylib.cmake create mode 160000 vendor/raylib diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..af7b76e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/raylib"] + path = vendor/raylib + url = https://github.com/raysan5/raylib.git diff --git a/CMakeLists.txt b/CMakeLists.txt index ce13ae2..66c4215 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,40 @@ cmake_minimum_required(VERSION 3.11) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -project (raylib-cpp) +project (raylib-cpp + VERSION 0.3.0 + DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib" + HOMEPAGE_URL "https://github.com/robloach/raylib-cpp" + LANGUAGES C CXX) -option(BUILD_STATIC "Static Library" ON) -option(BUILD_EXAMPLES "Examples" ON) +# CMake configuration +configure_file(${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake ${CMAKE_BINARY_DIR}) +# raylib +find_package(raylib 3.0.0 QUIET) +if (NOT raylib_FOUND) + set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples + set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games + add_subdirectory(vendor/raylib) +endif() + +# Options +option(BUILD_RAYLIB_CPP_STATIC "Static Library" ON) +option(BUILD_RAYLIB_CPP_EXAMPLES "Examples" ON) + +# Include Directory add_subdirectory(include) -if(BUILD_STATIC) +# Static Library +if(BUILD_RAYLIB_CPP_STATIC) add_subdirectory(lib) endif() -if(BUILD_EXAMPLES) +# Examples +if(BUILD_RAYLIB_CPP_EXAMPLES) add_subdirectory(examples) endif() +# Testing include(CTest) enable_testing() if(BUILD_TESTING) diff --git a/README.md b/README.md index 82d9ee0..01c082e 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,7 @@ There is a [CMake sample project template](projects/CMake) that you can use a st *raylib-cpp* uses [CMake](https://cmake.org) as a primary target for development. To build it, and run the tests/examples, use... ``` bash +git submodule update --init mkdir build cd build cmake .. diff --git a/cmake/CTestCustom.cmake b/cmake/CTestCustom.cmake new file mode 100644 index 0000000..4cf1ea3 --- /dev/null +++ b/cmake/CTestCustom.cmake @@ -0,0 +1,3 @@ +set(CTEST_CUSTOM_TESTS_IGNORE + pkg-config--static +) diff --git a/cmake/FindRaylib.cmake b/cmake/FindRaylib.cmake deleted file mode 100644 index fbdd654..0000000 --- a/cmake/FindRaylib.cmake +++ /dev/null @@ -1,17 +0,0 @@ -find_package(raylib 3.0.0 QUIET) -if (NOT raylib_FOUND) - include(FetchContent) - FetchContent_Declare( - raylib - GIT_REPOSITORY https://github.com/raysan5/raylib.git - GIT_TAG 6a8b1079c13b7d5e1bddc0ecc86ad7e16fc2556d - ) - 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) # don't build the supplied examples - set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games - add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR}) - endif() -endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 347d674..98d1b8c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,7 @@ foreach(example_source ${example_sources}) # Setup the example add_executable(${example_name} ${example_source}) - target_link_libraries(${example_name} PUBLIC raylib-cpp raylib) + target_link_libraries(${example_name} PUBLIC libraylib-cpp) string(REGEX MATCH ".*/.*/" resources_dir ${example_source}) string(APPEND resources_dir "resources") diff --git a/lib/libraylib-cpp.cpp b/lib/libraylib-cpp.cpp index fed4535..b2938f3 100644 --- a/lib/libraylib-cpp.cpp +++ b/lib/libraylib-cpp.cpp @@ -4,8 +4,9 @@ * * This is a static C++ built library to make linking easier. * -* Copyright (c) 2015 Rob Loach (@RobLoach) +* Copyright (c) 2020 Rob Loach (@RobLoach) * ********************************************************************************************/ +// raylib-cpp #include "raylib/raylib.hpp" diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index b2aac1d..b34745c 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -7,7 +7,7 @@ if (NOT raylib_FOUND) FetchContent_Declare( raylib GIT_REPOSITORY https://github.com/raysan5/raylib.git - GIT_TAG 6a8b1079c13b7d5e1bddc0ecc86ad7e16fc2556d + GIT_TAG 7ef114d1da2c34a70bba5442497103441647d8f3 ) FetchContent_GetProperties(raylib) if (NOT raylib_POPULATED) # Have we downloaded raylib yet? @@ -20,13 +20,13 @@ if (NOT raylib_FOUND) endif() endif() -find_package(raylib-cpp 0.2.0 QUIET) +find_package(raylib-cpp 0.3.0 QUIET) if (NOT raylib-cpp_FOUND) include(FetchContent) FetchContent_Declare( raylib-cpp GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git - GIT_TAG eddfc01dfc1ae9419683cacd81965c6a07b8aacd + GIT_TAG 64c39d6d6b1ab2f68cb3669b0a3ff57857d5cdf7 ) FetchContent_GetProperties(raylib-cpp) if (NOT raylib-cpp_POPULATED) # Have we downloaded raylib yet? diff --git a/vendor/raylib b/vendor/raylib new file mode 160000 index 0000000..7ef114d --- /dev/null +++ b/vendor/raylib @@ -0,0 +1 @@ +Subproject commit 7ef114d1da2c34a70bba5442497103441647d8f3