Give glad a CMake file
Today I learned that CMake will error if the project shares a dependency with a nested CMake file (which could be from an entirely-separate project that you have no control over). I'm starting to really hate CMake.
This commit is contained in:
parent
a093ebd018
commit
5b996b3459
6 changed files with 26 additions and 7 deletions
|
@ -526,7 +526,8 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BACKEND_RENDERER MATCHES "OpenGL3")
|
if(BACKEND_RENDERER MATCHES "OpenGL3")
|
||||||
target_sources(CSE2 PRIVATE "external/glad/src/glad.c" "external/glad/include/glad/glad.h" "external/glad/include/KHR/khrplatform.h")
|
add_subdirectory("external/glad" EXCLUDE_FROM_ALL)
|
||||||
|
target_link_libraries(CSE2 PRIVATE glad)
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
target_link_libraries(CSE2 PRIVATE OpenGL::GL ${CMAKE_DL_LIBS})
|
target_link_libraries(CSE2 PRIVATE OpenGL::GL ${CMAKE_DL_LIBS})
|
||||||
|
|
|
@ -9,9 +9,6 @@ project(DoConfig LANGUAGES C CXX)
|
||||||
|
|
||||||
add_executable(DoConfig WIN32
|
add_executable(DoConfig WIN32
|
||||||
"icon.rc"
|
"icon.rc"
|
||||||
"../external/glad/include/glad/glad.h"
|
|
||||||
"../external/glad/include/KHR/khrplatform.h"
|
|
||||||
"../external/glad/src/glad.c"
|
|
||||||
"DoConfig.cpp"
|
"DoConfig.cpp"
|
||||||
"imgui/imconfig.h"
|
"imgui/imconfig.h"
|
||||||
"imgui/imgui.cpp"
|
"imgui/imgui.cpp"
|
||||||
|
@ -71,6 +68,16 @@ endif()
|
||||||
# Dependencies #
|
# Dependencies #
|
||||||
################
|
################
|
||||||
|
|
||||||
|
# glad
|
||||||
|
|
||||||
|
if(NOT TARGET glad)
|
||||||
|
add_subdirectory("../external/glad" "glad" EXCLUDE_FROM_ALL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(DoConfig PRIVATE glad)
|
||||||
|
|
||||||
|
# GLFW3
|
||||||
|
|
||||||
if(NOT FORCE_LOCAL_LIBS)
|
if(NOT FORCE_LOCAL_LIBS)
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
endif()
|
endif()
|
||||||
|
|
11
external/glad/CMakeLists.txt
vendored
Normal file
11
external/glad/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
|
project(glad LANGUAGES C)
|
||||||
|
|
||||||
|
add_library(glad
|
||||||
|
"include/glad/glad.h"
|
||||||
|
"include/KHR/khrplatform.h"
|
||||||
|
"src/glad.c"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(glad PUBLIC "include")
|
2
external/glad/include/glad/glad.h
vendored
2
external/glad/include/glad/glad.h
vendored
|
@ -86,7 +86,7 @@ GLAPI int gladLoadGL(void);
|
||||||
|
|
||||||
GLAPI int gladLoadGLLoader(GLADloadproc);
|
GLAPI int gladLoadGLLoader(GLADloadproc);
|
||||||
|
|
||||||
#include "../KHR/khrplatform.h"
|
#include <KHR/khrplatform.h>
|
||||||
typedef unsigned int GLenum;
|
typedef unsigned int GLenum;
|
||||||
typedef unsigned char GLboolean;
|
typedef unsigned char GLboolean;
|
||||||
typedef unsigned int GLbitfield;
|
typedef unsigned int GLbitfield;
|
||||||
|
|
2
external/glad/src/glad.c
vendored
2
external/glad/src/glad.c
vendored
|
@ -22,7 +22,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../include/glad/glad.h"
|
#include <glad/glad.h>
|
||||||
|
|
||||||
static void* get_proc(const char *namez);
|
static void* get_proc(const char *namez);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#ifdef USE_OPENGLES2
|
#ifdef USE_OPENGLES2
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#else
|
#else
|
||||||
#include "../../../external/glad/include/glad/glad.h"
|
#include <glad/glad.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SPRITEBATCH_IMPLEMENTATION
|
#define SPRITEBATCH_IMPLEMENTATION
|
||||||
|
|
Loading…
Add table
Reference in a new issue