From a6117d25e8a2102cfeee966e7c59f2d65479d042 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Tue, 21 Apr 2020 14:51:31 -0400 Subject: [PATCH] Update the cmake include vendor project --- .gitmodules | 1 + CMakeLists.txt | 19 ++++++------------- examples/CMakeLists.txt | 3 +-- lib/CMakeLists.txt | 8 ++++++++ projects/CMake/CMakeLists.txt | 6 +++--- tests/CMakeLists.txt | 2 -- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.gitmodules b/.gitmodules index af7b76e..9ab9a3d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "vendor/raylib"] path = vendor/raylib url = https://github.com/raysan5/raylib.git + ignore = dirty diff --git a/CMakeLists.txt b/CMakeLists.txt index 29f4c1b..79b085c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,14 +6,6 @@ project (raylib-cpp HOMEPAGE_URL "https://github.com/robloach/raylib-cpp" LANGUAGES C CXX) -# 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) @@ -21,14 +13,15 @@ option(BUILD_RAYLIB_CPP_EXAMPLES "Examples" ON) # Include Directory add_subdirectory(include) -# Static Library -if(BUILD_RAYLIB_CPP_STATIC) - add_subdirectory(lib) -endif() - # Examples if(BUILD_RAYLIB_CPP_EXAMPLES) add_subdirectory(examples) + set(BUILD_RAYLIB_CPP_STATIC ON) +endif() + +# Static Library +if(BUILD_RAYLIB_CPP_STATIC) + add_subdirectory(lib) endif() # Testing diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 98d1b8c..7bb399f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(Raylib) - # Get the sources together set(example_dirs audio core models shapes text textures) set(example_sources) @@ -23,6 +21,7 @@ foreach(example_source ${example_sources}) # Setup the example add_executable(${example_name} ${example_source}) + # Link against the static library. target_link_libraries(${example_name} PUBLIC libraylib-cpp) string(REGEX MATCH ".*/.*/" resources_dir ${example_source}) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index f203b59..a443e66 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,6 +1,14 @@ # libraylib-cpp static library add_library(libraylib-cpp STATIC libraylib-cpp) +# 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(${CMAKE_CURRENT_SOURCE_DIR}/../vendor/raylib ${CMAKE_CURRENT_SOURCE_DIR}/../vendor/raylib) +endif() + # Link raylib and raylib-cpp target_link_libraries(libraylib-cpp PUBLIC raylib raylib-cpp) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index e1c04be..7a49428 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -34,9 +34,9 @@ if (NOT raylib-cpp_FOUND) if (NOT raylib-cpp_POPULATED) # Have we downloaded raylib yet? set(FETCHCONTENT_QUIET NO) FetchContent_Populate(raylib-cpp) - set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) - set(BUILD_GAMES OFF CACHE BOOL "" FORCE) - set(BUILD_TESTING OFF CACHE BOOL "" FORCE) + set(BUILD_RAYLIB_CPP_STATIC OFF CACHE BOOL "" FORCE) + set(BUILD_RAYLIB_CPP_EXAMPLES OFF CACHE BOOL "" FORCE) + set(BUILD_TESTING OFF CACHE BOOL "" FORCE) add_subdirectory(${raylib-cpp_SOURCE_DIR} ${raylib-cpp_BINARY_DIR}) endif() endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 935f96b..338d889 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,8 +28,6 @@ macro(ADD_CATCH_TESTS executable) endforeach() endmacro() -find_package(Raylib) - set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CTEST_CUSTOM_TESTS_IGNORE pkg-config--static)