From 1059d79d73f8298da8975ba68b170d0dce5495de Mon Sep 17 00:00:00 2001 From: Emmanuel Boutin Date: Wed, 14 Dec 2022 14:30:36 +0100 Subject: [PATCH] Add support for CMake source dependency on librw --- cmake/librw-config.cmake.in | 8 ++++++-- src/CMakeLists.txt | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmake/librw-config.cmake.in b/cmake/librw-config.cmake.in index 47b3487..3c3d9e1 100644 --- a/cmake/librw-config.cmake.in +++ b/cmake/librw-config.cmake.in @@ -15,8 +15,12 @@ if(LIBRW_PLATFORM_GL3) endif() if(LIBRW_GL3_GFXLIB STREQUAL "GLFW") - find_package(glfw3 REQUIRED) + if (NOT TARGET glfw) + find_package(glfw3 REQUIRED) + endif() elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2") - find_package(SDL2 REQUIRED) + if (NOT TARGET SDL2::SDL2) + find_package(SDL2 REQUIRED) + endif() endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5b16901..0e3d637 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -150,13 +150,17 @@ set_target_properties(librw if(LIBRW_PLATFORM_GL3) if (LIBRW_GL3_GFXLIB STREQUAL "GLFW") - find_package(glfw3 REQUIRED) + if (NOT TARGET glfw) + find_package(glfw3 REQUIRED) + endif() target_link_libraries(librw PUBLIC glfw ) elseif (LIBRW_GL3_GFXLIB STREQUAL "SDL2") - find_package(SDL2 REQUIRED) + if (NOT TARGET SDL2::SDL2) + find_package(SDL2 REQUIRED) + endif() target_compile_definitions(librw PUBLIC LIBRW_SDL2) target_link_libraries(librw PUBLIC