[Orxonox-commit 2817] r7520 - code/branches/ois_update/cmake

rgrieder at orxonox.net rgrieder at orxonox.net
Mon Oct 11 12:29:16 CEST 2010


Author: rgrieder
Date: 2010-10-11 12:29:16 +0200 (Mon, 11 Oct 2010)
New Revision: 7520

Modified:
   code/branches/ois_update/cmake/CompilerConfigGCC.cmake
   code/branches/ois_update/cmake/CompilerConfigMSVC.cmake
Log:
Added some useful compiler options found in the Ogre build system.
SSE for GCC and fp:fast for MSVC are commented (not tested yet).

Modified: code/branches/ois_update/cmake/CompilerConfigGCC.cmake
===================================================================
--- code/branches/ois_update/cmake/CompilerConfigGCC.cmake	2010-10-09 15:32:31 UTC (rev 7519)
+++ code/branches/ois_update/cmake/CompilerConfigGCC.cmake	2010-10-11 10:29:16 UTC (rev 7520)
@@ -25,6 +25,7 @@
 
 INCLUDE(FlagUtilities)
 INCLUDE(CompareVersionStrings)
+INCLUDE(CheckCXXCompilerFlag)
 
 # Shortcut for CMAKE_COMPILER_IS_GNUCXX and ..._GNUC
 SET(CMAKE_COMPILER_IS_GNU TRUE)
@@ -63,10 +64,29 @@
 ADD_COMPILER_FLAGS("-Os"                   MinSizeRel     CACHE)
 
 # CMake doesn't seem to set the PIC flags right on certain 64 bit systems
+# Todo: MinGW too?
 IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
   ADD_COMPILER_FLAGS("-fPIC" CACHE)
 ENDIF()
 
+# Use SSE if possible
+#CHECK_CXX_COMPILER_FLAG(-msse _gcc_have_sse)
+#IF(_gcc_have_sse)
+#  ADD_COMPILER_FLAGS("-msse" CACHE)
+#ENDIF()
+
+IF(NOT MINGW)
+  # Have GCC visibility?
+  CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" _gcc_have_visibility)
+  IF(_gcc_have_visibility)
+    # Note: There is a possible bug with the flag in gcc < 4.2 and Debug versions
+    COMPARE_VERSION_STRINGS("${GCC_VERSION}" "4.2.0" _compare_result)
+    IF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" OR _compare_result SMALLER GREATER -1)
+      ADD_COMPILER_FLAGS("-DORXONOX_GCC_VISIBILITY -fvisibility=hidden -fvisibility-inlines-hidden" CACHE)
+    ENDIF()
+  ENDIF(_have_gcc_visibility)
+ENDIF(NOT MINGW)
+
 # We have some unconformant code, disable an optimisation feature
 ADD_COMPILER_FLAGS("-fno-strict-aliasing" CACHE)
 

Modified: code/branches/ois_update/cmake/CompilerConfigMSVC.cmake
===================================================================
--- code/branches/ois_update/cmake/CompilerConfigMSVC.cmake	2010-10-09 15:32:31 UTC (rev 7519)
+++ code/branches/ois_update/cmake/CompilerConfigMSVC.cmake	2010-10-11 10:29:16 UTC (rev 7520)
@@ -70,12 +70,16 @@
 ADD_COMPILER_FLAGS("-D_SCL_SECURE_NO_WARNINGS" CACHE)
 
 # Overwrite CMake default flags here for the individual configurations
-SET_COMPILER_FLAGS("-MDd -Od -Zi -D_DEBUG -RTC1" Debug          CACHE)
-SET_COMPILER_FLAGS("-MD  -O2     -DNDEBUG"       Release        CACHE)
-SET_COMPILER_FLAGS("-MD  -O2 -Zi -DNDEBUG"       RelWithDebInfo CACHE)
-SET_COMPILER_FLAGS("-MD  -O1     -DNDEBUG"       MinSizeRel     CACHE)
-ADD_COMPILER_FLAGS("-D_SECURE_SCL=0"       MSVC9 ReleaseAll     CACHE)
+SET_COMPILER_FLAGS("-MDd -Od -Oi -Zi -D_DEBUG -RTC1" Debug          CACHE)
+SET_COMPILER_FLAGS("-MD  -O2         -DNDEBUG"       Release        CACHE)
+SET_COMPILER_FLAGS("-MD  -O2 -Zi     -DNDEBUG"       RelWithDebInfo CACHE)
+SET_COMPILER_FLAGS("-MD  -O1         -DNDEBUG"       MinSizeRel     CACHE)
+ADD_COMPILER_FLAGS("-D_SECURE_SCL=0"           MSVC9 ReleaseAll     CACHE)
 
+# Enable non standard floating point optimisations
+# Note: It hasn't been checked yet whether we have code that might break
+#ADD_COMPILER_FLAGS("-fp:fast" CACHE)
+
 # Use Link time code generation for Release config if ORXONOX_RELEASE is defined
 IF(ORXONOX_RELEASE)
   ADD_COMPILER_FLAGS("-GL" ReleaseAll CACHE)




More information about the Orxonox-commit mailing list