67 lines
2.1 KiB
CMake
67 lines
2.1 KiB
CMake
macro(append var string)
|
|
set(${var} "${${var}} ${string}")
|
|
endmacro(append)
|
|
|
|
set(SANITIZE_FLAGS "")
|
|
if(SIMDJSON_SANITIZE)
|
|
set(SIMDJSON_SANITIZE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all")
|
|
if (CMAKE_COMPILER_IS_GNUCC)
|
|
# Ubuntu bug for GCC 5.0+ (safe for all versions)
|
|
append(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=gold")
|
|
append(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=gold")
|
|
endif()
|
|
endif()
|
|
|
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)|(x86_64)")
|
|
set (X64 TRUE)
|
|
else ()
|
|
set (X64 FALSE)
|
|
endif ()
|
|
|
|
if(X64)
|
|
message(STATUS "Detected x64 processor: ${CMAKE_SYSTEM_PROCESSOR}")
|
|
if(SIMDJSON_DISABLE_AVX)
|
|
message(STATUS "Disabling AVX. No runtime dispatch.")
|
|
if(NOT MSVC)
|
|
set (OPT_FLAGS "${OPT_FLAGS} -mno-avx -mno-bmi -mpclmul -msse4.2") #westmere
|
|
else()
|
|
set (OPT_FLAGS "${OPT_FLAGS}")
|
|
endif()
|
|
else()
|
|
if(NOT MSVC)
|
|
message(STATUS "Assuming Westmere or better")
|
|
set (OPT_FLAGS "${OPT_FLAGS} -mpclmul -msse4.2")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if(SIMDJSON_EXCEPTIONS)
|
|
set(OPT_FLAGS "${OPT_FLAGS} -DSIMDJSON_EXCEPTIONS=1")
|
|
else()
|
|
message(STATUS "simdjson exception interface turned off. Code that does not check error codes will not compile.")
|
|
set(OPT_FLAGS "${OPT_FLAGS} -DSIMDJSON_EXCEPTIONS=0")
|
|
endif()
|
|
|
|
if(NOT MSVC)
|
|
set(CXXSTD_FLAGS "-std=c++17 -fPIC")
|
|
endif()
|
|
|
|
set(WARNING_FLAGS "-Wall")
|
|
if(NOT MSVC)
|
|
set(WARNING_FLAGS "${WARNING_FLAGS} -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self")
|
|
set(CMAKE_C_FLAGS_DEBUG "-ggdb")
|
|
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
|
|
endif()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${STD_FLAGS} ${OPT_FLAGS} ${INCLUDE_FLAGS} ${WARNING_FLAGS} ${SIMDJSON_SANITIZE_FLAGS} ")
|
|
|
|
if(NOT MSVC)
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb")
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
|
endif()
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXXSTD_FLAGS} ${OPT_FLAGS} ${INCLUDE_FLAGS} ${WARNING_FLAGS} ${SIMDJSON_SANITIZE_FLAGS} ")
|
|
|
|
if(MSVC)
|
|
add_definitions( "${OPT_FLAGS} /W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /wd4267 /wd4244 /wd4113 /nologo")
|
|
endif()
|