1From 83628b471a1a79dae50bb158fca9448b668dd3a6 Mon Sep 17 00:00:00 2001
2From: Gregory Anders <greg@gpanders.com>
3Date: Wed, 21 Oct 2020 10:43:16 -0600
4Subject: [PATCH] Preserve CXXFLAGS from environment in Mongoose
5
6This allows CXXFLAGS set in the environment to also be used in the CMake
7build process, instead of overwriting them. This is useful in a cross
8compile context where the CXXFLAGS variable might contain necessary
9flags for cross compiling.
10---
11Upstream-Status: Pending
12
13 Mongoose/CMakeLists.txt | 6 +++---
14 1 file changed, 3 insertions(+), 3 deletions(-)
15
16diff --git a/Mongoose/CMakeLists.txt b/Mongoose/CMakeLists.txt
17index 7e134ab..91a7f70 100644
18--- a/Mongoose/CMakeLists.txt
19+++ b/Mongoose/CMakeLists.txt
20@@ -321,14 +321,14 @@ add_test(Unit_Test_EdgeSep ./tests/mongoose_unit_test_edgesep)
21 message(STATUS "CMAKE_CXX_COMPILER: " ${BoldBlue} ${CMAKE_CXX_COMPILER_ID} ${ColourReset})
22 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
23     # using Clang
24-    SET(CMAKE_CXX_FLAGS "-O3 -fwrapv")
25+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fwrapv")
26     # Debug flags for Clang
27     SET(CMAKE_CXX_FLAGS_DEBUG "--coverage -g -fwrapv")
28     SET(CMAKE_C_FLAGS_DEBUG "--coverage -g")
29     SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "--coverage -g")
30 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
31     # using GCC
32-    SET(CMAKE_CXX_FLAGS "-O3 -fwrapv")
33+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fwrapv")
34     # Debug flags for GCC
35     if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.6")
36         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
37@@ -339,7 +339,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
38     SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage")
39 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
40     # using Intel C++
41-    SET(CMAKE_CXX_FLAGS "-O3 -no-prec-div -xHOST -ipo -fwrapv")
42+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -no-prec-div -xHOST -ipo -fwrapv")
43     # Debug flags for Intel
44     SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -fwrapv")
45     SET(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall")
46