Переглянути джерело

Ensure CTK_ENABLE_Python_Wrapping remain set when CTK_BUILD_ALL is ON

When CTK was configured with CTK_BUILD_ALL or CTK_BUILD_ALL_LIBRARIES, all
expected options were properly set after the first configuration. It's
after configuring the project a second time (without changing any options)
that problems appeared.

Example
=======

Before this commit, the option CTK_ENABLE_Python_Wrapping was
disabled after configuring a second time.

$ git clone git://github.com/commontk/CTK
$ mkdir CTK-build
$ cd CTK-build
$ cmake -DCTK_BUILD_ALL_LIBRARIES:BOOL=ON -DCTK_ENABLE_Python_Wrapping:BOOL=ON ../CTK

[...]

$ cmake .
Full support for [CTK_ENABLE_Python_Wrapping] disabled

Details
=======

The highlevel option (CTK_ENABLE_*) were set before the regular toolkit
options (CTK_LIB_*, CTK_APP_*, CTK_PLUGIN_*). If configured again and if associated expression
evaluated to false, the high-level option was forced to OFF.

For example, the option CTK_ENABLE_Python_Wrapping was depending on
CTK_LIB_Scripting/Python/Core. On following configuration, if CTK_LIB_Scripting/Python/Core
was false, CTK_ENABLE_Python_Wrapping was forced to OFF. This behavior was observed.

Since setting CTK_BUILD_ALL or CTK_BUILD_ALL_* options are NOT forcing  any variables in the
cache [1], when option like CTK_LIB_Scripting/Python/Core were specified, they were set to ON in
the current scope. On the following configuration, the code allowing to
specify the CTK_ENABLE_Python_Wrapping was forcing the option CTK_ENABLE_Python_Wrapping to be OFF
since CTK_LIB_Scripting/Python/Core was also OFF.

By moving the definition of the high level variables after the definition of the CTK_LIB_*,
CTK_APP_* and CTK_PLUGIN_* variables, we ensure that these same variables will be set in the current
scope when on of the CTK_BUILD_ALL_* option are enabled, doing so will then ensure that the highlevel
option are not forced to false when not required.

Finally, let's also not that high-level option like CTK_ENABLE_Widgets were not impacted by that issue
because they were dependent on option being already systematically forced in the cache. Preventing
the option from being forced into the cache in the "ctk_option" macro ensure that no variables is set
in the cache when either high level or build all options are set.

[1] The existing cache variable are "shadowed", it allows to keep the state
of the CTK_LIB_*, CTK_APP_*, CTK_PLUGIN_* variables untouched while trying to build the complete tree.

See #258
Jean-Christophe Fillion-Robin 11 роки тому
батько
коміт
189603ad4b
2 змінених файлів з 50 додано та 53 видалено
  1. 2 5
      CMake/ctkMacroOptionUtils.cmake
  2. 48 48
      CMakeLists.txt

+ 2 - 5
CMake/ctkMacroOptionUtils.cmake

@@ -23,11 +23,8 @@ macro(ctk_option option_prefix name doc default)
   set(_logical_expr ${ARGN})
   if(_logical_expr AND NOT ${option_prefix}_${name})
     if(${ARGN})
-      # Force the option to ON. This is okay since the
-      # logical expression should contain a CTK_ENABLE_*
-      # option value, which requires the current option to be ON.
-      get_property(_doc_string CACHE ${option_prefix}_${name} PROPERTY HELPSTRING)
-      set(${option_prefix}_${name} ON CACHE BOOL ${_doc_string} FORCE)
+      # Set the variable ON.
+      set(${option_prefix}_${name} ON)
       # Generate user-friendly message
       set(enabling_msg)
       ctk_option_logical_expression_to_message(enabling_msg "${ARGN}")

+ 48 - 48
CMakeLists.txt

@@ -407,35 +407,6 @@ endif()
 #
 
 #-----------------------------------------------------------------------------
