Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1740 - in trunk: CMake SwigInterface
- Date: Mon, 24 Sep 2007 14:45:07 -0600 (MDT)
Author: bigler
Date: Mon Sep 24 14:45:07 2007
New Revision: 1740
Modified:
trunk/CMake/Macros.cmake
trunk/SwigInterface/CMakeLists.txt
Log:
CMake/Macros.cmake
Added MANTA_THREE_PART_VERSION_REGEX variable.
Added COMPARE_VERSION_STRINGS macro.
SwigInterface/CMakeLists.txt
Add -Wextra if the version of SWIG is new enough.
Remove -Wall, as it didn't do what I thought it should (-Wextra does
what I need it to, but this feature is only found in v. > 1.3.32).
Modified: trunk/CMake/Macros.cmake
==============================================================================
--- trunk/CMake/Macros.cmake (original)
+++ trunk/CMake/Macros.cmake Mon Sep 24 14:45:07 2007
@@ -98,3 +98,75 @@
)
ENDMACRO(PYTHON_POST_BUILD_COPY PY_FILE)
+SET(MANTA_THREE_PART_VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+")
+
+# Computes the realtionship between two version strings. A version
+# string is a number delineated by '.'s such as 1.3.2 and 0.99.9.1.
+# You can feed version strings with different number of dot versions,
+# and the shorter version number will be padded with zeros: 9.2 <
+# 9.2.1 will actually compare 9.2.0 < 9.2.1.
+#
+# Input: a_in - value, not variable
+# b_in - value, not variable
+# result_out - variable with value:
+# -1 : a_in < b_in
+# 0 : a_in == b_in
+# 1 : a_in > b_in
+#
+# Written by James Bigler.
+MACRO(COMPARE_VERSION_STRINGS a_in b_in result_out)
+ # Since SEPARATE_ARGUMENTS using ' ' as the separation token,
+ # replace '.' with ' ' to allow easy tokenization of the string.
+ STRING(REPLACE "." " " a ${a_in})
+ STRING(REPLACE "." " " b ${b_in})
+ SEPARATE_ARGUMENTS(a)
+ SEPARATE_ARGUMENTS(b)
+
+ # Check the size of each list to see if they are equal.
+ LIST(LENGTH a a_length)
+ LIST(LENGTH b b_length)
+
+ # Pad the shorter list with zeros.
+
+ # Note that range needs to be one less than the length as the for
+ # loop is inclusive (silly CMake).
+ IF(a_length LESS b_length)
+ # a is shorter
+ SET(shorter a)
+ MATH(EXPR range "${b_length} - 1")
+ MATH(EXPR pad_range "${b_length} - ${a_length} - 1")
+ ELSE(a_length LESS b_length)
+ # b is shorter
+ SET(shorter b)
+ MATH(EXPR range "${a_length} - 1")
+ MATH(EXPR pad_range "${a_length} - ${b_length} - 1")
+ ENDIF(a_length LESS b_length)
+
+ # PAD out if we need to
+ IF(NOT pad_range LESS 0)
+ FOREACH(pad RANGE ${pad_range})
+ # Since shorter is an alias for b, we need to get to it by by
dereferencing shorter.
+ LIST(APPEND ${shorter} 0)
+ ENDFOREACH(pad RANGE ${pad_range})
+ ENDIF(NOT pad_range LESS 0)
+
+ SET(result 0)
+ FOREACH(index RANGE ${range})
+ IF(result EQUAL 0)
+ # Only continue to compare things as long as they are equal
+ LIST(GET a ${index} a_version)
+ LIST(GET b ${index} b_version)
+ # LESS
+ IF(a_version LESS b_version)
+ SET(result -1)
+ ENDIF(a_version LESS b_version)
+ # GREATER
+ IF(a_version GREATER b_version)
+ SET(result 1)
+ ENDIF(a_version GREATER b_version)
+ ENDIF(result EQUAL 0)
+ ENDFOREACH(index)
+
+ # Copy out the return result
+ SET(${result_out} ${result})
+ENDMACRO(COMPARE_VERSION_STRINGS)
Modified: trunk/SwigInterface/CMakeLists.txt
==============================================================================
--- trunk/SwigInterface/CMakeLists.txt (original)
+++ trunk/SwigInterface/CMakeLists.txt Mon Sep 24 14:45:07 2007
@@ -14,7 +14,18 @@
FIND_PACKAGE(SWIG)
IF (SWIG_FOUND)
-
+ EXECUTE_PROCESS(COMMAND ${SWIG_EXECUTABLE} -version
+ OUTPUT_VARIABLE swig-output
+ )
+ # string looks like: SWIG Version 1.3.31
+ STRING(REGEX MATCH "SWIG Version ${MANTA_THREE_PART_VERSION_REGEX}"
version-string ${swig-output})
+ STRING(REGEX MATCH ${MANTA_THREE_PART_VERSION_REGEX} version-string
${version-string})
+
+ COMPARE_VERSION_STRINGS(${version-string} "1.3.31" swig-version-compare)
+ IF(swig-version-compare GREATER 0)
+ # version > 1.3.31
+ SET(warning_extra "-Wextra")
+ ENDIF(swig-version-compare GREATER 0)
###############################################################################
FIND_PACKAGE(PythonLibs)
@@ -39,7 +50,7 @@
# -Wall : Turn on all the warnings.
# -w512 : Turn off warning 512. Overloaded declaration const ignored.
Non-const method at file:line used.
# -DSCI_NOPERSISTENT : Flag for SCIRun headers.
-SET(MANTA_SWIG_FLAGS -Wall -w512 -DSCI_NOPERSISTENT) # Don't put quotes
around it. It needs to be a list.
+SET(MANTA_SWIG_FLAGS ${warning_extra} -w512 -DSCI_NOPERSISTENT) # Don't put
quotes around it. It needs to be a list.
############################################################
# Manta Interface.
- [Manta] r1740 - in trunk: CMake SwigInterface, bigler, 09/24/2007
Archive powered by MHonArc 2.6.16.