@@ -4,43 +4,38 @@ project(libsecp256k1 VERSION 0.1 LANGUAGES C)
4
4
set (CMAKE_C_STANDARD 90)
5
5
set (CMAKE_C_STANDARD_REQUIRED ON )
6
6
7
- if (CMAKE_C_FLAGS STREQUAL "" )
8
- set (CMAKE_C_FLAGS "-g" )
9
- endif ()
7
+ include (CheckCCompilerFlag)
10
8
11
- if (CMAKE_CROSSCOMPILING )
12
- message (FATAL_ERROR "Currently Cmake makefile doesn't support cross compiling." )
9
+ if (CMAKE_C_FLAGS STREQUAL "" )
10
+ check_c_compiler_flag("-g" DEBUG_OPTION)
11
+ if (DEBUG_OPTION)
12
+ set (CMAKE_C_FLAGS "-g" )
13
+ endif ()
13
14
endif ()
14
15
15
16
if (APPLE AND NOT BIGNUM_NO)
16
17
find_program (brew "brew" )
17
- if (NOT brew STREQUAL "" )
18
+ if (brew STREQUAL "" )
19
+ find_program (port "port" )
20
+ # if homebrew isn't installed and macports is, add the macports default paths
21
+ # as a last resort.
22
+ if (NOT port STREQUAL "" )
23
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem /opt/local/include" )
24
+ set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L/opt/local/lib" )
25
+ endif ()
26
+ else ()
18
27
# These Homebrew packages may be keg-only, meaning that they won't be found
19
28
# in expected paths because they may conflict with system files. Ask
20
29
# Homebrew where each one is located, then adjust paths accordingly.
21
30
execute_process (COMMAND ${brew} --prefix openssl OUTPUT_VARIABLE openssl_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
22
31
execute_process (COMMAND ${brew} --prefix gmp OUTPUT_VARIABLE gmp_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
23
- if (NOT openssl_prefix STREQUAL "" )
24
- set (ENV{PKG_CONFIG_PATH} "${openssl_prefix} /lib/pkgconfig:$PKG_CONFIG_PATH" )
25
- endif ()
26
32
if (NOT gmp_prefix STREQUAL "" )
27
- set (ENV{PKG_CONFIG_PATH} "${gmp_prefix} /lib/pkgconfig:$PKG_CONFIG_PATH" )
28
33
set (GMP_C_FLAGS "-I${gmp_prefix} /include" )
29
34
set (GMP_LIBS "-L${gmp_prefix} /lib -lgmp" )
30
35
endif ()
31
- else ()
32
- find_program (port "port" )
33
- # if homebrew isn't installed and macports is, add the macports default paths
34
- # as a last resort.
35
- if (NOT port STREQUAL "" )
36
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem /opt/local/include" )
37
- set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L/opt/local/lib" )
38
- endif ()
39
36
endif ()
40
37
endif ()
41
38
42
- include (CheckCCompilerFlag)
43
-
44
39
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W" )
45
40
set (WARN_C_FLAGS "-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings" )
46
41
set (SAVED_C_FLAGS "${CMAKE_C_FLAGS} " )
@@ -84,10 +79,10 @@ option(ASM_NO "don't use any assembly optimization (default is auto)" OFF)
84
79
85
80
include (CheckTypeSize)
86
81
check_type_size("__int128" INT128)
87
- if (NOT INT128 STREQUAL "" )
88
- set (INT128 ON )
89
- else ()
82
+ if (INT128 STREQUAL "" )
90
83
set (INT128 OFF )
84
+ else ()
85
+ set (INT128 ON )
91
86
endif ()
92
87
93
88
include (CheckCSourceCompiles)
@@ -261,15 +256,21 @@ if (INT128)
261
256
add_compile_definitions (HAVE___INT128=1)
262
257
endif ()
263
258
259
+ include (TestBigEndian)
260
+ test_big_endian(BIG_ENDIAN)
261
+ if (BIG_ENDIAN)
262
+ add_compile_definitions (WORDS_BIGENDIAN=1)
263
+ endif ()
264
+
264
265
add_compile_definitions (SECP256K1_BUILD)
265
266
266
267
message ("Using static precomputation: ${PRECOMP} " )
267
268
message ("Using x86_64 ASM: ${ASM_x86_64} " )
268
269
message ("Using ARM ASM: ${ASM_ARM} " )
269
270
message ("Using external ASM: ${USE_EXTERNAL_ASM} " )
270
271
message ("Using 64 bit field implementation: ${FIELD_64BIT} " )
271
- message ("Using GMP bignum implementation: ${BIGNUM_GMP} " )
272
272
message ("Using 64 bit scalar implementation: ${SCALAR_64BIT} " )
273
+ message ("Using GMP bignum implementation: ${BIGNUM_GMP} " )
273
274
message ("Using endomorphism optimizations: ${ENDOMORPHISM} " )
274
275
message ("Building benchmarks: ${BENCHMARK} " )
275
276
message ("Building for coverage analysis: ${COVERAGE} " )
0 commit comments