From 7d4c8780e566c7e957568bf23bdccf75c1569cb2 Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Sun, 19 Mar 2017 18:38:04 +0100 Subject: [PATCH] cmake: Fix linking against system Snappy --- CMakeLists.txt | 2 +- cmake/Modules/FindSnappy.cmake | 2 +- ext/snappy/CMakeLists.txt | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8dc0e169b..aff0e26b13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -386,7 +386,7 @@ add_subdirectory(ext) include_directories(Common) setup_target_project(Common Common) -target_link_libraries(Common Snappy::Snappy) +target_link_libraries(Common Ext::Snappy) if(WIN32) include_directories(dx9sdk/Include) diff --git a/cmake/Modules/FindSnappy.cmake b/cmake/Modules/FindSnappy.cmake index 312dfb1299..3b906a0a65 100644 --- a/cmake/Modules/FindSnappy.cmake +++ b/cmake/Modules/FindSnappy.cmake @@ -58,7 +58,7 @@ mark_as_advanced( SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIR) -add_library(Snappy::Snappy IMPORTED UNKNOWN GLOBAL) +add_library(Snappy::Snappy IMPORTED UNKNOWN) set_target_properties(Snappy::Snappy PROPERTIES IMPORTED_LOCATION "${SNAPPY_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${SNAPPY_INCLUDE_DIR}" diff --git a/ext/snappy/CMakeLists.txt b/ext/snappy/CMakeLists.txt index e817f73fef..fb1ed966c4 100644 --- a/ext/snappy/CMakeLists.txt +++ b/ext/snappy/CMakeLists.txt @@ -1,6 +1,10 @@ find_package(Snappy) -if(NOT SNAPPY_FOUND) +if(SNAPPY_FOUND) + add_library(system_snappy INTERFACE) + add_library(Ext::Snappy ALIAS system_snappy) + target_link_libraries(system_snappy INTERFACE Snappy::Snappy) +else() add_library(snappy STATIC snappy-c.cpp snappy-c.h @@ -17,5 +21,5 @@ if(NOT SNAPPY_FOUND) target_compile_options(snappy PRIVATE "-O3") endif() - add_library(Snappy::Snappy ALIAS snappy) + add_library(Ext::Snappy ALIAS snappy) endif()