From 24680e1c482043651991df008f56dd312bf652cd Mon Sep 17 00:00:00 2001 From: Leonardo Date: Mon, 25 Nov 2024 22:33:27 -0300 Subject: [PATCH] Only have glfw as private if using internal glfw and not static --- cmake/GlfwImport.cmake | 1 + cmake/LibraryConfigurations.cmake | 4 ---- src/CMakeLists.txt | 11 ++++++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmake/GlfwImport.cmake b/cmake/GlfwImport.cmake index f116799f7..f10257c3d 100644 --- a/cmake/GlfwImport.cmake +++ b/cmake/GlfwImport.cmake @@ -12,6 +12,7 @@ endif() # Also adding only on desktop (web also uses glfw but it is more limited and is added using an emcc linker flag) if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MATCHES "Desktop") MESSAGE(STATUS "Using raylib's GLFW") + set(INTERNAL_GLFW ON CACHE INTERNAL "" FORCE) set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake index fb7898306..6206928cb 100644 --- a/cmake/LibraryConfigurations.cmake +++ b/cmake/LibraryConfigurations.cmake @@ -125,7 +125,3 @@ if (NOT GRAPHICS) endif () set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY}) - -if (${PLATFORM} MATCHES "Desktop") - set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw) -endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5ce6ac964..12cc24347 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -90,7 +90,16 @@ if (BUILD_SHARED_LIBS) set_property(TARGET raylib PROPERTY C_VISIBILITY_PRESET hidden) endif () -target_link_libraries(raylib PRIVATE "${LIBS_PRIVATE}") + +# If building as a static lib *AND* using internal GLFW we +# need to set it up as a PRIVATE import so cmake doesn't complain +# it isn't declared on an install rule +if (INTERNAL_GLFW AND BUILD_SHARED_LIBS) + target_link_libraries(raylib PRIVATE glfw) +endif() + +target_link_libraries(raylib PUBLIC "${LIBS_PRIVATE}") + # Sets some compile time definitions for the pre-processor # If CUSTOMIZE_BUILD option is on you will not use config.h by default