Skip to content

Commit

Permalink
Update library name and optimize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqiNs committed Oct 29, 2024
1 parent ef870e6 commit a925c0e
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 50 deletions.
36 changes: 18 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.20)

# Project name and language.
project(
RBP
LibRBP
VERSION 0.1
LANGUAGES CXX
DESCRIPTION "This library implements a bilinear pairing group using the RELIC library."
Expand Down Expand Up @@ -42,40 +42,40 @@ add_subdirectory(src)
add_subdirectory(tests)

# Install targets and files.
install(TARGETS BP_LIB
EXPORT RBPTargets
install(TARGETS LibRBP
EXPORT LibRBPTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/RBP)

install(EXPORT RBPTargets
FILE RBPTargets.cmake
NAMESPACE RBP::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/RBP)
install(EXPORT LibRBPTargets
FILE LibRBPTargets.cmake
NAMESPACE LibRBP::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibRBP)

# Install the configuration file.
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/RBPConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/RBPConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/RBP)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibRBPConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LibRBPConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibRBP)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/RBPConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LibRBPConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/RBPConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/RBPConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/RBP)
"${CMAKE_CURRENT_BINARY_DIR}/LibRBPConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LibRBPConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibRBP)

# Install the dependency file.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/RBPDependencies.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/RBPDependencies.cmake"
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibRBPDependencies.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LibRBPDependencies.cmake"
@ONLY)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/RBPDependencies.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/RBP)
"${CMAKE_CURRENT_BINARY_DIR}/LibRBPDependencies.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibRBP)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RELIC based Bilinear Pairing Library (RBP)
# RELIC based Bilinear Pairing Library (LibRBP)
[![LibRBP CI](https://github.com/Weiqi97/LibRBP/actions/workflows/ci.yml/badge.svg)](https://github.com/Weiqi97/LibRBP/actions/workflows/ci.yml)

LibRBP is a wrapper designed for constructing bilinear pairing groups using the [RELIC](https://github.com/relic-toolkit/relic) library. It offers a set of slightly simplified APIs to facilitate the implementation and prototyping of pairing-based cryptographic schemes, leveraging the capabilities of the RELIC library.
Expand Down
9 changes: 9 additions & 0 deletions cmake/LibRBPConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(RELIC REQUIRED)
link_libraries(${RLC_LIBRARY})

include("${CMAKE_CURRENT_LIST_DIR}/LibRBPTargets.cmake")

check_required_components(LibRBP)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file defines the dependencies of RBP, the RELIC package.
find_package(RELIC REQUIRED)
link_libraries(${RELIC_LIB})
link_libraries(${RLC_LIBRARY})
9 changes: 0 additions & 9 deletions cmake/RBPConfig.cmake.in

This file was deleted.

6 changes: 3 additions & 3 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
cmake_minimum_required(VERSION 3.20)
project(RBPTest)
project(LibRBPDemo)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find the RBP library.
find_package(RBP REQUIRED)
find_package(LibRBP REQUIRED)

# Create an executable.
add_executable(demo demo.cpp)

# Link the executable with the library.
target_link_libraries(demo PUBLIC RBP::BP_LIB)
target_link_libraries(demo PUBLIC LibRBP::LibRBP)
16 changes: 8 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Get all header and source files.
file(GLOB SOURCE_LIST CONFIGURE_DEPENDS "${RBP_SOURCE_DIR}/src/*.cpp")
file(GLOB SOURCE_LIST CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/*.cpp")

# Make an automatic library - will be static or dynamic based on user setting.
add_library(BP_LIB ${SOURCE_LIST})
add_library(LibRBP ${SOURCE_LIST})

# Add this line:
add_library(RBP::BP_LIB ALIAS BP_LIB)
add_library(LibRBP::LibRBP ALIAS LibRBP)

# We need this directory, and users of our library will need it too.
target_include_directories(BP_LIB PUBLIC
$<BUILD_INTERFACE:${RBP_SOURCE_DIR}/include>
target_include_directories(LibRBP PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_link_libraries(BP_LIB PUBLIC ${RLC_LIBRARY})
target_link_libraries(LibRBP PUBLIC ${RLC_LIBRARY})

# Add this line to ensure RELIC's include directories are correctly passed
target_include_directories(BP_LIB PUBLIC ${RELIC_INCLUDE_DIRS})
target_include_directories(LibRBP PUBLIC ${RLC_INCLUDE_DIRS})

# Add RPATH settings
set_target_properties(BP_LIB PROPERTIES
set_target_properties(LibRBP PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH TRUE)
10 changes: 5 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ include(GoogleTest)
set(GTEST_LIB gtest gtest_main)
# -----------------------------------------------------
add_executable(test_fp test_fp.cpp)
target_link_libraries(test_fp BP_LIB ${GTEST_LIB})
target_link_libraries(test_fp LibRBP ${GTEST_LIB})
gtest_discover_tests(test_fp)
# -----------------------------------------------------
add_executable(test_field test_field.cpp)
target_link_libraries(test_field BP_LIB ${GTEST_LIB})
target_link_libraries(test_field LibRBP ${GTEST_LIB})
gtest_discover_tests(test_field)
# -----------------------------------------------------
add_executable(test_gp test_gp.cpp)
target_link_libraries(test_gp BP_LIB ${GTEST_LIB})
target_link_libraries(test_gp LibRBP ${GTEST_LIB})
gtest_discover_tests(test_gp)
# -----------------------------------------------------
add_executable(test_group test_group.cpp)
target_link_libraries(test_group BP_LIB ${GTEST_LIB})
target_link_libraries(test_group LibRBP ${GTEST_LIB})
gtest_discover_tests(test_group)
# -----------------------------------------------------
add_executable(test_bp test_bp.cpp)
target_link_libraries(test_bp BP_LIB ${GTEST_LIB})
target_link_libraries(test_bp LibRBP ${GTEST_LIB})
gtest_discover_tests(test_bp)
# -----------------------------------------------------
2 changes: 1 addition & 1 deletion tests/test_bp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "bp.hpp"
#include <gtest/gtest.h>
#include "bp.hpp"

TEST(RBPTests, Pairing){
const auto Bp = BP();
Expand Down
2 changes: 1 addition & 1 deletion tests/test_field.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "bp.hpp"
#include <gtest/gtest.h>
#include "bp.hpp"

TEST(FieldElementTests, Add){
// Initialize the scheme.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "bp.hpp"
#include <gtest/gtest.h>
#include "bp.hpp"

TEST(FieldTests, FieldPoint){
// Initialize the scheme.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "bp.hpp"
#include <gtest/gtest.h>
#include "bp.hpp"

TEST(GroupElementTests, G1Element){
// Initialize the scheme.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_group.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "bp.hpp"
#include <gtest/gtest.h>
#include "bp.hpp"

TEST(GroupTests, Pairing){
// Initialize the scheme.
Expand Down

0 comments on commit a925c0e

Please sign in to comment.