Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 13, 2025. It is now read-only.

Commit eb80804

Browse files
committed
Added project.
0 parents  commit eb80804

File tree

6 files changed

+1166
-0
lines changed

6 files changed

+1166
-0
lines changed

CMakeLists.txt

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(libretro_core_glad_lua C)
3+
include(FetchContent)
4+
FetchContent_Declare(
5+
libretro-common
6+
GIT_REPOSITORY https://github.com/libretro/libretro-common.git
7+
GIT_TAG master
8+
)
9+
FetchContent_MakeAvailable(libretro-common)
10+
FetchContent_Declare(
11+
glad
12+
GIT_REPOSITORY https://github.com/Dav1dde/glad.git
13+
GIT_TAG v0.1.36
14+
)
15+
FetchContent_MakeAvailable(glad)
16+
set(GLAD_PROFILE "core" CACHE STRING "OpenGL profile")
17+
set(GLAD_API "gl=3.3" CACHE STRING "API type/version")
18+
set(GLAD_GENERATOR "c" CACHE STRING "Language to generate")
19+
20+
# Fetch Lua (source only, no CMake build)
21+
FetchContent_Declare(
22+
lua
23+
GIT_REPOSITORY https://github.com/lua/lua.git
24+
GIT_TAG v5.4.7
25+
)
26+
FetchContent_Populate(lua)
27+
28+
# Lua doesn't have a CMake build, so we manually compile it
29+
# List Lua source files (core and libraries, excluding lua.c and luac.c)
30+
set(LUA_SRC
31+
${lua_SOURCE_DIR}/lapi.c
32+
${lua_SOURCE_DIR}/lauxlib.c
33+
${lua_SOURCE_DIR}/lbaselib.c
34+
${lua_SOURCE_DIR}/lcode.c
35+
${lua_SOURCE_DIR}/lcorolib.c
36+
${lua_SOURCE_DIR}/lctype.c
37+
${lua_SOURCE_DIR}/ldblib.c
38+
${lua_SOURCE_DIR}/ldebug.c
39+
${lua_SOURCE_DIR}/ldo.c
40+
${lua_SOURCE_DIR}/ldump.c
41+
${lua_SOURCE_DIR}/lfunc.c
42+
${lua_SOURCE_DIR}/lgc.c
43+
${lua_SOURCE_DIR}/linit.c
44+
${lua_SOURCE_DIR}/liolib.c
45+
${lua_SOURCE_DIR}/llex.c
46+
${lua_SOURCE_DIR}/lmathlib.c
47+
${lua_SOURCE_DIR}/lmem.c
48+
${lua_SOURCE_DIR}/loadlib.c
49+
${lua_SOURCE_DIR}/lobject.c
50+
${lua_SOURCE_DIR}/lopcodes.c
51+
${lua_SOURCE_DIR}/loslib.c
52+
${lua_SOURCE_DIR}/lparser.c
53+
${lua_SOURCE_DIR}/lstate.c
54+
${lua_SOURCE_DIR}/lstring.c
55+
${lua_SOURCE_DIR}/lstrlib.c
56+
${lua_SOURCE_DIR}/ltable.c
57+
${lua_SOURCE_DIR}/ltablib.c
58+
${lua_SOURCE_DIR}/ltm.c
59+
${lua_SOURCE_DIR}/lundump.c
60+
${lua_SOURCE_DIR}/lvm.c
61+
${lua_SOURCE_DIR}/lzio.c
62+
${lua_SOURCE_DIR}/lutf8lib.c
63+
)
64+
65+
# Create a static Lua library
66+
add_library(lua STATIC ${LUA_SRC})
67+
target_include_directories(lua PUBLIC
68+
${lua_SOURCE_DIR}
69+
)
70+
71+
# testing for opengl and software render toggle
72+
set(USE_OPENGL ON)
73+
# lrcgl library
74+
add_library(lrcgl SHARED src/lib.c)
75+
# glad
76+
target_link_libraries(lrcgl PRIVATE
77+
glad
78+
lua
79+
)
80+
# opengl
81+
if(WIN32 AND USE_OPENGL)
82+
target_link_libraries(lrcgl PRIVATE opengl32)
83+
endif()
84+
# include folder for headers
85+
target_include_directories(lrcgl PRIVATE
86+
${libretro-common_SOURCE_DIR}/include
87+
${CMAKE_CURRENT_SOURCE_DIR}/include
88+
${glad_SOURCE_DIR}/include
89+
${lua_SOURCE_DIR}
90+
)
91+
# compile definitions
92+
target_compile_definitions(lrcgl PRIVATE _CRT_SECURE_NO_WARNINGS)
93+
if(USE_OPENGL)
94+
target_compile_definitions(lrcgl PRIVATE USE_OPENGL)
95+
endif()
96+
# lrcgl.dll
97+
set_target_properties(lrcgl PROPERTIES
98+
PREFIX ""
99+
OUTPUT_NAME "libretro_core_glad_lua" # file name
100+
SUFFIX ".dll"
101+
)
102+
set_property(TARGET lrcgl PROPERTY C_STANDARD 99)

0 commit comments

Comments
 (0)