Skip to content
Permalink
Browse files

Enable C++11 only for newer clang versions; match AppleClang for Cmake 3

- Switch STREQUAL conditionals to MATCHES for Clang to handle CMake 3
  introduction of AppleClang compiler ID for Mac-specific Xcode clang,
  which has different reported versions than upstream clang
  • Loading branch information
dakcarto committed Feb 12, 2015
1 parent 1b252d4 commit 5273889d455301085f60eae1d8d6e1dcaa047b61
Showing with 20 additions and 13 deletions.
  1. +14 −7 CMakeLists.txt
  2. +2 −2 src/analysis/CMakeLists.txt
  3. +2 −2 src/core/CMakeLists.txt
  4. +2 −2 src/plugins/grass/CMakeLists.txt
@@ -315,6 +315,10 @@ FIND_PROGRAM(QT_LRELEASE_EXECUTABLE

#############################################################
# enable use of c++11 features where available
# full c++11 support in clang 3.3+: http://clang.llvm.org/cxx_status.html
# for Mac, this is probably Apple LLVM 4.2 (based on LLVM 3.2svn, in XCode 4.6+)
# or definitely Apple LLVM 5.0 (based on LLVM 3.3svn, in Xcode 5+):
# https://gist.github.com/yamaya/2924292

IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
@@ -323,9 +327,12 @@ IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ENDIF()
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET(USE_CXX_11 TRUE)
#deprecated-register breaks Travis builds
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-error=c++11-narrowing -Wno-deprecated-register")
IF ((NOT APPLE AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "3.2")
OR (APPLE AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.1"))
SET(USE_CXX_11 TRUE)
#deprecated-register breaks Travis builds
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-error=c++11-narrowing -Wno-deprecated-register")
ENDIF()
ELSE()
SET(USE_CXX_11 FALSE)
ENDIF()
@@ -368,9 +375,9 @@ IF (PEDANTIC)
# There are redundant declarations in Qt and GDAL
# ADD_DEFINITIONS( -fstrict-aliasing -Wstrict-aliasing=1 -Wredundant-decls )

IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-overloaded-virtual")
ENDIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

# add any extra CXXFLAGS flags set by user. can be -D CXX_EXTRA_FLAGS or environment variable
# command line -D option overrides environment variable
@@ -387,13 +394,13 @@ IF (PEDANTIC)

ENDIF (PEDANTIC)

IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Qunused-arguments")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Qunused-arguments")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Qunused-arguments")
ENDIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
# spatialite crashes on ppc - see bugs.debian.org/603986
@@ -71,14 +71,14 @@ IF (PEDANTIC AND MSVC)
)
ENDIF (PEDANTIC AND MSVC)

IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET_SOURCE_FILES_PROPERTIES(
interpolation/qgstininterpolator.cpp
interpolation/NormVecDecorator.cc
interpolation/CloughTocherInterpolator.cc
PROPERTIES COMPILE_FLAGS "-Wno-overloaded-virtual"
)
ENDIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

QT4_WRAP_CPP(QGIS_ANALYSIS_MOC_SRCS ${QGIS_ANALYSIS_MOC_HDRS})

@@ -299,10 +299,10 @@ IF (NOT QT5_BUILD)
)
ENDIF (NOT QT5_BUILD)

IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# spatialindex headers produce warnings
SET_SOURCE_FILES_PROPERTIES(qgsspatialindex.cpp PROPERTIES COMPILE_FLAGS -Wno-overloaded-virtual)
ENDIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

IF (WITH_INTERNAL_QEXTSERIALPORT)
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
@@ -99,7 +99,7 @@ IF(NOT WIN32)
qtermwidget/qtermwidget.h
)

IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_BINARY_DIR}/qtermwidget/moc_Pty.cxx
qtermwidget/Pty.cpp
@@ -108,7 +108,7 @@ IF(NOT WIN32)
qtermwidget/k3process.cpp
PROPERTIES COMPILE_FLAGS "-Wno-overloaded-virtual -Wno-mismatched-tags"
)
ENDIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
ENDIF(NOT WIN32)

SET (GRASS_PLUGIN_RCCS qgsgrass_plugin.qrc)

0 comments on commit 5273889

Please sign in to comment.
You can’t perform that action at this time.