pe-parse/cmake/compilation_flags.cmake
Alessandro Gario 0d0ca1861c Squash (#56)
- CMake: Refactor, added more warnings.
- Refactor
- Added Windows support
- Added a missing include file for linux.
- Do not set CMAKE_CXX_STANDARD on Windows
- Always initialize the stat struct
- CMake: update the required version, request C++11, disable GNU extensions
- CMake: Add default switch cases, fix GCC warnings.
- Prefer assignment from an empty object when initializing
2017-10-19 12:13:35 -04:00

40 lines
1.3 KiB
CMake

if (WIN32)
list(APPEND DEFAULT_CXX_FLAGS /W4)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
list(APPEND DEFAULT_CXX_FLAGS /Zi)
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
list(APPEND DEFAULT_CXX_FLAGS /WX)
endif ()
else ()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND DEFAULT_CXX_FLAGS
-fPIC
-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization
-Wformat=2 -Winit-self -Wlong-long -Wmissing-declarations -Wmissing-include-dirs -Wcomment
-Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion
-Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror -Wunused -Wuninitialized
-Wno-missing-declarations
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
list(APPEND PROJECT_CXXFLAGS -gdwarf-2 -g3)
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "This is a debug build; enabling -Weverything...")
list(APPEND PROJECT_CXXFLAGS
-Weverything -Wno-c++98-compat -Wno-missing-prototypes
-Wno-missing-variable-declarations -Wno-global-constructors
-Wno-exit-time-destructors -Wno-padded -Wno-error
)
endif ()
endif ()