Better cmake curl finding

This commit is contained in:
timoreo 2023-12-11 20:50:12 +01:00
parent 308b77f2c4
commit 25819c346a
Signed by: timoreo
GPG key ID: 121A72C3512BA288

View file

@ -4,16 +4,12 @@ cmake_minimum_required(VERSION 3.24)
project(matrix-3ds-sdk) project(matrix-3ds-sdk)
add_subdirectory(olm) add_subdirectory(olm)
add_library(matrix-3ds-sdk source/matrixclient.cpp source/memorystore.cpp source/util.cpp) add_library(matrix-3ds-sdk source/matrixclient.cpp source/memorystore.cpp source/util.cpp
source/devicestore.cpp
source/devicestore.h)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(jansson REQUIRED IMPORTED_TARGET jansson) pkg_check_modules(jansson REQUIRED IMPORTED_TARGET jansson)
pkg_check_modules(libcurl REQUIRED IMPORTED_TARGET libcurl)
# libtool usage forcing this little hack target_link_libraries(matrix-3ds-sdk PRIVATE PkgConfig::libcurl PkgConfig::jansson olm ${deps})
file(READ "${DEVKITPRO}/portlibs/3ds/lib/libcurl.la" contents)
if (contents MATCHES "dependency_libs *= *'([^']*)'")
string(STRIP "${CMAKE_MATCH_1}" deps)
string(REGEX REPLACE " +" ";" deps "${deps}")
target_link_libraries(matrix-3ds-sdk PRIVATE curl PkgConfig::jansson olm ${deps})
endif()
target_include_directories(matrix-3ds-sdk PUBLIC source include "${DEVKITPRO}/portlibs/3ds/include/") target_include_directories(matrix-3ds-sdk PUBLIC source include "${DEVKITPRO}/portlibs/3ds/include/")