diff --git a/CMakeLists.txt b/CMakeLists.txt index 193f311..e570198 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,13 +3,18 @@ project(Correct C) include(CheckLibraryExists) include(CheckIncludeFiles) include(CheckCSourceCompiles) +include(CheckCCompilerFlag) if(MSVC) set(LIBM "") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") else(MSVC) set(LIBM "m") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c99 -Wpedantic -Wall") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c99 -Wall") +check_c_compiler_flag(-Wpedantic COMPILER_SUPPORTS_WPEDANTIC) +if(COMPILER_SUPPORTS_WPEDANTIC) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic") +endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0 -fsanitize=address") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie,")