From b54b0d3dbb7095c3ce45eabf4a76c375c1b550b0 Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Sat, 1 Jul 2023 11:27:06 +0800 Subject: [PATCH] follow-up to c0092c7 - fix macos build warnings --- CMakeLists.txt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dafa8aa..d062266 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,21 @@ # Project cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(heapusage VERSION 1.0 LANGUAGES C CXX) -set(COMMON_FLAGS "-funwind-tables -g -Wall -Wextra -Wpedantic -Wshadow -Wpointer-arith \ - -Wcast-qual -Wno-missing-braces -Wswitch-default -Wcast-align \ - -Wunreachable-code -Wuninitialized -Wno-stringop-overflow") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_FLAGS} -Wstrict-prototypes \ - -Wmissing-prototypes") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}") + +set(COMMON_FLAGS "-funwind-tables -g -Wall -Wextra -Wpedantic -Wshadow \ + -Wpointer-arith -Wcast-qual -Wno-missing-braces \ + -Wswitch-default -Wcast-align -Wunreachable-code \ + -Wuninitialized") + +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(TOOLCHAIN_FLAGS "") +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(TOOLCHAIN_FLAGS "-Wno-stringop-overflow") +endif() + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_FLAGS} ${TOOLCHAIN_FLAGS} \ + -Wstrict-prototypes -Wmissing-prototypes") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${TOOLCHAIN_FLAGS}") # C++ compiler flags set(CMAKE_CXX_STANDARD 11)