Browse Source

fix FreeBSD build and clean up some related mess

master
Menche 1 year ago
parent
commit
777bb5857e
1 changed files with 22 additions and 22 deletions
  1. 22
    22
      src/CMakeLists.txt

+ 22
- 22
src/CMakeLists.txt View File

@@ -417,52 +417,52 @@ if(MSVC)
endif(BUILD_SERVER)

else()
set(CFLAGS "-fwrapv -fno-fast-math")
set(OPT_CFLAGS "-O3 -fomit-frame-pointer")

if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CFLAGS "${CFLAGS} -I/usr/local/include")
set(CXXFLAGS "-std=gnu++98")
set(LDFLAGS "${LDFLAGS} -L/usr/local/include")
endif()

if(APPLE)
set(CMAKE_OSX_ARCHITECTURES x86_64 FORCE)
set(ARCH x86_64)
endif()

set(SAFETY_FLAGS "-fwrapv -fno-fast-math")
if(MINGW)
set(SAFETY_LDFLAGS "")
else()
set(SAFETY_LDFLAGS "-Wl,-z,relro,-z,now")
endif()
set(OPT_FLAGS "-O3 -fomit-frame-pointer")
set(OPT_LDFLAGS "-Wl,-O1,--sort-common,-s")

if(ENABLE_SSP)
CHECK_CXX_COMPILER_FLAG("-fstack-protector-strong" HAS_FSTACK_STRONG)
if(HAS_FSTACK_STRONG)
set(SAFETY_FLAGS "${SAFETY_FLAGS} -fstack-protector-strong")
set(CFLAGS "${CFLAGS} -fstack-protector-strong")
else()
set(SAFETY_FLAGS "${SAFETY_FLAGS} -fstack-protector")
set(CFLAGS "${CFLAGS} -fstack-protector")
endif()
endif()
if(ENABLE_SAFESTACK)
CHECK_CXX_COMPILER_FLAG("-fsanitize=safe-stack" HAS_SAFESTACK)
if(HAS_SAFESTACK)
set(SAFETY_FLAGS "${SAFETY_FLAGS} -fsanitize=safe-stack")
set(SAFETY_LDFLAGS "${SAFETY_LDFLAGS} -fsanitize=safe-stack -lrt")
set(CFLAGS "${CFLAGS} -fsanitize=safe-stack")
set(LDFLAGS "${LDFLAGS} -fsanitize=safe-stack -lrt")
endif()
endif()
if(ENABLE_PIE)
set(SAFETY_FLAGS "${SAFETY_FLAGS} -fPIC -fPIE")
set(SAFETY_LDFLAGS "${SAFETY_LDFLAGS} -Wl,-pie")
set(CFLAGS "${CFLAGS} -fPIC -fPIE")
set(LDFLAGS "${LDFLAGS} -Wl,-pie")
endif()
if(CPU_OPTS)
set(OPT_FLAGS "${OPT_FLAGS} -march=${CPUTYPE}")
set(OPT_CFLAGS "${OPT_CFLAGS} -march=${CPUTYPE}")
endif()

set(CMAKE_CXX_FLAGS_RELEASE "${OPT_FLAGS} ${SAFETY_FLAGS} -Wall -DNDEBUG -pipe -fpermissive -Wno-write-strings")
set(CMAKE_C_FLAGS_RELEASE "${OPT_FLAGS} ${SAFETY_FLAGS} -Wall -DNDEBUG -pipe")
set(CMAKE_CXX_FLAGS_DEBUG "${SAFETY_FLAGS} -Wall -O0 -g3 -ggdb -fpermissive -Wno-write-strings")
set(CMAKE_C_FLAGS_DEBUG "${SAFETY_FLAGS} -Wall -O0 -g3 -ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "${OPT_CFLAGS} ${CFLAGS} ${CXXFLAGS} -Wall -DNDEBUG -pipe -fpermissive -Wno-write-strings")
set(CMAKE_C_FLAGS_RELEASE "${OPT_CFLAGS} ${CFLAGS} -Wall -DNDEBUG -pipe")
set(CMAKE_CXX_FLAGS_DEBUG "${CFLAGS} ${CXXFLAGS} -Wall -O0 -g3 -ggdb -fpermissive -Wno-write-strings")
set(CMAKE_C_FLAGS_DEBUG "${CFLAGS} -Wall -O0 -g3 -ggdb")

set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${OPT_LDFLAGS} ${SAFETY_LDFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE ${LDFLAGS})
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${SAFETY_LDFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${LDFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG})


Loading…
Cancel
Save