kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #41283
[PATCH 4/9] Turn off compiler extensions
We want to be somewhat standards compliant if we can.
There is a small complication, which we work around:
gcc sets __STRICT_ANSI__ in "c++11" mode (the non-strict mode would be
"gnu++11"), which causes the "strdup" definition to go away. If wx < 3.1 is
compiled with GNU extensions, it just forwards the wxCRT strdup function to
system strdup and doesn't create a definition for the wxCRT function, and
when a program is then compiled in strict mode against that, the wxCRT
function is missing.
>From 3.1 onwards, the function is provided unconditionally in wx, so the
workaround is no longer needed there.
---
CMakeLists.txt | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c73c86a29..676733664 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -142,6 +142,7 @@ set( CMAKE_POSITION_INDEPENDENT_CODE ON )
# Global setting: Use C++11
set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -788,6 +789,12 @@ if( KICAD_SCRIPTING_WXPYTHON AND NOT KICAD_SCRIPTING_WXPYTHON_PHOENIX )
endif()
endif()
+if( MINGW AND ( ${wxWidgets_VERSION_STRING} VERSION_LESS 3.1 ) )
+ # Work around a bug in wx < 3.1 -- when wx itself is compiled with
+ # compiler extensions enabled, it assumes these are also available for
+ # applications.
+ add_definitions( -U__STRICT_ANSI__ )
+endif()
if( APPLE )
# Remove app bundles in ${KICAD_BIN} before installing anything new.
References