2 if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
6 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
11 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
12 # TODO: Fix Folly ad change to -std=c++11 (ISO C++11), GNU_GCC version enable flags: -ffast-math
13 set(CMAKE_CXX_FLAGS " -Wall -std=gnu++11 -stdlib=libc++ -fno-gcse -fno-omit-frame-pointer -ftemplate-depth-180 -Woverloaded-virtual -Wno-deprecated -Wno-strict-aliasing -Wno-write-strings -Wno-invalid-offsetof -fno-operator-names -Wno-error=array-bounds -Wno-error=switch -Werror=format-security -Wno-unused-result -Wno-sign-compare -Wno-attributes -Wno-maybe-uninitialized -Wno-mismatched-tags -Wno-unknown-warning-option -Wno-return-type-c-linkage -Qunused-arguments")
14 # CMAKE_BUILD_TYPE: http://www.cmake.org/Wiki/CMake_Useful_Variables#Compilers_and_Tools
15 set(CMAKE_C_FLAGS_DEBUG "-g")
16 set(CMAKE_CXX_FLAGS_DEBUG "-g")
17 set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
18 set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
19 set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
20 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
21 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
22 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
24 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
25 execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
27 if (NOT (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8))
28 message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.8 or greater.")
29 elseif(GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
30 # fix problem with GCC 4.9, Changes in gcc Code Optimization Can Cause a Crash
31 # https://kb.isc.org/article/AA-01167
32 set(GNUCC49_OPT "-fno-delete-null-pointer-checks")
36 set(GNUCC_PLAT_OPT "")
38 # TODO: This should really only be set on X86/X64
39 set(GNUCC_PLAT_OPT "-mcrc32")
42 # No optimizations for debug builds.
43 set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb")
44 set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb")
46 # Generic GCC flags and Optional flags
47 set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
48 set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
49 set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
50 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
51 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
52 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
53 set(CMAKE_C_FLAGS "${GNUCC49_OPT} -w")
54 set(CMAKE_CXX_FLAGS "-Wall -std=gnu++11 -fno-gcse -fno-omit-frame-pointer -ftemplate-depth-180 -Woverloaded-virtual -Wno-deprecated -Wno-strict-aliasing -Wno-write-strings -Wno-invalid-offsetof -fno-operator-names -Wno-error=array-bounds -Wno-error=switch -Werror=format-security -Wno-unused-result -Wno-sign-compare -Wno-attributes -Wno-maybe-uninitialized -Wno-unused-local-typedefs -fno-canonical-system-headers -Wno-deprecated-declarations ${GNUCC49_OPT} ${GNUCC_PLAT_OPT}")
56 set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
59 # in debug mode large files can overflow pe/coff sections
60 # this switches binutils to use the pe+ format
61 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj")
62 # stack limit is set at compile time on windows
63 # code expects a minimum of 8 * 1024 * 1024 + 8 for a buffer
65 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--stack,8388616")
68 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
69 set(CMAKE_C_FLAGS "-no-ipo -fp-model precise -wd584 -wd1418 -wd1918 -wd383 -wd869 -wd981 -wd424 -wd1419 -wd444 -wd271 -wd2259 -wd1572 -wd1599 -wd82 -wd177 -wd593 -w")
70 set(CMAKE_CXX_FLAGS "-no-ipo -fp-model precise -wd584 -wd1418 -wd1918 -wd383 -wd869 -wd981 -wd424 -wd1419 -wd444 -wd271 -wd2259 -wd1572 -wd1599 -wd82 -wd177 -wd593 -fno-omit-frame-pointer -ftemplate-depth-180 -Wall -Woverloaded-virtual -Wno-deprecated -w1 -Wno-strict-aliasing -Wno-write-strings -Wno-invalid-offsetof -fno-operator-names")
71 # using Visual Studio C++
72 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")