forked from Chia-Network/bls-signatures
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve and simplify the build process. (Chia-Network#276)
- Loading branch information
1 parent
ffa9d77
commit 45cca81
Showing
4 changed files
with
25 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,46 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.14 FATAL_ERROR) | ||
set (CMAKE_CXX_STANDARD 17) | ||
|
||
file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) | ||
source_group("SrcHeaders" FILES ${HEADERS}) | ||
|
||
include_directories( | ||
${INCLUDE_DIRECTORIES} | ||
${relic_SOURCE_DIR}/include | ||
${relic_BINARY_DIR}/include | ||
) | ||
|
||
if (GMP_FOUND) | ||
include_directories(${GMP_INCLUDES}) | ||
endif(GMP_FOUND) | ||
|
||
set(C_LIB ${CMAKE_BINARY_DIR}/libbls.a) | ||
|
||
add_library(bls ${CMAKE_CURRENT_SOURCE_DIR}/privatekey.cpp) | ||
|
||
add_library(blstmp ${HEADERS} | ||
add_library(bls | ||
${HEADERS} | ||
${CMAKE_CURRENT_SOURCE_DIR}/privatekey.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/bls.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/elements.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/schemes.cpp | ||
) | ||
|
||
target_compile_definitions(blstmp PRIVATE BLSALLOC_SODIUM=1) | ||
target_link_libraries(blstmp PUBLIC sodium) | ||
|
||
if(MSVC) | ||
add_custom_command( | ||
OUTPUT ${C_LIB} | ||
COMMAND ${CMAKE_AR} /OUT:${C_LIB} $<TARGET_FILE:blstmp> $<TARGET_FILE:relic_s> | ||
DEPENDS blstmp relic_s | ||
) | ||
add_custom_target(combined_custom | ||
DEPENDS ${C_LIB} | ||
) | ||
else() | ||
set(OPREFIX object_) | ||
set(LIBRARIES_TO_COMBINE | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${OPREFIX}$<TARGET_NAME:blstmp> && cd ${OPREFIX}$<TARGET_NAME:blstmp> && ${CMAKE_AR} -x $<TARGET_FILE:blstmp> | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${OPREFIX}$<TARGET_NAME:relic_s> && cd ${OPREFIX}$<TARGET_NAME:relic_s> && ${CMAKE_AR} -x $<TARGET_FILE:relic_s> | ||
) | ||
|
||
find_library(GMP_NAME NAMES libgmp.a) | ||
if(NOT ${GMP_NAME} STREQUAL "GMP_NAME-NOTFOUND") | ||
list(APPEND LIBRARIES_TO_COMBINE COMMAND ${CMAKE_COMMAND} -E make_directory ${OPREFIX}gmp && cd ${OPREFIX}gmp && ${CMAKE_AR} -x ${GMP_NAME}) | ||
endif() | ||
|
||
add_custom_target(combined_custom | ||
${LIBRARIES_TO_COMBINE} | ||
COMMAND ${CMAKE_AR} -rs ${C_LIB} ${OPREFIX}*/*${CMAKE_C_OUTPUT_EXTENSION} | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
DEPENDS blstmp relic_s | ||
) | ||
endif() | ||
target_include_directories(bls | ||
PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
$<$<BOOL:${GMP_FOUND}>:${GMP_INCLUDES}> | ||
${relic_SOURCE_DIR}/include | ||
${relic_BINARY_DIR}/include | ||
) | ||
|
||
add_library(combined STATIC IMPORTED GLOBAL) | ||
add_dependencies(combined combined_custom) | ||
target_link_libraries(bls combined) | ||
target_compile_definitions(bls | ||
PRIVATE | ||
BLSALLOC_SODIUM=1 | ||
) | ||
|
||
set_target_properties(combined | ||
PROPERTIES | ||
IMPORTED_LOCATION ${C_LIB} | ||
target_link_libraries(bls | ||
PUBLIC | ||
relic_s | ||
sodium | ||
) | ||
|
||
file(GLOB includes "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp") | ||
install(DIRECTORY ${relic_SOURCE_DIR}/include/ DESTINATION include/chiabls) | ||
install(DIRECTORY ${relic_BINARY_DIR}/include/ DESTINATION include/chiabls) | ||
install(FILES ${includes} DESTINATION include/chiabls) | ||
install(FILES ${C_LIB} DESTINATION lib) | ||
install(FILES ${HEADERS} DESTINATION include/chiabls) | ||
install(FILES $<TARGET_FILE:bls> DESTINATION lib) | ||
|
||
if(BUILD_BLS_TESTS) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/catch) | ||
add_executable(runtest test.cpp) | ||
target_link_libraries(runtest blstmp relic_s) | ||
target_link_libraries(runtest PRIVATE bls) | ||
endif() | ||
|
||
if(BUILD_BLS_BENCHMARKS) | ||
add_executable(runbench test-bench.cpp) | ||
target_link_libraries(runbench blstmp relic_s) | ||
target_link_libraries(runbench PRIVATE bls) | ||
endif() |