Merge pull request #9461 from Orphis/cmake_cleanup

Fix linking against system GLEW and Snappy
This commit is contained in:
Henrik Rydgård 2017-03-19 18:46:55 +01:00 committed by GitHub
commit 92b0f00cd8
4 changed files with 17 additions and 8 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)
@ -960,8 +960,8 @@ if(ANDROID)
endif()
target_link_libraries(native ${LIBZIP_LIBRARY} ${ZLIB_LIBRARY} ${PNG_LIBRARY} rg_etc1 vjson udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB})
if(TARGET glew)
target_link_libraries(native glew)
if(TARGET Ext::GLEW)
target_link_libraries(native Ext::GLEW)
endif()
if(ANDROID)

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,5 +1,9 @@
#find_package(GLEW)
if(NOT GLEW_FOUND)
find_package(GLEW)
if(GLEW_FOUND)
add_library(system_glew INTERFACE)
add_library(Ext::GLEW ALIAS system_glew)
target_link_libraries(system_glew INTERFACE GLEW::GLEW)
else()
find_package(OpenGL REQUIRED)
add_library(glew STATIC
GL/glew.h
@ -7,6 +11,7 @@ if(NOT GLEW_FOUND)
GL/wglew.h
glew.c
)
add_library(Ext::GLEW ALIAS glew)
target_link_libraries(glew PUBLIC ${OPENGL_LIBRARIES})
target_compile_definitions(glew PUBLIC GLEW_STATIC)
target_include_directories(glew PUBLIC . ${OPENGL_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()