aboutsummaryrefslogtreecommitdiff
path: root/raylib/src/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'raylib/src/CMakeLists.txt')
-rw-r--r--raylib/src/CMakeLists.txt132
1 files changed, 132 insertions, 0 deletions
diff --git a/raylib/src/CMakeLists.txt b/raylib/src/CMakeLists.txt
new file mode 100644
index 0000000..9735e26
--- /dev/null
+++ b/raylib/src/CMakeLists.txt
@@ -0,0 +1,132 @@
1# Setup the project and settings
2project(raylib C)
3set(PROJECT_VERSION 5.5.0)
4set(API_VERSION 550)
5
6include(GNUInstallDirs)
7include(JoinPaths)
8
9# Sets build type if not set by now
10if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
11 if(RAYLIB_IS_MAIN)
12 set(default_build_type Debug)
13 else()
14 message(WARNING "Default build type is not set (CMAKE_BUILD_TYPE)")
15 endif()
16
17 message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
18
19 set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
20 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
21endif()
22
23# Used as public API to be included into other projects
24set(raylib_public_headers
25 raylib.h
26 rlgl.h
27 raymath.h
28 )
29
30# Sources to be compiled
31set(raylib_sources
32 raudio.c
33 rcore.c
34 rmodels.c
35 rshapes.c
36 rtext.c
37 rtextures.c
38 utils.c
39 )
40
41# <root>/cmake/GlfwImport.cmake handles the details around the inclusion of glfw
42if (NOT ${PLATFORM} MATCHES "Web")
43 include(GlfwImport)
44endif ()
45
46# Sets additional platform options and link libraries for each platform
47# also selects the proper graphics API and version for that platform
48# Produces a variable LIBS_PRIVATE that will be used later
49include(LibraryConfigurations)
50
51if (SUPPORT_MODULE_RAUDIO)
52 MESSAGE(STATUS "Audio Backend: miniaudio")
53else ()
54 MESSAGE(STATUS "Audio Backend: None (-DCUSTOMIZE_BUILD=ON -DSUPPORT_MODULE_RAUDIO=OFF)")
55endif ()
56
57add_library(raylib ${raylib_sources} ${raylib_public_headers})
58
59if (NOT BUILD_SHARED_LIBS)
60 MESSAGE(STATUS "Building raylib static library")
61 add_library(raylib_static ALIAS raylib)
62else()
63 MESSAGE(STATUS "Building raylib shared library")
64 target_compile_definitions(raylib
65 PRIVATE $<BUILD_INTERFACE:BUILD_LIBTYPE_SHARED>
66 INTERFACE $<INSTALL_INTERFACE:USE_LIBTYPE_SHARED>
67 )
68endif()
69
70if (${PLATFORM} MATCHES "Web")
71 target_link_options(raylib PUBLIC "-sUSE_GLFW=3")
72 if(${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES3")
73 target_link_options(raylib PUBLIC "-sMIN_WEBGL_VERSION=2")
74 target_link_options(raylib PUBLIC "-sMAX_WEBGL_VERSION=2")
75 endif()
76endif()
77
78set_target_properties(raylib PROPERTIES
79 PUBLIC_HEADER "${raylib_public_headers}"
80 VERSION ${PROJECT_VERSION}
81 SOVERSION ${API_VERSION}
82 )
83
84if (WITH_PIC OR BUILD_SHARED_LIBS)
85 set_property(TARGET raylib PROPERTY POSITION_INDEPENDENT_CODE ON)
86endif ()
87
88if (BUILD_SHARED_LIBS)
89 # Hide raylib's symbols by default so RLAPI can expose them
90 set_property(TARGET raylib PROPERTY C_VISIBILITY_PRESET hidden)
91endif ()
92
93target_link_libraries(raylib "${LIBS_PRIVATE}")
94
95# Sets some compile time definitions for the pre-processor
96# If CUSTOMIZE_BUILD option is on you will not use config.h by default
97# and you will be able to select more build options
98include(CompileDefinitions)
99
100# Registering include directories
101target_include_directories(raylib
102 PUBLIC
103 $<INSTALL_INTERFACE:include>
104 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
105 PRIVATE
106 ${CMAKE_CURRENT_SOURCE_DIR}
107 ${OPENGL_INCLUDE_DIR}
108 ${OPENAL_INCLUDE_DIR}
109 )
110
111# Copy the header files to the build directory for convenience
112file(COPY ${raylib_public_headers} DESTINATION "include")
113
114# Includes information on how the library will be installed on the system
115# when cmake --install is run
116include(InstallConfigurations)
117
118# Print the flags for the user
119if (DEFINED CMAKE_BUILD_TYPE)
120 message(STATUS "Generated build type: ${CMAKE_BUILD_TYPE}")
121else ()
122 message(STATUS "Generated config types: ${CMAKE_CONFIGURATION_TYPES}")
123endif ()
124
125message(STATUS "Compiling with the flags:")
126message(STATUS " PLATFORM=" ${PLATFORM_CPP})
127message(STATUS " GRAPHICS=" ${GRAPHICS})
128
129# Options if you want to create an installer using CPack
130include(PackConfigurations)
131
132enable_testing()

Generated with cgit - Back to sebastiano.tronto.net