@@ -13,7 +13,7 @@ if (CMAKE_CROSSCOMPILING)
1313endif ()
1414
1515if (APPLE AND NOT BIGNUM_NO)
16- find_program (" brew" brew)
16+ find_program (brew " brew" )
1717 if (NOT brew STREQUAL "" )
1818 # These Homebrew packages may be keg-only, meaning that they won't be found
1919 # in expected paths because they may conflict with system files. Ask
@@ -29,7 +29,7 @@ if (APPLE AND NOT BIGNUM_NO)
2929 set (GMP_LIBS "-L${gmp_prefix} /lib -lgmp" )
3030 endif ()
3131 else ()
32- find_program (" port" port)
32+ find_program (port " port" )
3333 # if homebrew isn't installed and macports is, add the macports default paths
3434 # as a last resort.
3535 if (NOT port STREQUAL "" )
@@ -101,7 +101,16 @@ if (COVERAGE)
101101 set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} --coverage" )
102102 set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" )
103103else ()
104- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3" )
104+ check_c_compiler_flag("-O3" OPTIMIZE_O3)
105+ if (OPTIMIZE_O3)
106+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3" )
107+ else ()
108+ # MSVC
109+ check_c_compiler_flag("/Ox" OPTIMIZE_OX)
110+ if (OPTIMIZE_OX)
111+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox" )
112+ endif ()
113+ endif ()
105114endif ()
106115
107116set (PRECOMP ${ECMULT_STATIC_PRECOMPUTATION} )
@@ -110,7 +119,7 @@ if (NOT ASM_ARM)
110119 check_c_source_compiles("\
111120 #include <stdint.h> \n\
112121 uint64_t a = 11, tmp; \n\
113- int main(void) {__asm__ __volatile__(\" movq 0x100000000,%1; mulq %%rsi\" : \" +a\" (a) : \" S\" (tmp) : \" cc\" , \" %rdx\" );return 0;}" ASM_64BIT)
122+ int main(void) {__asm__ __volatile__(\" movq $ 0x100000000,%1; mulq %%rsi\" : \" +a\" (a) : \" S\" (tmp) : \" cc\" , \" %rdx\" );return 0;}" ASM_64BIT)
114123 if (ASM_64BIT)
115124 set (ASM_x86_64 ON )
116125 elseif (ASM_x86_64)
@@ -163,9 +172,7 @@ if (ASM_x86_64)
163172 # Define this symbol to enable x86_64 assembly optimizations
164173 add_compile_definitions (USE_ASM_X86_64=1)
165174else ()
166- if (ASM_ARM)
167- set (USE_EXTERNAL_ASM ON )
168- endif ()
175+ set (USE_EXTERNAL_ASM ${ASM_ARM} )
169176 # no asm
170177endif ()
171178
0 commit comments