Revision: 40590
          http://brlcad.svn.sourceforge.net/brlcad/?rev=40590&view=rev
Author:   starseeker
Date:     2010-09-16 20:16:26 +0000 (Thu, 16 Sep 2010)

Log Message:
-----------
Detect 32/64 bit platforms via void pointer size, and conditionalize looking 
for 64 bit flags based on that - oddly enough, q64 succeeds on 32 bit OSX so I 
probably need to read up on why that is...

Modified Paths:
--------------
    brlcad/branches/cmake/CMakeLists.txt

Added Paths:
-----------
    brlcad/branches/cmake/misc/CMake/CompilerFlags.cmake

Modified: brlcad/branches/cmake/CMakeLists.txt
===================================================================
--- brlcad/branches/cmake/CMakeLists.txt        2010-09-16 16:27:58 UTC (rev 
40589)
+++ brlcad/branches/cmake/CMakeLists.txt        2010-09-16 20:16:26 UTC (rev 
40590)
@@ -418,6 +418,17 @@
 # be on, as a lot of functionality in BRL-CAD depends on Tk
 OPTION(BRLCAD-ENABLE_TK "Enable features requiring the Tk toolkit" ON)
 MARK_AS_ADVANCED(BRLCAD-ENABLE_TK)
+IF(NOT WIN32)
+       IF (APPLE)
+               IF(NOT BRLCAD-ENABLE_X11 AND NOT BRLCAD-ENABLE_AQUA)
+                       SET(BRLCAD-ENABLE_TK OFF)
+               ENDIF(NOT BRLCAD-ENABLE_X11 AND NOT BRLCAD-ENABLE_AQUA)
+       ELSE (APPLE)
+               IF(NOT BRLCAD-ENABLE_X11)
+                       SET(BRLCAD-ENABLE_TK OFF)
+               ENDIF(NOT BRLCAD-ENABLE_X11)
+       ENDIF(APPLE)
+ENDIF(NOT WIN32)
 
 # Enable features requring OPENGL
 OPTION(BRLCAD-ENABLE_OPENGL "Use OpenGL." ON)
@@ -480,16 +491,13 @@
 MARK_AS_ADVANCED(BRLCAD-ENABLE_STRICT)
 if (BRLCAD-ENABLE_STRICT)
        FILE(APPEND  ${CONFIG_H_FILE} "#define STRICT_FLAGS 1\n")
+       # TODO move this to CompilerFlags.cmake
        SET(STRICT_FLAGS "-pedantic -W -Wall -Werror -Wno-long-long" CACHE 
STRING "strict compiler flags")
 endif (BRLCAD-ENABLE_STRICT)
 
 # Build with O3 compiler optimization
 OPTION(BRLCAD-ENABLE_OPTIMIZED_BUILD "Use optimized compiler settings" OFF)
 MARK_AS_ADVANCED(BRLCAD-ENABLE_OPTIMIZED_BUILD)
-IF(BRLCAD-ENABLE_OPTIMIZED_BUILD)
-       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
-   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
-ENDIF(BRLCAD-ENABLE_OPTIMIZED_BUILD)
 
 # Build with compiler warning flags 
 OPTION(BRLCAD-ENABLE_COMPILER_WARNINGS "Use compiler warning flags" OFF)
@@ -509,12 +517,15 @@
 
 
 
