cmake: fix tox library detection

toxcore may be built as either a single monolithic library, or multiple
libraries (core, AV, encrypted savefiles). This updates the CMake find
module to work in both configurations.

Fixes <https://github.com/haavard/tox-weechat/issues/17>.
This commit is contained in:
Håvard Pettersson 2018-04-30 17:18:20 +02:00
parent d0c1904597
commit f9e44f44ee

View file

@ -24,8 +24,10 @@ find_path(Tox_CORE_INCLUDE_DIR tox/tox.h)
find_library(Tox_CORE_LIBRARY toxcore) find_library(Tox_CORE_LIBRARY toxcore)
find_path(Tox_AV_INCLUDE_DIR tox/toxav.h) find_path(Tox_AV_INCLUDE_DIR tox/toxav.h)
find_library(Tox_AV_LIBRARY toxav)
find_path(Tox_ENCRYPTSAVE_INCLUDE_DIR tox/toxencryptsave.h) find_path(Tox_ENCRYPTSAVE_INCLUDE_DIR tox/toxencryptsave.h)
find_library(Tox_ENCRYPTSAVE_LIBRARY toxencryptsave)
if(Tox_CORE_INCLUDE_DIR AND Tox_CORE_LIBRARY) if(Tox_CORE_INCLUDE_DIR AND Tox_CORE_LIBRARY)
set(Tox_CORE_FOUND TRUE) set(Tox_CORE_FOUND TRUE)
@ -36,11 +38,17 @@ endif()
if(Tox_AV_INCLUDE_DIR) if(Tox_AV_INCLUDE_DIR)
set(Tox_AV_FOUND TRUE) set(Tox_AV_FOUND TRUE)
list(APPEND Tox_INCLUDE_DIRS "${Tox_AV_INCLUDE_DIR}") list(APPEND Tox_INCLUDE_DIRS "${Tox_AV_INCLUDE_DIR}")
if(Tox_AV_LIBRARY)
list(APPEND Tox_LIBRARIES "${Tox_AV_LIBRARY}")
endif()
endif() endif()
if(Tox_ENCRYPTSAVE_INCLUDE_DIR) if(Tox_ENCRYPTSAVE_INCLUDE_DIR)
set(Tox_ENCRYPTSAVE_FOUND TRUE) set(Tox_ENCRYPTSAVE_FOUND TRUE)
list(APPEND Tox_INCLUDE_DIRS "${Tox_ENCRYPTSAVE_INCLUDE_DIR}") list(APPEND Tox_INCLUDE_DIRS "${Tox_ENCRYPTSAVE_INCLUDE_DIR}")
if(Tox_ENCRYPTSAVE_LIBRARY)
list(APPEND Tox_LIBRARIES "${Tox_ENCRYPTSAVE_LIBRARY}")
endif()
endif() endif()
list(REMOVE_DUPLICATES Tox_INCLUDE_DIRS) list(REMOVE_DUPLICATES Tox_INCLUDE_DIRS)