-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
CMakeLists.txt
92 lines (80 loc) · 2.33 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
cmake_minimum_required (VERSION 3.8)
project(bls
VERSION 1.10
LANGUAGES CXX ASM C)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(
BLS_BUILD_TESTING
"Build bls tests"
OFF
)
option(
BLS_BUILD_SAMPLE
"Build bls sample code"
OFF
)
option(
BLS_ETH
"Ethereum 2.0 spec"
"OFF"
)
if(BLS_ETH)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBLS_ETH")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
if(MSVC)
if(MSVC_RUNTIME_DLL)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MD /W4 /Oy /Ox /EHsc /GS- /Zi /DNDEBUG /DNOMINMAX")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /MDd /W4 /DNOMINMAX")
else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MT /W4 /Oy /Ox /EHsc /GS- /Zi /DNDEBUG /DNOMINMAX")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /MTd /W4 /DNOMINMAX")
endif()
else()
if("${CFLAGS_OPT_USER}" STREQUAL "")
set(CFLAGS_OPT_USER "-O3 -DNDEBUG")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith ${CFLAGS_OPT_USER}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
endif()
add_subdirectory(mcl)
foreach(bit IN ITEMS 256 384 384_256)
add_library(bls${bit} SHARED src/bls_c${bit}.cpp)
add_library(bls::bls${bit} ALIAS bls${bit})
target_compile_definitions(bls${bit} PRIVATE BLS_NO_AUTOLINK)
target_include_directories(bls${bit} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_DIR}/include>)
target_link_libraries(bls${bit} PUBLIC mcl::mcl mcl::mcl_st mcl::mclbn${bit})
set_target_properties(bls${bit} PROPERTIES
POSITION_INDEPENDENT_CODE ON
VERSION ${bls_VERSION}
SONAME ${bls_VERSION_MAJOR})
endforeach()
install(TARGETS bls256 bls384 bls384_256
EXPORT blsTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION lib)
install(DIRECTORY include/bls
DESTINATION include)
install(EXPORT blsTargets
FILE blsTargets.cmake
NAMESPACE bls::
DESTINATION lib/cmake/bls)
export(EXPORT blsTargets
FILE blsTargets.cmake
NAMESPACE bls::)
set(CMAKE_EXPORT_PACKAGE_REGISTERY ON)
export(PACKAGE bls)
# Tests
if(BLS_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
# Sample code
if(BLS_BUILD_SAMPLE)
add_subdirectory(sample)
endif()