From 9cdac05e4d0b6d9c549080775f4e32ca7aa03131 Mon Sep 17 00:00:00 2001 From: Nathaniel Filardo Date: Tue, 23 Apr 2019 13:42:10 +0100 Subject: [PATCH] portability: platform compiler flags -mcx16 and -march=native are platform specific. Leave them out if we aren't targeting chips that need it. --- CMakeLists.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c54235..8ad4ecd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,12 @@ if(NOT MSVC) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") target_link_libraries(snmalloc_lib INTERFACE atomic) endif() - target_compile_options(snmalloc_lib INTERFACE -mcx16) + if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") + target_compile_options(snmalloc_lib INTERFACE -mcx16) + elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") + target_compile_options(snmalloc_lib INTERFACE -mcx16) + # XXX elseif ARM? + endif() else() set(WIN8COMPAT FALSE CACHE BOOL "Avoid Windows 10 APIs") if (WIN8COMPAT) @@ -115,7 +120,13 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG") else() - add_compile_options(-march=native -fno-exceptions -fno-rtti -g -ftls-model=initial-exec -fomit-frame-pointer) + add_compile_options(-fno-exceptions -fno-rtti -g -ftls-model=initial-exec -fomit-frame-pointer) + if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") + add_compile_options(-march=native) + elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") + add_compile_options(-march=native) + # XXX elseif ARM? + endif() endif() macro(subdirlist result curdir)