From ceaa23fd1834ad56fe5f74d544b650be9a55360b Mon Sep 17 00:00:00 2001 From: AwesomeAdam54321 Date: Sat, 26 Aug 2023 16:38:13 +0800 Subject: [PATCH] glad: Add package configuration files. * glad.pc.in: Add pkg-config file. * gladConfig.cmake: Add CMake package file for detection by external packages. --- glad.pc.in | 11 +++++ gladConfig.cmake | 104 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 glad.pc create mode 100644 gladConfig.cmake diff --git a/glad.pc.in b/glad.pc.in new file mode 100644 index 0000000..5c29fcd --- /dev/null +++ b/glad.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ # this defines a variable +exec_prefix=${prefix} # defining another variable with a substitution +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: glad +Description: OpenGL(3.3) Loader Library +Version: 0 +URL: https://github.com/arrayfire/glad +Libs: -L${libdir} -lglad +Cflags: -I${includedir}/glad \ No newline at end of file diff --git a/gladConfig.cmake b/gladConfig.cmake new file mode 100644 index 0000000..1213d3e --- /dev/null +++ b/gladConfig.cmake @@ -0,0 +1,104 @@ +# Finds the glad libraries +# +# Sets the following variables: +# glad_FOUND +# glad_INCLUDE_DIR +# glad_DYNAMIC_LIBRARY +# glad_STATIC_LIBRARY +# +# Usage: +# find_package(glad) +# if (glad_FOUND) +# target_link_libraries(mylib PRIVATE glad::glad) +# endif (glad_FOUND) +# +# OR if you want to link against the static library: +# +# find_package(glad) +# if (glad_FOUND) +# target_link_libraries(mylib PRIVATE glad::glad_STATIC) +# endif (glad_FOUND) +# +# NOTE: You do not need to include the glad include directories since they +# will be included as part of the target_link_libraries command + +set(PX ${CMAKE_STATIC_LIBRARY_PREFIX}) +set(SX ${CMAKE_STATIC_LIBRARY_SUFFIX}) + +# use pkg-config to get the directories and then use these values +# in the find_path() and find_library() calls +if (NOT WIN32) + find_package(PkgConfig) + pkg_check_modules(gladPkg REQUIRED glad) +endif (NOT WIN32) + +find_path(glad_INCLUDE_DIR + NAMES glad.h + PATHS + /usr/include + /usr/local/include + /sw/include + /opt/local/include + HINTS + ${gladPkg_INCLUDE_DIRS} # Generated by pkg-config + ) + +find_library(glad_DYNAMIC_LIBRARY + NAMES glad fontconfig ${gladPkg_LIBRARY} + PATHS + /usr/local + /usr/X11 + /usr + /sw + /opt/local + /usr/lib/x86_64-linux-gnu + HINTS + ${gladPkg_LIBRARY_DIRS} # Generated by pkg-config + PATH_SUFFIXES + lib64 + lib + ) + +find_library(glad_STATIC_LIBRARY + NAMES ${PX}fontconfig${SX} ${PX}glad${SX} ${PX}${gladPkg_LIBRARY}${SX} + PATHS + /usr/local + /usr/X11 + /usr + /sw + /opt/local + /usr/lib/x86_64-linux-gnu + HINTS + ${gladPkg_LIBRARY_DIRS} # Generated by pkg-config + PATH_SUFFIXES + lib64 + lib + ) + +mark_as_advanced( + glad_INCLUDE_DIR + glad_DYNAMIC_LIBRARY + glad_STATIC_LIBRARY + ) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(glad + REQUIRED_VARS glad_DYNAMIC_LIBRARY glad_INCLUDE_DIR + ) + +if (glad_FOUND AND NOT TARGET glad::glad) + add_library(glad::glad UNKNOWN IMPORTED) + set_target_properties(glad::glad PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGE "C" + IMPORTED_LOCATION ${glad_DYNAMIC_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${glad_INCLUDE_DIR}) + + if (glad_STATIC_LIBRARY) + add_library(glad::glad_STATIC UNKNOWN IMPORTED) + set_target_properties(glad::glad_STATIC PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGE "C" + IMPORTED_LOCATION "${glad_STATIC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${glad_INCLUDE_DIR}") + endif (glad_STATIC_LIBRARY) +endif () -- 2.41.0