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:
Clownacy 2020-04-03 01:34:47 +01:00
parent a093ebd018
commit 5b996b3459
6 changed files with 26 additions and 7 deletions

View file

@ -526,7 +526,8 @@ else()
endif()
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)
target_link_libraries(CSE2 PRIVATE OpenGL::GL ${CMAKE_DL_LIBS})

View file

@ -9,9 +9,6 @@ project(DoConfig LANGUAGES C CXX)
add_executable(DoConfig WIN32
"icon.rc"
"../external/glad/include/glad/glad.h"
"../external/glad/include/KHR/khrplatform.h"
"../external/glad/src/glad.c"
"DoConfig.cpp"
"imgui/imconfig.h"
"imgui/imgui.cpp"
@ -71,6 +68,16 @@ endif()
# 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)
find_package(PkgConfig QUIET)
endif()

11
external/glad/CMakeLists.txt vendored Normal file
View 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")

View file

@ -86,7 +86,7 @@ GLAPI int gladLoadGL(void);
GLAPI int gladLoadGLLoader(GLADloadproc);
#include "../KHR/khrplatform.h"
#include <KHR/khrplatform.h>
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;

View file

@ -22,7 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../include/glad/glad.h"
#include <glad/glad.h>
static void* get_proc(const char *namez);

View file

@ -10,7 +10,7 @@
#ifdef USE_OPENGLES2
#include <GLES2/gl2.h>
#else
#include "../../../external/glad/include/glad/glad.h"
#include <glad/glad.h>
#endif
#define SPRITEBATCH_IMPLEMENTATION