From 1e0f0ed99cf55a7cf52657cf7d06ee3ee5e37e3e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 1 Apr 2020 22:42:27 +0100 Subject: [PATCH] Add pkg-config GLFW3 support --- CMakeLists.txt | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4365e462..527193e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -406,8 +406,32 @@ if(NOT FORCE_LOCAL_LIBS) 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")