2017-11-06 03:11:35 +03:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
|
2019-09-15 13:26:26 +07:00
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
|
2017-11-06 03:11:35 +03:00
|
|
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
2018-03-26 11:47:01 +07:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
2023-02-09 13:55:11 +07:00
|
|
|
add_definitions(-DNDEBUG)
|
2018-03-26 11:47:01 +07:00
|
|
|
endif()
|
|
|
|
|
2019-04-16 01:20:50 +07:00
|
|
|
include(CheckSymbolExists)
|
|
|
|
|
2017-11-06 03:11:35 +03:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-strict-aliasing")
|
2018-04-16 15:40:37 +07:00
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast")
|
2017-11-06 03:11:35 +03:00
|
|
|
|
2019-09-15 13:26:26 +07:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexceptions -fno-rtti -Wno-strict-aliasing -Wno-class-memaccess")
|
2018-04-16 15:40:37 +07:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -s")
|
2017-11-06 03:11:35 +03:00
|
|
|
|
2021-08-27 12:36:08 +07:00
|
|
|
if (ARM_TARGET EQUAL 8)
|
2019-02-04 02:23:05 +07:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM8_CXX_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM8_CXX_FLAGS} -flax-vector-conversions")
|
2021-08-27 12:36:08 +07:00
|
|
|
elseif (ARM_TARGET EQUAL 7)
|
2022-01-25 11:11:26 +01:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=neon")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfpu=neon -flax-vector-conversions")
|
2017-11-06 03:11:35 +03:00
|
|
|
else()
|
2020-09-27 08:55:57 +02:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
|
2019-04-16 01:20:50 +07:00
|
|
|
|
2023-02-09 13:55:11 +07:00
|
|
|
add_definitions(-DHAVE_ROTR)
|
2017-11-06 03:11:35 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (WIN32)
|
2019-08-02 10:54:00 +07:00
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
else()
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -Wl,--large-address-aware")
|
|
|
|
endif()
|
2017-11-06 03:11:35 +03:00
|
|
|
else()
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
|
|
|
endif()
|
|
|
|
|
2020-08-20 15:02:31 +07:00
|
|
|
if (BUILD_STATIC)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
endif()
|
|
|
|
|
2023-02-09 13:55:11 +07:00
|
|
|
add_definitions(-D_GNU_SOURCE -DHAVE_BUILTIN_CLEAR_CACHE)
|
2019-10-18 17:39:57 +02:00
|
|
|
|
2017-11-06 03:11:35 +03:00
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
2022-11-15 07:45:54 +01:00
|
|
|
set(CMAKE_C_FLAGS_RELEASE "/MP /MT /O2 /Oi /DNDEBUG /GL")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "/MP /MT /O2 /Oi /DNDEBUG /GL")
|
2017-11-06 03:11:35 +03:00
|
|
|
|
2022-11-15 07:45:54 +01:00
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MP /Ob1 /Zi /DRELWITHDEBINFO")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MP /Ob1 /Zi /DRELWITHDEBINFO")
|
2020-07-29 10:39:58 +02:00
|
|
|
|
2023-02-09 13:55:11 +07:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -DNOMINMAX -DHAVE_ROTR)
|
2017-11-06 03:11:35 +03:00
|
|
|
|
|
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast -funroll-loops -fmerge-all-constants")
|
|
|
|
|
2019-07-19 05:03:14 +07:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexceptions -fno-rtti -Wno-missing-braces")
|
2017-11-06 03:11:35 +03:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast -funroll-loops -fmerge-all-constants")
|
|
|
|
|
2021-08-27 12:36:08 +07:00
|
|
|
if (ARM_TARGET EQUAL 8)
|
2019-02-04 02:23:05 +07:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM8_CXX_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM8_CXX_FLAGS}")
|
2021-08-27 12:36:08 +07:00
|
|
|
elseif (ARM_TARGET EQUAL 7)
|
2017-11-26 22:23:23 +03:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon -march=${CMAKE_SYSTEM_PROCESSOR}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -march=${CMAKE_SYSTEM_PROCESSOR}")
|
2017-11-06 03:11:35 +03:00
|
|
|
else()
|
2020-09-27 08:55:57 +02:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes")
|
2019-04-16 01:20:50 +07:00
|
|
|
|
|
|
|
check_symbol_exists("_rotr" "x86intrin.h" HAVE_ROTR)
|
2019-04-16 02:00:27 +07:00
|
|
|
if (HAVE_ROTR)
|
2023-02-09 13:55:11 +07:00
|
|
|
add_definitions(-DHAVE_ROTR)
|
2019-04-16 02:00:27 +07:00
|
|
|
endif()
|
2017-11-06 03:11:35 +03:00
|
|
|
endif()
|
|
|
|
|
2020-08-23 15:46:56 +07:00
|
|
|
if (BUILD_STATIC)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
endif()
|
|
|
|
|
2017-11-06 03:11:35 +03:00
|
|
|
endif()
|
2019-06-03 18:40:12 +07:00
|
|
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
check_symbol_exists("__builtin___clear_cache" "stdlib.h" HAVE_BUILTIN_CLEAR_CACHE)
|
|
|
|
if (HAVE_BUILTIN_CLEAR_CACHE)
|
2023-02-09 13:55:11 +07:00
|
|
|
add_definitions(-DHAVE_BUILTIN_CLEAR_CACHE)
|
2019-06-03 18:40:12 +07:00
|
|
|
endif()
|
|
|
|
endif()
|