From a935d1cb2e75827e877bdcc9b48e19aa4f8c1e23 Mon Sep 17 00:00:00 2001 From: accelerated <> Date: Sat, 2 Mar 2019 18:51:25 -0500 Subject: [PATCH] Set CMAKE_CXX_FLAGS only when not set --- CMakeLists.txt | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cee5f7a..1256923 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,17 +7,20 @@ set(CPPKAFKA_VERSION_MINOR 2) set(CPPKAFKA_VERSION "${CPPKAFKA_VERSION_MAJOR}.${CPPKAFKA_VERSION_MINOR}") set(RDKAFKA_MIN_VERSION 0x00090400) -if(MSVC) - # Don't always use Wall, since VC's /Wall is ridiculously verbose. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3") +if (NOT CMAKE_CXX_FLAGS) + # Set default compile flags for the project + if(MSVC) + # Don't always use Wall, since VC's /Wall is ridiculously verbose. + set(CMAKE_CXX_FLAGS "/W3") - # Disable VC secure checks, since these are not really issues - add_definitions("-D_CRT_SECURE_NO_WARNINGS=1") - add_definitions("-D_SCL_SECURE_NO_WARNINGS=1") - add_definitions("-DNOGDI=1") - add_definitions("-DNOMINMAX=1") -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") + # Disable VC secure checks, since these are not really issues + add_definitions("-D_CRT_SECURE_NO_WARNINGS=1") + add_definitions("-D_SCL_SECURE_NO_WARNINGS=1") + add_definitions("-DNOGDI=1") + add_definitions("-DNOMINMAX=1") + else() + set(CMAKE_CXX_FLAGS "-std=c++11 -Wall") + endif() endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")