forked from jonas/tig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
112 lines (93 loc) · 2.89 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
105
106
107
108
109
110
111
112
if (MSVC)
cmake_minimum_required(VERSION 3.26)
else()
cmake_minimum_required(VERSION 3.15)
endif()
set(CMAKE_BUILD_TYPE Debug)
option(BUILD_RELEASE "BUILD_RELEASE" ON)
if(BUILD_RELEASE)
set(CMAKE_BUILD_TYPE Release)
endif()
project (nostril C)
include_directories(${CMAKE_SOURCE_DIR}/ext/secp256k1/include)
#add_subdirectory(${CMAKE_SOURCE_DIR}/ext/secp256k1)
#set_target_properties(libsecp256k1.a PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/ext/secp256k1/sec/libsecp256k1.a)
#add_library(${CMAKE_SOURCE_DIR}/libsecp256k1.a SHARED IMPORTED)
##set(lib_dep ${lib_dep} secp256k1)
# Provide the full path to the library, so CMake knows where to find it.
#set(lib_dep ${lib_dep} ${CMAKE_SOURCE_DIR}/libsecp256k1.a)
#//////////////////////////
#windows.h header file has macros for min and max, nostril defines max
#//////////////////////////
if (MSVC)
add_definitions(-DNOMINMAX)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
endif()
#//////////////////////////
#sources
#//////////////////////////
set(src ${src})
set(src ${src} hex.h)
set(src ${src} proof.h)
set(src ${src} cursor.h)
set(src ${src} endian.h)
set(src ${src} random.h)
set(src ${src} sha256.h)
set(src ${src} sha256.c)
set(src ${src} base64.h)
set(src ${src} base64.c)
set(src ${src} aes.h)
set(src ${src} aes.c)
if (MSVC)
set(src ${src} clock_gettime.h)
endif()
#//////////////////////////
#link with libraries
#lib_dep contains a cascade definition of all the libraries needed to link
#//////////////////////////
set(lib_dep ${lib_dep})
if (MSVC)
set(lib_dep ${lib_dep} ${CMAKE_BINARY_DIR}/ext/secp256k1/src/Debug/libsecp256k1.lib)
set(lib_dep ${lib_dep} Bcrypt.lib)
else()
##set(lib_dep ${lib_dep} ${CMAKE_BINARY_DIR}/libsecp256k1.a)
set(lib_dep ${lib_dep} ${CMAKE_SOURCE_DIR}/libsecp256k1.a)
endif()
#//////////////////////////
#executables
#//////////////////////////
# tool to generate file 'config.h' , generate from a shell with
# configurator.exe > config.h
add_executable(configurator configurator.c)
add_executable(nostril ${src} nostril.c)
target_link_libraries (nostril ${lib_dep})
#//////////////////////////
# generate config.h
#//////////////////////////
add_custom_command(
TARGET configurator
POST_BUILD
COMMAND configurator > config.h
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/config.h" ${CMAKE_SOURCE_DIR}
COMMENT "generating config.h"
)
## add_custom_command(
## TARGET secp256k1
## PRE_BUILD
## COMMAND make secp256k1
## COMMENT "make secp256k1"
## )
execute_process (
COMMAND bash -c "git update-index --assume-unchanged Makefile"
OUTPUT_VARIABLE outVar
)
#//////////////////////////
# Install
#//////////////////////////
install(TARGETS nostril
CONFIGURATIONS Debug
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin)
install(TARGETS nostril
CONFIGURATIONS Release
RUNTIME DESTINATION /usr/local/bin)