shithub: cstory

Download patch

ref: 1e0f0ed99cf55a7cf52657cf7d06ee3ee5e37e3e
parent: 135365f94166d2029d043a99d2235c9722f77d63
author: Clownacy <[email protected]>
date: Wed Apr 1 18:42:27 EDT 2020

Add pkg-config GLFW3 support

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -406,8 +406,32 @@
 endif()
 
 if(BACKEND_PLATFORM MATCHES "GLFW3")
-	find_package(glfw3 REQUIRED)
-	target_link_libraries(CSE2 PRIVATE glfw)
+	if(NOT FORCE_LOCAL_LIBS)
+		find_package(glfw3)
+
+		if (PKG_CONFIG_FOUND)
+			pkg_check_modules(glfw3 QUIET glfw3)
+		endif()
+	endif()
+
+	if(glfw3_FOUND)
+		# pkg-config
+		if (PKG_CONFIG_STATIC_LIBS)
+			message(STATUS "Using system GLFW3 (pkg-config, static)")
+			target_compile_options(CSE2 PRIVATE ${glfw3_STATIC_CFLAGS})
+			target_link_libraries(CSE2 PRIVATE ${glfw3_STATIC_LIBRARIES})
+		else()
+			message(STATUS "Using system GLFW3 (pkg-config, dynamic)")
+			target_compile_options(CSE2 PRIVATE ${glfw3_CFLAGS})
+			target_link_libraries(CSE2 PRIVATE ${glfw3_LIBRARIES})
+		endif()
+	elseif(TARGET glfw)
+		# CMake
+		message(STATUS "Using system GLFW3 (CMake)")
+		target_link_libraries(CSE2 PRIVATE glfw)
+	else()
+		message(FATAL_ERROR "Couldn't find GLFW3")
+	endif()
 endif()
 
 if(BACKEND_PLATFORM MATCHES "SDL2" OR BACKEND_AUDIO MATCHES "SDL2")