I'm looking to have a certain group of variables controlled primarily by one master setting

I want the cache value to be ignored when the user explicitly provides the master variable on the command line and whenever the value of the variable changes.

Put another way: When the user EXPLICITLY specifies or changes the value of MasterVariable, I want to delete the values of ${${AffectedVariables_MasterVariable}} from the cache.

Example:

    Master: "VARIANT"
    Controls: SSE2, SSE3, PACKAGE_FORMAT
    Setting1: VARIANT=Internal, SSE2=OFF, SSE3=OFF, PACKAGE_FORMAT=TGZ
    Setting83: VARIANT=Eval, SSE2=ON, SSE3=ON, PACKAGE_FORMAT=DEB
    Setting509: VARIANT=Client623, SSE=ON, SSE3=OFF, PACKAGE_FORMAT=RPM
    PIZZA: XL
    ...

CMakeCache.txt  values:
  VARIANT=Internal, SSE2=ON, SSE3=OFF, PACKAGE_FORMAT=TGZ, PIZZA=L
$ cmake -DVARIANT=Internal -DPIZZA=Medium
VARIANT=Internal, *SSE2=OFF*, SSE3=OFF, PACKAGE_FORMAT=TGZ, PIZZA=M
(SSE2 was reset to it's default value)
$ cmake -DPACKAGE_FORMAT=RPM -DVARIANT=Internal
VARIANT=Internal, SSE2=OFF, SSE3=OFF, PACKAGE_FORMAT=RPM, PIZZA=M
(All values were reset but the -DPACKAGE_FORMAT overrode the default of that option, non-controlled value, PIZZA, left alone)
$ cmake -DEval
VARIANT=Eval, *SSE2=ON*, *SSE3=ON*, *PACKAGE_FORMAT=DEB*, PIZZA=M
(previously user-specified package_format was reset because it was not explicitly provided)
$ cmake .
(No changes because no VARIANT explicitly specified)

If this was being implemented by deleting the CMakeCache.txt file, then the value of "PIZZA" would be continually clobbered along with all the other values...

Is there a way to do this? I'm wanting to build it something like:

   OPTION(SSE2 "Enable SSE2 instructions" OFF)    -- General default.
   ...

   IF ( VARIANT BECOMES "Internal" )
      DEFAULT(SSE2 OFF)
      DEFAULT(SSE3 OFF)
      DEFAULT(PACKAGE_FORMAT "TGZ")
   ELSEIF ( VARIANT BECOMES "Eval" )
      DEFAULT(SSE2 ON)
      DEFAULT(SSE3 OFF)
      DEFAULT(PACKAGE_FORMAT "DEB")
   ELSEIF ( VARIANT BECOMES "Client623" )
      DEFAULT(SSE2 ON)
      DEFAULT(SSE3 OFF)
      DEFAULT(PACKAGE_FORMAT "RPM")
   ELSEIF ...

Or perhaps the slightly less error-prone:

OPTIONS(<name of control variable> VALUE <value to default to> DEFAULTS
                    VARIABLE:VALUE
                     ...)

This would then complain about the following, because the second OPTIONS has a different list for the same control as the previous incarnation:

    OPTIONS(VARIANT VALUE "Internal" DEFAULTS
                        SSE2 OFF
                        SSE3 OFF
                        PACKAGE_FORMAT "TGZ"
    )
    OPTIONS(VARIANT VALUE "Eval" DEFAULTS
                        SSE2 ON
                        SES3 OFF    # Typo
                        PACKAGE_FORMAT "DEB"
    )
    OPTIONS(VARIANT VALUE "Client623" DEFAULTS
                        SSE2 ON
                        SSE3 OFF
                        PACKAGE_FORMAT "RPM"
    )

Another advantage of this is that the GUI/CCMake could use these to build a drop-down list of "VARIANT" settings, and CMake itself could ascertain that "-DVARIANT=Intrenal" (typo) is invalid (-DVARIANT is used in OPTIONS but there is no OPTIONS that matches Intrenal).

- Oliver

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to