Add a static library

This commit is contained in:
Rob Loach
2020-03-19 14:49:19 -04:00
parent 8e2ad2eb38
commit c2c1eb4e30
4 changed files with 25 additions and 1 deletions

View File

@@ -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()

View File

@@ -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);

8
lib/CMakeLists.txt Normal file
View File

@@ -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 "")

11
lib/libraylib-cpp.cpp Normal file
View File

@@ -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"