-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
104 lines (78 loc) · 2.58 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
93
94
95
96
97
98
99
100
101
102
103
104
CMAKE_MINIMUM_REQUIRED(VERSION 3.13)
PROJECT(
ethc
LANGUAGES C
VERSION 1.1.2)
INCLUDE(GNUInstallDirs)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug)
ENDIF()
MESSAGE(STATUS "ethc: build type: ${CMAKE_BUILD_TYPE}")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
SET(ETHC_SOURCE_FILES
src/abi.c
src/account.c
src/address.c
src/ecdsa.c
src/bloom.c
src/internals.c
src/unit.c
src/hex.c
src/rlp.c
src/keccak256.c)
SET(BUILD_SHARED_LIBS ON)
OPTION(ETHC_BUILD_TESTS "Build tests" OFF)
OPTION(ETHC_DISABLE_SHARED_LIBS "Disable shared libs" OFF)
OPTION(ETHC_BUILD_DOCS "Build docs" OFF)
IF(ETHC_DISABLE_SHARED_LIBS)
SET(BUILD_SHARED_LIBS OFF)
ENDIF()
ADD_LIBRARY(${PROJECT_NAME} ${ETHC_SOURCE_FILES})
SET_TARGET_PROPERTIES(
${PROJECT_NAME} PROPERTIES C_STANDARD 90 SOVERSION ${PROJECT_VERSION_MAJOR})
TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-sometimes-uninitialized -Wno-sign-compare)
FIND_PACKAGE(secp256k1 QUIET)
FIND_PACKAGE(gmp QUIET)
FIND_PACKAGE(Git QUIET)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} keccak m
${GMP_LINK_LIBRARIES}
${SECP256K1_LINK_LIBRARIES})
TARGET_INCLUDE_DIRECTORIES(
${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
${GMP_INCLUDE_DIRS} ${SECP256K1_INCLUDE_DIRS})
if(ETHC_BUILD_TESTS)
if(NOT Git_FOUND)
MESSAGE(FATAL_ERROR "ethc: cannot find git")
endif()
MESSAGE(STATUS "ethc: initializing and updating submodules")
EXECUTE_PROCESS(COMMAND "git submodule init")
EXECUTE_PROCESS(COMMAND "git submodule update")
MESSAGE(STATUS "ethc: git version: ${GIT_VERSION_STRING}")
ENDIF()
IF(ETHC_BUILD_TESTS)
ADD_CUSTOM_TARGET(libtap.a ALL
COMMAND make libtap.a
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libtap)
ENABLE_TESTING()
ADD_SUBDIRECTORY(test)
ENDIF()
IF(ETHC_BUILD_DOCS)
ADD_SUBDIRECTORY(docs)
ENDIF()
MESSAGE(STATUS "ethc: SECP256K1_INCLUDE_DIRS: ${SECP256K1_INCLUDE_DIRS}")
MESSAGE(STATUS "ethc: SECP256K1_LINK_LIBRARIES: ${SECP256K1_LINK_LIBRARIES}")
MESSAGE(STATUS "ethc: GMP_INCLUDE_DIRS: ${GMP_INCLUDE_DIRS}")
MESSAGE(STATUS "ethc: GMP_LINK_LIBRARIES: ${GMP_LINK_LIBRARIES}")
ADD_SUBDIRECTORY(libkeccak)
INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
INSTALL(
DIRECTORY ${CMAKE_SOURCE_DIR}/include
DESTINATION .
FILES_MATCHING
PATTERN "*.h")
IF(UNIX OR APPLE OR CYGWIN)
MESSAGE(STATUS "ethc: generating libethc.pc")
CONFIGURE_FILE(libethc.pc.in libethc.pc @ONLY)
INSTALL(FILES ${CMAKE_BINARY_DIR}/libethc.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
ENDIF()