-# Enable/disable 64-bit build settings. This should be 
-# autodetected - turning this option off basically means not to try
-# building 64 bit even if the platform supports it.  Unless you
-# need a 32 bit build on a 64 bit system you shouldn't need to
-# pay attention to this flag.
-OPTION(BRLCAD-ENABLE_64BIT "Test for working 64 bit build settings" ON)
+# Enable/disable 64-bit build settings. This is autodetcted based on
+# the size of the void pointer - don't override this setting unless
+# you know what you are doing.
+IF(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
+       OPTION(BRLCAD-ENABLE_64BIT "64 bit void pointer" ON)
+ELSE(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
+       math(EXPR platform_bit_type "${CMAKE_SIZEOF_VOID_P} * 8")
+       OPTION(BRLCAD-ENABLE_64BIT "${platform_bit_type} bit void pointer" OFF)
+ENDIF(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
 MARK_AS_ADVANCED(BRLCAD-ENABLE_64BIT)
 
 # Take advantage of parallel processors if available - highly recommended
@@ -748,8 +759,8 @@
        FILE(APPEND  ${CONFIG_H_FILE} "#define HAVE_DIRNAME 1\n")
 endif()
 
+INCLUDE(${BRLCAD_CMAKE_DIR}/CompilerFlags.cmake)
 
-
 # Only look for frameworks if we're on an Apple machine - start
 # with the example from the cmake wiki, but will very likely need
 # fleshing out
@@ -914,7 +925,8 @@
        if (BRLCAD-ENABLE_64BIT)
                set(BRLCAD_ARCH_BITSETTING "ON")
        else (BRLCAD-ENABLE_64BIT)
-               set(BRLCAD_ARCH_BITSETTING "OFF (32 bit)")
+               math(EXPR platform_bit_type "${CMAKE_SIZEOF_VOID_P} * 8")
+               set(BRLCAD_ARCH_BITSETTING "OFF (${platform_bit_type} bit)")
        endif (BRLCAD-ENABLE_64BIT)
        SET(BRLCAD_ARCH_BITSETTING_LABEL "Build 64-bit release ")
        SET(BRLCAD-ENABLE_OPTIMIZED_LABEL "Build optimized release ")

Added: brlcad/branches/cmake/misc/CMake/CompilerFlags.cmake
===================================================================
--- brlcad/branches/cmake/misc/CMake/CompilerFlags.cmake                        
        (rev 0)
+++ brlcad/branches/cmake/misc/CMake/CompilerFlags.cmake        2010-09-16 
20:16:26 UTC (rev 40590)
@@ -0,0 +1,74 @@
+INCLUDE(CheckCCompilerFlag)
+
+MACRO(CHECK_C_FLAG flag)
+       STRING(TOUPPER ${flag} UPPER_FLAG)
+       STRING(REGEX REPLACE " " "_" UPPER_FLAG ${UPPER_FLAG})
+       IF(${ARGC} LESS 2)
+               CHECK_C_COMPILER_FLAG(-${flag} ${UPPER_FLAG}_FLAG)
+       ENDIF(${ARGC} LESS 2)
+       IF(NOT ${ARGV1})
+               CHECK_C_COMPILER_FLAG(-${flag} ${UPPER_FLAG}_FLAG)
+       ENDIF(NOT ${ARGV1})
+       IF(${UPPER_FLAG}_FLAG)
+               SET(${UPPER_FLAG}_FLAG "-${flag}")
+               IF(${ARGC} GREATER 1)
+                       MESSAGE("Found - setting ${ARGV1} to -${flag}")
+                       SET(${ARGV1} "-${flag}" CACHE STRING "${ARGV1}" FORCE)
+               ENDIF(${ARGC} GREATER 1)
+       ENDIF(${UPPER_FLAG}_FLAG)
+ENDMACRO()
+
+# try to use -pipe to speed up the compiles
+CHECK_C_FLAG(pipe)
+
+# check for -fno-strict-aliasing
+# XXX - THIS FLAG IS REQUIRED if any level of optimization is
+# enabled with GCC as we do use aliasing and type-punning.
+CHECK_C_FLAG(fno-strict-aliasing)
+
+# check for -fno-common (libtcl needs it on darwin, do we need
+# this anymore with ExternalProject_ADD calling the configure?)
+CHECK_C_FLAG(fno-common)
+
+# check for -fexceptions
+# this is needed to resolve __Unwind_Resume when compiling and
+# linking against openNURBS in librt for some binaries, for
+# example rttherm (i.e. any -static binaries)
+CHECK_C_FLAG(fexceptions)
+
+# check for -ftemplate-depth-NN this is needed in libpc and
+# other code using boost where the template instantiation depth
+# needs to be increased from the default ANSI minimum of 17.
+CHECK_C_FLAG(ftemplate-depth-50)
+
+# dynamic SSE optimizations for NURBS processing
+#
+# XXX disable the SSE flags for now as they can cause illegal instructions.
+#     the test needs to also be tied to run-time functionality since gcc
+#     may still output SSE instructions (e.g., for cross-compiling).
+# CHECK_C_FLAG(msse)
+# CHECK_C_FLAG(msse2)
+
+# 64bit compilation flags
+IF(BRLCAD-ENABLE_64BIT)
+       IF(NOT 64BIT_FLAG)
+               MESSAGE("Checking for 64-bit support:")
+               CHECK_C_FLAG("arch x86_64" 64BIT_FLAG)
+               CHECK_C_FLAG(64 64BIT_FLAG)
+               CHECK_C_FLAG("mabi=64" 64BIT_FLAG)
+               CHECK_C_FLAG(m64 64BIT_FLAG)
+               CHECK_C_FLAG(q64 64BIT_FLAG)
+       ENDIF(NOT 64BIT_FLAG)
+       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${64BIT_FLAG}")
+       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${64BIT_FLAG}")
+ENDIF(BRLCAD-ENABLE_64BIT)
+
+IF(BRLCAD-ENABLE_PROFILING)
+       CHECK_C_FLAG(pg PROFILE_FLAG)
+       CHECK_C_FLAG(p PROFILE_FLAG)
+       CHECK_C_FLAG(prof_gen PROFILE_FLAG)
+       IF(NOT PROFILE_FLAG)
+               MESSAGE("Warning - profiling requested, but don't know how to 
profile with this compiler - disabling.")
+               SET(BRLCAD-ENABLE_PROFILING OFF)
+       ENDIF(NOT PROFILE_FLAG)
+ENDIF(BRLCAD-ENABLE_PROFILING)


Property changes on: brlcad/branches/cmake/misc/CMake/CompilerFlags.cmake
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to