Skip to content

Commit 59deef2

Browse files
committed
More improvements
1 parent e4e889b commit 59deef2

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

CMakeLists.txt

+25-24
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,38 @@ project(libsecp256k1 VERSION 0.1 LANGUAGES C)
44
set(CMAKE_C_STANDARD 90)
55
set(CMAKE_C_STANDARD_REQUIRED ON)
66

7-
if (CMAKE_C_FLAGS STREQUAL "")
8-
set(CMAKE_C_FLAGS "-g")
9-
endif()
7+
include(CheckCCompilerFlag)
108

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()
1314
endif()
1415

1516
if (APPLE AND NOT BIGNUM_NO)
1617
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()
1827
# These Homebrew packages may be keg-only, meaning that they won't be found
1928
# in expected paths because they may conflict with system files. Ask
2029
# Homebrew where each one is located, then adjust paths accordingly.
2130
execute_process(COMMAND ${brew} --prefix openssl OUTPUT_VARIABLE openssl_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
2231
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()
2632
if (NOT gmp_prefix STREQUAL "")
27-
set(ENV{PKG_CONFIG_PATH} "${gmp_prefix}/lib/pkgconfig:$PKG_CONFIG_PATH")
2833
set(GMP_C_FLAGS "-I${gmp_prefix}/include")
2934
set(GMP_LIBS "-L${gmp_prefix}/lib -lgmp")
3035
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()
3936
endif()
4037
endif()
4138

42-
include(CheckCCompilerFlag)
43-
4439
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W")
4540
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")
4641
set(SAVED_C_FLAGS "${CMAKE_C_FLAGS}")
@@ -84,10 +79,10 @@ option(ASM_NO "don't use any assembly optimization (default is auto)" OFF)
8479

8580
include(CheckTypeSize)
8681
check_type_size("__int128" INT128)
87-
if (NOT INT128 STREQUAL "")
88-
set(INT128 ON)
89-
else()
82+
if (INT128 STREQUAL "")
9083
set(INT128 OFF)
84+
else()
85+
set(INT128 ON)
9186
endif()
9287

9388
include(CheckCSourceCompiles)
@@ -261,15 +256,21 @@ if (INT128)
261256
add_compile_definitions(HAVE___INT128=1)
262257
endif()
263258

259+
include(TestBigEndian)
260+
test_big_endian(BIG_ENDIAN)
261+
if (BIG_ENDIAN)
262+
add_compile_definitions(WORDS_BIGENDIAN=1)
263+
endif()
264+
264265
add_compile_definitions(SECP256K1_BUILD)
265266

266267
message("Using static precomputation: ${PRECOMP}")
267268
message("Using x86_64 ASM: ${ASM_x86_64}")
268269
message("Using ARM ASM: ${ASM_ARM}")
269270
message("Using external ASM: ${USE_EXTERNAL_ASM}")
270271
message("Using 64 bit field implementation: ${FIELD_64BIT}")
271-
message("Using GMP bignum implementation: ${BIGNUM_GMP}")
272272
message("Using 64 bit scalar implementation: ${SCALAR_64BIT}")
273+
message("Using GMP bignum implementation: ${BIGNUM_GMP}")
273274
message("Using endomorphism optimizations: ${ENDOMORPHISM}")
274275
message("Building benchmarks: ${BENCHMARK}")
275276
message("Building for coverage analysis: ${COVERAGE}")

0 commit comments

Comments
 (0)