I am trying to include two libraries into my project to use them. I'm using CMake with CLion.
The two libraries are: https://github.com/herumi/bls and https://github.com/herumi/mcl
I got the following project setup:
This is the main CMake file:
cmake_minimum_required(VERSION 3.17)
project(blsbenchmark)
set(CMAKE_CXX_STANDARD 14)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(SOURCE_FILES src/main.cpp)
add_executable(blsbenchmark ${SOURCE_FILES})
include(FindPkgConfig)
find_package(bls REQUIRED)
include_directories(${BLS_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${BLS_LIBRARY})
find_package(mcl REQUIRED)
include_directories(${MCL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${MCL_LIBRARY})
The Findbls.cmake
:
set(FIND_BLS_PATHS
/opt/bls)
find_path(BLS_INCLUDE_DIR bls.h
PATH_SUFFIXES include
PATHS ${FIND_BLS_PATHS})
find_library(BLS_LIBRARY
NAMES bls384_256
PATH_SUFFIXES lib
PATHS ${FIND_BLS_PATHS})
The Findmcl.cmake
:
set(FIND_MCL_PATHS
/opt/mcl)
find_path(MCL_INCLUDE_DIR bn_c384_256.h, bn.h
PATH_SUFFIXES include
PATHS ${FIND_MCL_PATHS})
find_library(MCL_LIBRARY
NAMES mclbn384_256
PATH_SUFFIXES lib
PATHS ${FIND_MCL_PATHS})
This setup allows me to include the files of the library very nicely in my project:
However, problems arise because, as you can see, I can link the library files directly in my main (bn.h and bls.h) without their prefixes (bls/bls.h or mcl/bn.h).
Thus, when trying to build this I get a:
fatal error: mcl/bn.h: No such file or directory
11 | #include <mcl/bn.h>
| ^~~~~~~~~~
because the library itself requires the prefix "mcl/bn.h" path.
Thus, the question is how I can include these two libraries (mcl and bls) into my project with the prefix in the path such that this also is compatible with the two libraries.