Skip to content

Commit 0866c6c

Browse files
committed
Add CMake option whether to show extra warnings from clang on Apple
- Set APPLE_CLANG_WARNINGS:BOOL=FALSE to not show extra warnings (TRUE by default)
1 parent 4889d82 commit 0866c6c

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ ENDIF (WITH_GLOBE)
117117
# Compile flag. Make it possible to turn it off.
118118
SET (PEDANTIC TRUE CACHE BOOL "Determines if we should compile in pedantic mode.")
119119

120+
# whether the compiler front-end is clang on Apple (Mac OS X 10.7+)
121+
SET (APPLE_CLANG (APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
122+
SET (APPLE_CLANG_WARNINGS TRUE CACHE BOOL "Whether to show extra compiler warnings on Mac from clang front-end not shown in gcc front-end builds")
123+
120124
# whether unit tests should be build
121125
SET (ENABLE_TESTS TRUE CACHE BOOL "Build unit tests?")
122126

@@ -304,7 +308,12 @@ IF (PEDANTIC)
304308
ADD_DEFINITIONS( /wd4610 ) # user defined constructor required (sqlite3_index_info)
305309
ADD_DEFINITIONS( /wd4706 ) # assignment within conditional expression (pal)
306310
ELSE (MSVC)
307-
ADD_DEFINITIONS( -Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing )
311+
IF (APPLE_CLANG AND NOT APPLE_CLANG_WARNINGS)
312+
SET(CMAKE_C_FLAGS "-Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing ")
313+
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wno-return-type-c-linkage -Wno-overloaded-virtual ")
314+
ELSE (APPLE_CLANG AND NOT APPLE_CLANG_WARNINGS)
315+
ADD_DEFINITIONS( -Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing )
316+
ENDIF (APPLE_CLANG AND NOT APPLE_CLANG_WARNINGS)
308317
# Qt produces lots of warnings with strict aliasing (as of Qt 4.4.0 & GCC 4.3)
309318
# There are redundant declarations in Qt and GDAL
310319
# ADD_DEFINITIONS( -fstrict-aliasing -Wstrict-aliasing=1 -Wredundant-decls )

src/plugins/grass/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ ELSE (WIN32)
1111
ADD_DEFINITIONS(-DHAVE_POSIX_OPENPT)
1212
ENDIF (WIN32)
1313

14+
IF (APPLE_CLANG AND NOT APPLE_CLANG_WARNINGS)
15+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-mismatched-tags ")
16+
ENDIF (APPLE_CLANG AND NOT APPLE_CLANG_WARNINGS)
17+
1418
########################################################
1519
# Files
1620

src/plugins/grass/qtermwidget/k3processcontroller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ K3ProcessController::~K3ProcessController()
123123
close( d->fd[0] );
124124
close( d->fd[1] );
125125
#else
126-
#warning FIXME: why does close() freeze up destruction?
126+
//FIXME: why does close() freeze up destruction?
127127
#endif
128128

129129
delete d;

0 commit comments

Comments
 (0)