@@ -4,43 +4,38 @@ project(libsecp256k1 VERSION 0.1 LANGUAGES C)
44set (CMAKE_C_STANDARD 90)
55set (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 ()
1314endif ()
1415
1516if  (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 ()
4037endif ()
4138
42- include (CheckCCompilerFlag)
43- 
4439set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  -W" )
4540set (WARN_C_FLAGS "-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings" )
4641set (SAVED_C_FLAGS "${CMAKE_C_FLAGS} " )
@@ -84,10 +79,10 @@ option(ASM_NO "don't use any assembly optimization (default is auto)" OFF)
8479
8580include (CheckTypeSize)
8681check_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 )
9186endif ()
9287
9388include (CheckCSourceCompiles)
@@ -261,15 +256,21 @@ if (INT128)
261256  add_compile_definitions (HAVE___INT128=1)
262257endif ()
263258
259+ include (TestBigEndian)
260+ test_big_endian(BIG_ENDIAN)
261+ if  (BIG_ENDIAN)
262+   add_compile_definitions (WORDS_BIGENDIAN=1)
263+ endif ()
264+ 
264265add_compile_definitions (SECP256K1_BUILD)
265266
266267message ("Using static precomputation: ${PRECOMP} " )
267268message ("Using x86_64 ASM: ${ASM_x86_64} " )
268269message ("Using ARM ASM: ${ASM_ARM} " )
269270message ("Using external ASM: ${USE_EXTERNAL_ASM} " )
270271message ("Using 64 bit field implementation: ${FIELD_64BIT} " )
271- message ("Using GMP bignum implementation: ${BIGNUM_GMP} " )
272272message ("Using 64 bit scalar implementation: ${SCALAR_64BIT} " )
273+ message ("Using GMP bignum implementation: ${BIGNUM_GMP} " )
273274message ("Using endomorphism optimizations: ${ENDOMORPHISM} " )
274275message ("Building benchmarks: ${BENCHMARK} " )
275276message ("Building for coverage analysis: ${COVERAGE} " )
0 commit comments