[12177] | 1 | # |
---|
| 2 | # ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | # > www.orxonox.net < |
---|
| 4 | # |
---|
| 5 | # This program is free software; you can redistribute it and/or |
---|
| 6 | # modify it under the terms of the GNU General Public License |
---|
| 7 | # as published by the Free Software Foundation; either version 2 |
---|
| 8 | # of the License, or (at your option) any later version. |
---|
| 9 | # |
---|
| 10 | # This program is distributed in the hope that it will be useful, |
---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | # GNU General Public License for more details. |
---|
| 14 | # |
---|
| 15 | # You should have received a copy of the GNU General Public License along |
---|
| 16 | # with this program; if not, write to the Free Software Foundation, |
---|
| 17 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 18 | # |
---|
| 19 | # |
---|
| 20 | # Author: |
---|
| 21 | # Martin Mueller |
---|
| 22 | # Description: |
---|
| 23 | # Sets the right compiler and linker flags for Clang. |
---|
| 24 | # |
---|
| 25 | |
---|
| 26 | INCLUDE(FlagUtilities) |
---|
| 27 | |
---|
| 28 | # Shortcut for CMAKE_CXX_COMPILER_ID MATCHES Clang |
---|
| 29 | SET(CMAKE_COMPILER_IS_CLANG TRUE) |
---|
| 30 | |
---|
| 31 | # Generate compilation database for clang tooling |
---|
| 32 | SET(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) |
---|
| 33 | |
---|
| 34 | SET(PCH_COMPILER_SUPPORT TRUE) |
---|
| 35 | SET(HAVE_COUNTER_MACRO TRUE) |
---|
| 36 | |
---|
| 37 | # Also include environment flags. Could cause conflicts though |
---|
| 38 | SET_COMPILER_FLAGS("$ENV{CXXFLAGS}" CXX CACHE) |
---|
| 39 | SET_COMPILER_FLAGS("$ENV{CFLAGS}" C CACHE) |
---|
| 40 | |
---|
| 41 | # These flags get added to the flags above |
---|
| 42 | SET_COMPILER_FLAGS(" -g -D_DEBUG" Debug CACHE) |
---|
| 43 | SET_COMPILER_FLAGS(" -DNDEBUG" ReleaseAll CACHE) |
---|
| 44 | ADD_COMPILER_FLAGS("-O2 -g" RelForDevs CACHE) |
---|
| 45 | ADD_COMPILER_FLAGS("-O3 -g" RelWithDebInfo CACHE) |
---|
| 46 | ADD_COMPILER_FLAGS("-O3" Release CACHE) |
---|
| 47 | ADD_COMPILER_FLAGS("-Os" MinSizeRel CACHE) |
---|
| 48 | |
---|
| 49 | # Introducing c++11 |
---|
| 50 | ADD_COMPILER_FLAGS("-std=c++11" CXX CACHE) |
---|
| 51 | |
---|
| 52 | # Never omit frame pointers that could interfere with proper stack traces |
---|
| 53 | ADD_COMPILER_FLAGS("-fno-omit-frame-pointer" CACHE) |
---|
| 54 | |
---|
| 55 | # Enable non standard floating point optimisations |
---|
| 56 | ADD_COMPILER_FLAGS("-ffast-math" CACHE) |
---|
| 57 | |
---|
| 58 | ADD_COMPILER_FLAGS("-DORXONOX_GCC_VISIBILITY -fvisibility=default -fvisibility-inlines-hidden" CACHE) |
---|
| 59 | |
---|
| 60 | # We have some unconformant code, disable an optimisation feature |
---|
| 61 | ADD_COMPILER_FLAGS("-fno-strict-aliasing" CACHE) |
---|
| 62 | |
---|
| 63 | # Don't display hundreds of annoying deprecated messages |
---|
| 64 | ADD_COMPILER_FLAGS("-Wno-deprecated" CXX CACHE) |
---|
| 65 | |
---|
| 66 | # Clang doesn't like some narrowing bullet does |
---|
| 67 | ADD_COMPILER_FLAGS("-Wno-c++11-narrowing" CXX CACHE) |
---|
| 68 | |
---|
| 69 | # Always show why a precompiled header file could not be used |
---|
| 70 | ADD_COMPILER_FLAGS("-Winvalid-pch" CXX CACHE) |
---|
| 71 | |
---|
| 72 | # Increase warning level if requested |
---|
| 73 | IF(EXTRA_COMPILER_WARNINGS) |
---|
| 74 | ADD_COMPILER_FLAGS("-Wall -Wextra -Wno-unused-parameter" CACHE) |
---|
| 75 | ELSE() |
---|
| 76 | REMOVE_COMPILER_FLAGS("-Wextra -Wno-unused-parameter" CACHE) |
---|
| 77 | ADD_COMPILER_FLAGS("-Wall" CACHE) |
---|
| 78 | ENDIF() |
---|
| 79 | |
---|
| 80 | # Linker flags |
---|
| 81 | IF(LINUX) |
---|
| 82 | # Don't allow undefined symbols in a shared library |
---|
| 83 | SET_LINKER_FLAGS("-Wl,--no-undefined" CACHE) |
---|
| 84 | ENDIF() |
---|