Skip to content
Snippets Groups Projects
Commit cebe492b authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Fix up linux build flags

parent b1d726b0
No related branches found
No related tags found
No related merge requests found
...@@ -49,11 +49,10 @@ set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release;Debug" CACHE STRING ...@@ -49,11 +49,10 @@ set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release;Debug" CACHE STRING
"Supported build types." FORCE) "Supported build types." FORCE)
# SIMD config # SIMD config
option(USE_SSE41 "Enable usage of the SSE4.1 instruction set" OFF)
option(USE_SSE42 "Enable usage of the SSE4.2 instruction set" ON) option(USE_SSE42 "Enable usage of the SSE4.2 instruction set" ON)
option(USE_AVX "Enable usage of the AVX instruction set" OFF) option(USE_AVX "Enable usage of the AVX instruction set" OFF)
option(USE_AVX2 "Enable usage of the AVX2 instruction set" OFF) option(USE_AVX2 "Enable usage of the AVX2 instruction set" OFF)
if((USE_SSE41 AND USE_AVX) OR (USE_SSE41 AND USE_AVX AND USE_AVX2) OR (USE_AVX AND USE_AVX2)) if((USE_SSE42 AND USE_AVX) OR (USE_SSE42 AND USE_AVX AND USE_AVX2) OR (USE_AVX AND USE_AVX2))
message(FATAL_ERROR "Usage of multiple SIMD flags is unsupported") message(FATAL_ERROR "Usage of multiple SIMD flags is unsupported")
endif() endif()
...@@ -149,7 +148,9 @@ if (WINDOWS) ...@@ -149,7 +148,9 @@ if (WINDOWS)
"/GS /W3 /c /Zc:__cplusplus /Zc:forScope /Zc:rvalueCast /Zc:strictStrings /Zc:ternary /nologo" "/GS /W3 /c /Zc:__cplusplus /Zc:forScope /Zc:rvalueCast /Zc:strictStrings /Zc:ternary /nologo"
) )
if (USE_AVX2) if (ADDRESS_SIZE EQUAL 32)
set(GLOBAL_CXX_FLAGS "${GLOBAL_CXX_FLAGS} /arch:SSE2")
elseif (USE_AVX2)
set(GLOBAL_CXX_FLAGS "${GLOBAL_CXX_FLAGS} /arch:AVX2") set(GLOBAL_CXX_FLAGS "${GLOBAL_CXX_FLAGS} /arch:AVX2")
add_definitions(/DAL_AVX2=1 /DAL_AVX=1) add_definitions(/DAL_AVX2=1 /DAL_AVX=1)
elseif (USE_AVX) elseif (USE_AVX)
...@@ -157,10 +158,8 @@ if (WINDOWS) ...@@ -157,10 +158,8 @@ if (WINDOWS)
add_definitions(/DAL_AVX=1) add_definitions(/DAL_AVX=1)
elseif (USE_SSE42) elseif (USE_SSE42)
add_definitions(/D__SSE3__=1 /D__SSSE3__=1 /D__SSE4__=1 /D__SSE4_1__=1 /D__SSE4_2__=1) add_definitions(/D__SSE3__=1 /D__SSSE3__=1 /D__SSE4__=1 /D__SSE4_1__=1 /D__SSE4_2__=1)
elseif (USE_SSE41) else()
add_definitions(/D__SSE3__=1 /D__SSSE3__=1 /D__SSE4__=1 /D__SSE4_1__=1) add_definitions(/D__SSE3__=1 /D__SSSE3__=1 /D__SSE4__=1 /D__SSE4_1__=1)
elseif (ADDRESS_SIZE EQUAL 32)
set(GLOBAL_CXX_FLAGS "${GLOBAL_CXX_FLAGS} /arch:SSE2")
endif () endif ()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
...@@ -216,13 +215,21 @@ if (WINDOWS) ...@@ -216,13 +215,21 @@ if (WINDOWS)
add_definitions("/DWINVER=${WINVER}" "/D_WIN32_WINNT=${WINVER}") add_definitions("/DWINVER=${WINVER}" "/D_WIN32_WINNT=${WINVER}")
endif (WINDOWS) endif (WINDOWS)
if (LINUX) if (LINUX)
set(CMAKE_SKIP_BUILD_RPATH TRUE) set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(ALCHEMY_GLOBAL_DEFS "-DLL_LINUX=1 -DAPPID=secondlife -DLL_IGNORE_SIGCHLD -D_REENTRANT -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGTK_DISABLE_SINGLE_INCLUDES") set(ALCHEMY_GLOBAL_DEFS "-DLL_LINUX=1 -DAPPID=secondlife -DLL_IGNORE_SIGCHLD -D_REENTRANT -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGTK_DISABLE_SINGLE_INCLUDES")
set(ALCHEMY_GLOBAL_CFLAGS "-fvisibility=hidden -fexceptions -fno-math-errno -fno-strict-aliasing -fsigned-char -g -gz -pthread") set(ALCHEMY_GLOBAL_CFLAGS "-fvisibility=hidden -fexceptions -fno-math-errno -fno-strict-aliasing -fsigned-char -g -gz -pthread")
set(ALCHEMY_GLOBAL_CFLAGS "${ALCHEMY_GLOBAL_CFLAGS} -mfpmath=sse -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -mcx16 -mpopcnt -mpclmul -maes -mxsave -mxsaveopt")
if (USE_AVX2)
set(ALCHEMY_GLOBAL_CFLAGS "${ALCHEMY_GLOBAL_CFLAGS} -mavx2")
elseif (USE_AVX)
set(ALCHEMY_GLOBAL_CFLAGS "${ALCHEMY_GLOBAL_CFLAGS} -mavx")
elseif (USE_SSE42)
set(ALCHEMY_GLOBAL_CFLAGS "${ALCHEMY_GLOBAL_CFLAGS} -mfpmath=sse -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2")
else()
set(ALCHEMY_GLOBAL_CFLAGS "${ALCHEMY_GLOBAL_CFLAGS} -mfpmath=sse -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1")
endif ()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ALCHEMY_GLOBAL_DEFS} ${ALCHEMY_GLOBAL_CFLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ALCHEMY_GLOBAL_DEFS} ${ALCHEMY_GLOBAL_CFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ALCHEMY_GLOBAL_DEFS} ${ALCHEMY_GLOBAL_CFLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ALCHEMY_GLOBAL_DEFS} ${ALCHEMY_GLOBAL_CFLAGS}")
...@@ -263,16 +270,12 @@ if (LINUX) ...@@ -263,16 +270,12 @@ if (LINUX)
endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
CHECK_CXX_COMPILER_FLAG(-Og HAS_DEBUG_OPTIMIZATION) CHECK_CXX_COMPILER_FLAG(-Og HAS_DEBUG_OPTIMIZATION)
CHECK_CXX_COMPILER_FLAG(-fstack-protector-strong HAS_STRONG_STACK_PROTECTOR)
CHECK_CXX_COMPILER_FLAG(-fstack-protector HAS_STACK_PROTECTOR) CHECK_CXX_COMPILER_FLAG(-fstack-protector HAS_STACK_PROTECTOR)
if (${CMAKE_BUILD_TYPE} STREQUAL "Release") if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
if (HAS_STRONG_STACK_PROTECTOR) if (HAS_STACK_PROTECTOR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong")
elseif (HAS_STACK_PROTECTOR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
endif (HAS_STRONG_STACK_PROTECTOR) endif ()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2")
endif (${CMAKE_BUILD_TYPE} STREQUAL "Release") endif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
...@@ -292,7 +295,7 @@ if (LINUX) ...@@ -292,7 +295,7 @@ if (LINUX)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}")
endif () endif ()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND USE_LTO)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
endif() endif()
...@@ -322,7 +325,7 @@ endif (DARWIN) ...@@ -322,7 +325,7 @@ endif (DARWIN)
if (LINUX OR DARWIN) if (LINUX OR DARWIN)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-ignored-qualifiers -Wno-unused-function -Wnon-virtual-dtor") set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-ignored-qualifiers -Wno-unused-function")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-unused-local-typedef -Wno-unknown-warning-option") set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-unused-local-typedef -Wno-unknown-warning-option")
endif() endif()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment