cmake: Fix linking against system Snappy

This commit is contained in:
Florent Castelli 2017-03-19 18:38:04 +01:00
parent e0cce7602b
commit 7d4c8780e5
3 changed files with 8 additions and 4 deletions

View file

@ -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)

View file

@ -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}"

View file

@ -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()