[2579] | 1 | # |
---|
[2626] | 2 | # ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | # > www.orxonox.net < |
---|
[2579] | 4 | # |
---|
[2626] | 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. |
---|
[2579] | 9 | # |
---|
[2626] | 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. |
---|
[2579] | 14 | # |
---|
[2626] | 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. |
---|
[2579] | 18 | # |
---|
| 19 | # |
---|
[2626] | 20 | # Author: |
---|
| 21 | # Reto Grieder, Adrian Friedli |
---|
| 22 | # Description: |
---|
| 23 | # Sets the right compiler and linker flags for GCC. |
---|
[2579] | 24 | # |
---|
| 25 | |
---|
[2638] | 26 | # Determine compiler version |
---|
| 27 | EXEC_PROGRAM( |
---|
| 28 | ${CMAKE_CXX_COMPILER} |
---|
| 29 | ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion |
---|
| 30 | OUTPUT_VARIABLE GCC_VERSION |
---|
| 31 | ) |
---|
| 32 | |
---|
| 33 | # GCC may not support #pragma GCC system_header correctly when using |
---|
| 34 | # templates. According to Bugzilla, it was fixed March 07 but tests |
---|
| 35 | # have confirmed that GCC 4.0.0 does not pose a problem for our cases. |
---|
| 36 | INCLUDE(CompareVersionStrings) |
---|
| 37 | COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.0.0" _compare_result) |
---|
[2640] | 38 | IF(_compare_result LESS 0) |
---|
[2641] | 39 | SET(GCC_NO_SYSTEM_HEADER_SUPPORT TRUE) |
---|
[2638] | 40 | ENDIF() |
---|
| 41 | |
---|
[2621] | 42 | # Also include environment flags. Could cause conflicts though |
---|
| 43 | SET_COMPILER_FLAGS("$ENV{CXXFLAGS}" CXX CACHE) |
---|
| 44 | SET_COMPILER_FLAGS("$ENV{CFLAGS}" C CACHE) |
---|
[2582] | 45 | |
---|
[2621] | 46 | # These flags get added to the flags above |
---|
| 47 | SET_COMPILER_FLAGS(" -g -ggdb -D_DEBUG" Debug CACHE) |
---|
| 48 | SET_COMPILER_FLAGS(" -DNDEBUG" ReleaseAll CACHE) |
---|
| 49 | ADD_COMPILER_FLAGS("-O3" Release CACHE) |
---|
| 50 | ADD_COMPILER_FLAGS("-O2 -g -ggdb" RelWithDebInfo CACHE) |
---|
| 51 | ADD_COMPILER_FLAGS("-Os" MinSizeRel CACHE) |
---|
[2582] | 52 | |
---|
[2621] | 53 | # CMake doesn't seem to set the PIC flags right on certain 64 bit systems |
---|
| 54 | IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") |
---|
| 55 | ADD_COMPILER_FLAGS("-fPIC" CACHE) |
---|
[2624] | 56 | ENDIF() |
---|
[2621] | 57 | |
---|
[2704] | 58 | # We have some uncoformant code, disable an optimisation feature |
---|
| 59 | REMOVE_COMPILER_FLAGS("-fno-strict-aliasing" CACHE) |
---|
| 60 | |
---|
[2690] | 61 | # For GCC older than version 4, do not display sign compare warings |
---|
| 62 | # because of boost::filesystem (which creates about a hundred per include) |
---|
| 63 | ADD_COMPILER_FLAGS("-Wno-sign-compare" GCC_NO_SYSTEM_HEADER_SUPPORT CACHE) |
---|
| 64 | |
---|
[2621] | 65 | # Increase warning level if requested |
---|
[2673] | 66 | IF(EXTRA_COMPILER_WARNINGS) |
---|
[2908] | 67 | REMOVE_COMPILER_FLAGS("-Wall" CACHE) |
---|
| 68 | ADD_COMPILER_FLAGS("-Wextra --Wno-unused-parameter" CACHE) |
---|
[2624] | 69 | ELSE() |
---|
[2908] | 70 | REMOVE_COMPILER_FLAGS("-Wextra --Wno-unused-parameter" CACHE) |
---|
[2621] | 71 | ADD_COMPILER_FLAGS("-Wall" CACHE) |
---|
[2624] | 72 | ENDIF() |
---|
[2621] | 73 | |
---|
| 74 | # General linker flags |
---|
| 75 | SET_LINKER_FLAGS("--no-undefined" CACHE) |
---|