-# High-Level CTK options
-
-# The ctk_enable_option macro expects a logical expression after the first
-# three arguments. This expression should only contain build option names
-# which belong to leafs in the required dependency tree.
-
-# The CTK infrastructure for high-level DICOM support. This includes
-# DICOM indexing, networking, and GUI widgets.
-ctk_enable_option(DICOM "Enable default DICOM support" OFF
-                  CTK_LIB_DICOM/Widgets)
-
-# The CTK infrastructure for building a DICOM Part 19 compliant application
-# host and/or hosted application. This will not enable any example plugins
-# or executables (enable CTK_ENABLE_EXAMPLES for that).
-ctk_enable_option(DICOMApplicationHosting "Enable DICOM Part 19 Application Hosting support" OFF
-                  CTK_PLUGIN_org.commontk.dah.host AND CTK_PLUGIN_org.commontk.dah.hostedapp)
-
-# The CTK Qt Widgets. This will enable the Qt Widget library only.
-# It might trigger the enabling of other widget libraries in combination
-# with other enabled options.
-ctk_enable_option(Widgets "Enable Qt Widget libraries" OFF
-                  CTK_LIB_Widgets)
-
-# The CTK Plugin Framework, a dynamic component system based on OSGi.
-# This will enable only the framework itself.
-ctk_enable_option(PluginFramework "Enable Plugin Framework" OFF
-                  CTK_LIB_PluginFramework)
-
-#-----------------------------------------------------------------------------
 # Special "BUILD ALL" options
 
 # Build all CTK plug-ins
@@ -462,25 +433,6 @@ endif()
 #-----------------------------------------------------------------------------
 # Other options
 
-# The CTK Python Wrapping
-ctk_enable_option(Python_Wrapping "Wrap CTK classes using Qt meta-object system into Python language" OFF
-                  CTK_LIB_Scripting/Python/Core)
-mark_as_superbuild(CTK_ENABLE_Python_Wrapping)
-
-# Build examples
-# Create the logical expression containing the minium set of required options
-# for the CTK_BUILD_EXAMPLES option to be ON
-set(_build_examples_logical_expr)
-foreach(_app ${CTK_ENABLED_APPS})
-  list(APPEND _build_examples_logical_expr CTK_APP_${_app} AND)
-endforeach()
-if(_build_examples_logical_expr)
-  list(REMOVE_AT _build_examples_logical_expr -1)
-endif()
-
-ctk_enable_option_raw(CTK_BUILD_EXAMPLES "Build examples for CTK components" OFF
-                  ${_build_examples_logical_expr})
-
 # Git protocol option
 option(CTK_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." ON)
 mark_as_advanced(CTK_USE_GIT_PROTOCOL)
@@ -741,6 +693,54 @@ if(CTK_USE_CONTRIBUTED_PLUGINS)
 endif()
 
 #-----------------------------------------------------------------------------
+# High-Level CTK options
+
+# The ctk_enable_option macro expects a logical expression after the first
+# three arguments. This expression should only contain build option names
+# which belong to leafs in the required dependency tree.
+
+# The CTK infrastructure for high-level DICOM support. This includes
+# DICOM indexing, networking, and GUI widgets.
+ctk_enable_option(DICOM "Enable default DICOM support" OFF
+                  CTK_LIB_DICOM/Widgets)
+
+# The CTK infrastructure for building a DICOM Part 19 compliant application
+# host and/or hosted application. This will not enable any example plugins
+# or executables (enable CTK_ENABLE_EXAMPLES for that).
+ctk_enable_option(DICOMApplicationHosting "Enable DICOM Part 19 Application Hosting support" OFF
+                  CTK_PLUGIN_org.commontk.dah.host AND CTK_PLUGIN_org.commontk.dah.app)
+
+# The CTK Qt Widgets. This will enable the Qt Widget library only.
+# It might trigger the enabling of other widget libraries in combination
+# with other enabled options.
+ctk_enable_option(Widgets "Enable Qt Widget libraries" OFF
+                  CTK_LIB_Widgets)
+
+# The CTK Plugin Framework, a dynamic component system based on OSGi.
+# This will enable only the framework itself.
+ctk_enable_option(PluginFramework "Enable Plugin Framework" OFF
+                  CTK_LIB_PluginFramework)
+
+# The CTK Python Wrapping
+ctk_enable_option(Python_Wrapping "Wrap CTK classes using Qt meta-object system into Python language" OFF
+                  CTK_LIB_Scripting/Python/Core)
+mark_as_superbuild(CTK_ENABLE_Python_Wrapping)
+
+# Build examples
+# Create the logical expression containing the minium set of required options
+# for the CTK_BUILD_EXAMPLES option to be ON
+set(_build_examples_logical_expr)
+foreach(_app ${CTK_ENABLED_APPS})
+  list(APPEND _build_examples_logical_expr CTK_APP_${_app} AND)
+endforeach()
+if(_build_examples_logical_expr)
+  list(REMOVE_AT _build_examples_logical_expr -1)
+endif()
+
+ctk_enable_option_raw(CTK_BUILD_EXAMPLES "Build examples for CTK components" OFF
+                  ${_build_examples_logical_expr})
+
+#-----------------------------------------------------------------------------
 # Generate target_directories list - List of directory corresponding to the different
 # libraries, plugins and applications associated with the corresponding option name.
 #