Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1592 - trunk/CMake


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1592 - trunk/CMake
  • Date: Tue, 31 Jul 2007 13:18:13 -0600 (MDT)

Author: bigler
Date: Tue Jul 31 13:18:12 2007
New Revision: 1592

Modified:
   trunk/CMake/Macros.cmake
Log:
CMake/Macros.cmake

  Better (and correct) implementation of FORCE_ADD_FLAGS.


Modified: trunk/CMake/Macros.cmake
==============================================================================
--- trunk/CMake/Macros.cmake    (original)
+++ trunk/CMake/Macros.cmake    Tue Jul 31 13:18:12 2007
@@ -16,25 +16,42 @@
 
 
 #################################################################
-###  FORCE_ADD_FLAGS(parameter flags)                         ###
-### flags will be added to parameter, but only once           ###
-### This only works for CMake 2.0 and above.                  ###
+#  FORCE_ADD_FLAGS(parameter flags)
+#
+# This will add arguments not found in ${parameter} to the end.  It
+# does not attempt to remove duplicate arguments already existing in
+# ${parameter}.
 #################################################################
 MACRO(FORCE_ADD_FLAGS parameter)
-  FOREACH(arg ${ARGN})
-    SET(TMP ${arg}) #elsewise the Seperate command doesn't work)
+  # Create a separated list of the arguments to loop over
+  SET(p_list ${${parameter}})
+  SEPARATE_ARGUMENTS(p_list)
+  # Make a copy of the current arguments in ${parameter}
+  SET(new_parameter ${${parameter}})
+  # Now loop over each required argument and see if it is in our
+  # current list of arguments.
+  FOREACH(required_arg ${ARGN})
+    # This helps when we get arguments to the function that are
+    # grouped as a string:
+    #
+    # ["-msse -msse2"]  instead of [-msse -msse2]
+    SET(TMP ${required_arg}) #elsewise the Seperate command doesn't work)
     SEPARATE_ARGUMENTS(TMP)
     FOREACH(option ${TMP})
-      # We might already have this option.  Look for it and remove it so when
-      # we add again, it doesn't add another copy.
-      STRING(REGEX REPLACE " ${option} " " " ${parameter}
-        "${${parameter}}")
-      #STRING(REGEX REPLACE "${option}" "" ${parameter}
-      #  "${${parameter}}")
-      SET(${parameter} "${${parameter}} ${option} " CACHE STRING
-        "" FORCE)
+      # Look for the required argument in our list of existing arguments
+      SET(found FALSE)
+      FOREACH(p_arg ${p_list})
+        IF (${p_arg} STREQUAL ${option})
+          SET(found TRUE)
+        ENDIF (${p_arg} STREQUAL ${option})
+      ENDFOREACH(p_arg)
+      IF(NOT found)
+        # The required argument wasn't found, so we need to add it in.
+        SET(new_parameter "${new_parameter} ${option}")
+      ENDIF(NOT found)
     ENDFOREACH(option ${TMP})
-  ENDFOREACH(arg ${ARGN})
+  ENDFOREACH(required_arg ${ARGN})
+  SET(${parameter} ${new_parameter} CACHE STRING "" FORCE)
 ENDMACRO(FORCE_ADD_FLAGS)
 
 # This MACRO is designed to set variables to default values only on




  • [MANTA] r1592 - trunk/CMake, bigler, 07/31/2007

Archive powered by MHonArc 2.6.16.

Top of page