cpm-cmake / CPM.cmake

📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I link libsodium to the c++ project

onqlave-cesc opened this issue · comments

commented
cmake_minimum_required(VERSION 3.14...3.22)

project(onqlave-cpp LANGUAGES CXX)

# --- Import tools ----

include(../cmake/tools.cmake)

# ---- Dependencies ----

include(../cmake/CPM.cmake)

CPMAddPackage(
  NAME libsodium
  VERSION 1.0.18
  URL https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz
)

if(libsodium_ADDED)
    add_library(libsodium INTERFACE IMPORTED)
    target_include_directories(libsodium INTERFACE ${libsodium_SOURCE_DIR}/src/libsodium/include)
endif()

# ---- Create standalone executable ----

file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)

add_library(${PROJECT_NAME} ${sources})

target_link_libraries(${PROJECT_NAME} PRIVATE libsodium)

Here is my CMakeLists.txt file I added in my C++ project. However, I am facing with the error you are not looking for the header file like

fatal error: 'sodium/version.h' file not found
commented

I saw that, it's seem to be can not build that repository. Looking at the _deps folder. libsodium-build folder is empty

Libsodium doesn't support CMake, you can have a look at what I did couple of years ago (or cpm fetch this one, no sure it work tho):
https://github.com/OlivierLDff/libsodium