[Orxonox-commit 6419] r11076 - in code/trunk: cmake cmake/tools src
muemart at orxonox.net
muemart at orxonox.net
Tue Jan 19 13:53:36 CET 2016
Author: muemart
Date: 2016-01-19 13:53:36 +0100 (Tue, 19 Jan 2016)
New Revision: 11076
Added:
code/trunk/cmake/CompilerConfigClang.cmake
Modified:
code/trunk/cmake/CompilerConfig.cmake
code/trunk/cmake/tools/PrecompiledHeaderFiles.cmake
code/trunk/src/OrxonoxConfig.cmake
Log:
Add CMake configs for Clang. Most of it is reused from GCC.
Modified: code/trunk/cmake/CompilerConfig.cmake
===================================================================
--- code/trunk/cmake/CompilerConfig.cmake 2016-01-18 21:35:11 UTC (rev 11075)
+++ code/trunk/cmake/CompilerConfig.cmake 2016-01-19 12:53:36 UTC (rev 11076)
@@ -26,10 +26,12 @@
OPTION(EXTRA_COMPILER_WARNINGS "Enable some extra warnings (heavily pollutes the output)" FALSE)
# Configure the compiler specific build options
-IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC)
+IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
INCLUDE(CompilerConfigGCC)
-ELSEIF(MSVC)
+ELSEIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
INCLUDE(CompilerConfigMSVC)
+ELSEIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ INCLUDE(CompilerConfigClang)
ELSE()
MESSAGE(STATUS "Warning: Your compiler is not officially supported.")
ENDIF()
Added: code/trunk/cmake/CompilerConfigClang.cmake
===================================================================
--- code/trunk/cmake/CompilerConfigClang.cmake (rev 0)
+++ code/trunk/cmake/CompilerConfigClang.cmake 2016-01-19 12:53:36 UTC (rev 11076)
@@ -0,0 +1,87 @@
+ #
+ # ORXONOX - the hottest 3D action shooter ever to exist
+ # > www.orxonox.net <
+ #
+ # This program is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU General Public License
+ # as published by the Free Software Foundation; either version 2
+ # of the License, or (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License along
+ # with this program; if not, write to the Free Software Foundation,
+ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ #
+ #
+ # Author:
+ # Martin Mueller
+ # Description:
+ # Sets the right compiler and linker flags for Clang.
+ #
+
+INCLUDE(FlagUtilities)
+
+# Shortcut for CMAKE_CXX_COMPILER_ID MATCHES Clang
+SET(CMAKE_COMPILER_IS_CLANG TRUE)
+
+# Generate compilation database for clang tooling
+SET(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
+
+SET(PCH_COMPILER_SUPPORT TRUE)
+SET(HAVE_COUNTER_MACRO TRUE)
+
+# Also include environment flags. Could cause conflicts though
+SET_COMPILER_FLAGS("$ENV{CXXFLAGS}" CXX CACHE)
+SET_COMPILER_FLAGS("$ENV{CFLAGS}" C CACHE)
+
+# These flags get added to the flags above
+SET_COMPILER_FLAGS(" -g -D_DEBUG" Debug CACHE)
+SET_COMPILER_FLAGS(" -DNDEBUG" ReleaseAll CACHE)
+ADD_COMPILER_FLAGS("-O2 -g" RelForDevs CACHE)
+ADD_COMPILER_FLAGS("-O3 -g" RelWithDebInfo CACHE)
+ADD_COMPILER_FLAGS("-O3" Release CACHE)
+ADD_COMPILER_FLAGS("-Os" MinSizeRel CACHE)
+
+# Introducing c++11
+ADD_COMPILER_FLAGS("-std=c++11" CXX CACHE)
+
+# Never omit frame pointers that could interfere with proper stack traces
+ADD_COMPILER_FLAGS("-fno-omit-frame-pointer" CACHE)
+
+# Enable non standard floating point optimisations
+ADD_COMPILER_FLAGS("-ffast-math" CACHE)
+
+ADD_COMPILER_FLAGS("-DORXONOX_GCC_VISIBILITY -fvisibility=default -fvisibility-inlines-hidden" CACHE)
+
+# We have some unconformant code, disable an optimisation feature
+ADD_COMPILER_FLAGS("-fno-strict-aliasing" CACHE)
+
+# Don't display hundreds of annoying deprecated messages
+ADD_COMPILER_FLAGS("-Wno-deprecated" CXX CACHE)
+
+# Triggers lots of warnings in boost headers
+ADD_COMPILER_FLAGS("-Wno-unused-local-typedefs" CXX CACHE)
+
+# Clang doesn't like some narrowing bullet does
+ADD_COMPILER_FLAGS("-Wno-c++11-narrowing" CXX CACHE)
+
+# Always show why a precompiled header file could not be used
+ADD_COMPILER_FLAGS("-Winvalid-pch" CXX CACHE)
+
+# Increase warning level if requested
+IF(EXTRA_COMPILER_WARNINGS)
+ ADD_COMPILER_FLAGS("-Wall -Wextra -Wno-unused-parameter" CACHE)
+ELSE()
+ REMOVE_COMPILER_FLAGS("-Wextra -Wno-unused-parameter" CACHE)
+ ADD_COMPILER_FLAGS("-Wall" CACHE)
+ENDIF()
+
+# Linker flags
+IF(LINUX)
+ # Don't allow undefined symbols in a shared library
+ SET_LINKER_FLAGS("-Wl,--no-undefined" CACHE)
+ENDIF()
Property changes on: code/trunk/cmake/CompilerConfigClang.cmake
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/trunk/cmake/tools/PrecompiledHeaderFiles.cmake
===================================================================
--- code/trunk/cmake/tools/PrecompiledHeaderFiles.cmake 2016-01-18 21:35:11 UTC (rev 11075)
+++ code/trunk/cmake/tools/PrecompiledHeaderFiles.cmake 2016-01-19 12:53:36 UTC (rev 11076)
@@ -95,9 +95,9 @@
ENDIF(NOT _is_header)
ENDFOREACH(_file)
- ELSEIF(CMAKE_COMPILER_IS_GNU)
+ ELSEIF(CMAKE_COMPILER_IS_GNU OR CMAKE_COMPILER_IS_CLANG)
- # Append the gch-dir to make sure gcc finds the pch file
+ # Append the gch-dir to make sure compiler finds the pch file
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
# Set Compile flags for the other source files
@@ -121,8 +121,8 @@
ENDMACRO(PRECOMPILED_HEADER_FILES_PRE_TARGET)
FUNCTION(PRECOMPILED_HEADER_FILES_POST_TARGET _target_name)
- # This macro is only necessary for GCC
- IF(CMAKE_COMPILER_IS_GNU)
+ # This macro is only necessary for GCC and Clang
+ IF(CMAKE_COMPILER_IS_GNU OR CMAKE_COMPILER_IS_CLANG)
SET(_pch_file "${CMAKE_CURRENT_BINARY_DIR}/${_pch_header_filename}.gch")
SET(_pch_dep_helper_file "${CMAKE_CURRENT_BINARY_DIR}/${_target_name}PCHDependencyHelper.h")
@@ -155,5 +155,5 @@
ADD_CUSTOM_TARGET(${_target_name}PrecompiledHeader DEPENDS ${_pch_file})
ADD_DEPENDENCIES(${_target_name} ${_target_name}PrecompiledHeader)
- ENDIF(CMAKE_COMPILER_IS_GNU)
+ ENDIF(CMAKE_COMPILER_IS_GNU OR CMAKE_COMPILER_IS_CLANG)
ENDFUNCTION(PRECOMPILED_HEADER_FILES_POST_TARGET)
Modified: code/trunk/src/OrxonoxConfig.cmake
===================================================================
--- code/trunk/src/OrxonoxConfig.cmake 2016-01-18 21:35:11 UTC (rev 11075)
+++ code/trunk/src/OrxonoxConfig.cmake 2016-01-19 12:53:36 UTC (rev 11076)
@@ -54,7 +54,7 @@
ENDIF()
ENDIF()
ENDIF()
- IF(CMAKE_COMPILER_IS_GNU)
+ IF(CMAKE_COMPILER_IS_GNU OR CMAKE_COMPILER_IS_CLANG)
INCLUDE(BuildUnitsConfigGCC.cmake)
ELSEIF(MSVC)
INCLUDE(BuildUnitsConfigMSVC.cmake)
More information about the Orxonox-commit
mailing list