From c2c1eb4e30e8405ad6e2acbefba7babbce26c0dd Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 19 Mar 2020 14:49:19 -0400 Subject: [PATCH] Add a static library --- CMakeLists.txt | 5 +++++ examples/textures/textures_image_loading.cpp | 2 +- lib/CMakeLists.txt | 8 ++++++++ lib/libraylib-cpp.cpp | 11 +++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 lib/CMakeLists.txt create mode 100644 lib/libraylib-cpp.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d05fdf9..92a38f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.11) project (raylib-cpp) +option(BUILD_STATIC "Static Library" ON) option(BUILD_EXAMPLES "Examples" ON) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") @@ -8,6 +9,10 @@ configure_file(${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake ${CMAKE_BINARY_DIR}) add_subdirectory(include) +if(BUILD_STATIC) + add_subdirectory(lib) +endif() + if(BUILD_EXAMPLES) add_subdirectory(examples) endif() diff --git a/examples/textures/textures_image_loading.cpp b/examples/textures/textures_image_loading.cpp index 2792bbd..2dc3aab 100644 --- a/examples/textures/textures_image_loading.cpp +++ b/examples/textures/textures_image_loading.cpp @@ -39,7 +39,7 @@ int main() background.ClearBackground(); - texture.Draw(screenWidth / 2 - texture.getWidth() / 2, screenHeight / 2 - texture.getHeight() / 2); + texture.Draw(screenWidth / 2 - texture.GetWidth() / 2, screenHeight / 2 - texture.GetHeight() / 2); textColor.DrawText("this IS a texture loaded from an image!", 300, 370, 10); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 0000000..a0d32c9 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,8 @@ +# libraylib-cpp static library +add_library(libraylib-cpp STATIC libraylib-cpp) + +# Link raylib and raylib-cpp +target_link_libraries(libraylib-cpp PUBLIC raylib raylib-cpp) + +# Remove the "lib" at the beginning since it's already there. +set_target_properties(libraylib-cpp PROPERTIES PREFIX "") diff --git a/lib/libraylib-cpp.cpp b/lib/libraylib-cpp.cpp new file mode 100644 index 0000000..fed4535 --- /dev/null +++ b/lib/libraylib-cpp.cpp @@ -0,0 +1,11 @@ +/******************************************************************************************* +* +* libraylib-cpp [raylib-cpp] library +* +* This is a static C++ built library to make linking easier. +* +* Copyright (c) 2015 Rob Loach (@RobLoach) +* +********************************************************************************************/ + +#include "raylib/raylib.hpp"