Skip to content

Commit

Permalink
Fix build error under clang on Mac
Browse files Browse the repository at this point in the history
- Remove APPLE_CLANG_WARNINGS option
- Add warnings via flags instead of definitions
  • Loading branch information
dakcarto committed Feb 3, 2013
1 parent ba6189c commit 8e7db45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 13 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ ENDIF (WITH_GLOBE)
# Compile flag. Make it possible to turn it off.
SET (PEDANTIC TRUE CACHE BOOL "Determines if we should compile in pedantic mode.")

# whether the compiler front-end is clang on Apple (Mac OS X 10.7+)
SET (APPLE_CLANG (APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
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")

# whether unit tests should be build
SET (ENABLE_TESTS TRUE CACHE BOOL "Build unit tests?")

Expand Down Expand Up @@ -308,13 +304,24 @@ IF (PEDANTIC)
ADD_DEFINITIONS( /wd4610 ) # user defined constructor required (sqlite3_index_info)
ADD_DEFINITIONS( /wd4706 ) # assignment within conditional expression (pal)
ELSE (MSVC)
ADD_DEFINITIONS( -Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing )
IF (APPLE)
# add warnings via flags instead of definitions on Mac (otherwise -Wall can not be overridden per language)
SET(_warnings "-Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_warnings}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_warnings}")
ELSE (APPLE)
ADD_DEFINITIONS( -Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing )
ENDIF (APPLE)
# Qt produces lots of warnings with strict aliasing (as of Qt 4.4.0 & GCC 4.3)
# There are redundant declarations in Qt and GDAL
# ADD_DEFINITIONS( -fstrict-aliasing -Wstrict-aliasing=1 -Wredundant-decls )

IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
ADD_DEFINITIONS(-Wno-return-type-c-linkage) # used in plugins and providers
IF (APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage")
ELSE (APPLE)
ADD_DEFINITIONS(-Wno-return-type-c-linkage) # used in plugins and providers
ENDIF (APPLE)
ENDIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
ENDIF (MSVC)

Expand Down
4 changes: 0 additions & 4 deletions src/plugins/grass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ ELSE (WIN32)
ADD_DEFINITIONS(-DHAVE_POSIX_OPENPT)
ENDIF (WIN32)

IF (APPLE_CLANG AND NOT APPLE_CLANG_WARNINGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-mismatched-tags ")
ENDIF (APPLE_CLANG AND NOT APPLE_CLANG_WARNINGS)

########################################################
# Files

Expand Down

0 comments on commit 8e7db45

Please sign in to comment.