Skip to content

Commit

Permalink
New CTK_ENABLE_* build system feature.
Browse files Browse the repository at this point in the history
The CTK CMake configuration now shows only high-level options
representing the main features of the toolkit. All other options
are marked as advanced.

Some options have been renamed to include the CTK_ prefix.
  • Loading branch information
saschazelzer committed Nov 18, 2011
1 parent 7f2c86f commit ed4b1ad
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 157 deletions.
20 changes: 4 additions & 16 deletions CMake/ctkBlockCheckDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# Collect CTK library target dependencies
#

ctkMacroCollectAllTargetLibraries("${CTK_LIBS_SUBDIRS}" "Libs" ALL_TARGET_LIBRARIES)
ctkMacroCollectAllTargetLibraries("${CTK_PLUGINS_SUBDIRS}" "Plugins" ALL_TARGET_LIBRARIES)
ctkMacroCollectAllTargetLibraries("${CTK_APPLICATIONS_SUBDIRS}" "Applications" ALL_TARGET_LIBRARIES)
ctkMacroCollectAllTargetLibraries("${CTK_LIBS}" "Libs" ALL_TARGET_LIBRARIES)
ctkMacroCollectAllTargetLibraries("${CTK_PLUGINS}" "Plugins" ALL_TARGET_LIBRARIES)
ctkMacroCollectAllTargetLibraries("${CTK_APPS}" "Applications" ALL_TARGET_LIBRARIES)
#message(STATUS ALL_TARGET_LIBRARIES:${ALL_TARGET_LIBRARIES})

#-----------------------------------------------------------------------------
Expand All @@ -25,19 +25,7 @@ ctkMacroCollectAllTargetLibraries("${CTK_APPLICATIONS_SUBDIRS}" "Applications" A
# of the macro ctkMacroCollectAllTargetLibraries, let's get the list of all Non-CTK dependencies.
# NON_CTK_DEPENDENCIES is expected by the macro ctkMacroShouldAddExternalProject
ctkMacroGetAllNonProjectTargetLibraries("${ALL_TARGET_LIBRARIES}" NON_CTK_DEPENDENCIES)
#message(STATUS NON_CTK_DEPENDENCIES:${NON_CTK_DEPENDENCIES})

#-----------------------------------------------------------------------------
# Include external projects
#
#-----------------------------------------------------------------------------
# Git protocole option
#
option(CTK_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." ON)
set(git_protocol "git")
if(NOT CTK_USE_GIT_PROTOCOL)
set(git_protocol "http")
endif()
#message(NON_CTK_DEPENDENCIES:${NON_CTK_DEPENDENCIES})

#-----------------------------------------------------------------------------
# Enable and setup External project global properties
Expand Down
42 changes: 42 additions & 0 deletions CMake/ctkMacroOptionUtils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
macro(ctk_option option_prefix name doc default)
option(${option_prefix}_${name} ${doc} ${default})
mark_as_advanced(${option_prefix}_${name})
list(APPEND ${option_prefix}S ${name})
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)
message("Enabling [${option_prefix}_${name}] because of [${ARGN}]")
endif()
endif()
endmacro()

macro(ctk_lib_option name doc default)
ctk_option(CTK_LIB ${name} ${doc} ${default} ${ARGN})
endmacro()

macro(ctk_plugin_option name doc default)
ctk_option(CTK_PLUGIN ${name} ${doc} ${default} ${ARGN})
endmacro()

macro(ctk_app_option name doc default)
ctk_option(CTK_APP ${name} ${doc} ${default} ${ARGN})
endmacro()

macro(ctk_enable_option name doc default)
option(CTK_ENABLE_${name} "${doc}" ${default})
if(DEFINED CTK_ENABLE_${name}_internal)
if(${CTK_ENABLE_${name}} AND ${CTK_ENABLE_${name}_internal})
if(NOT (${ARGN}))
get_property(_doc_string CACHE CTK_ENABLE_${name} PROPERTY HELPSTRING)
set(CTK_ENABLE_${name} OFF CACHE BOOL ${_doc_string} FORCE)
message("Full support for [${name}] disabled")
endif()
endif()
endif()
set(CTK_ENABLE_${name}_internal ${CTK_ENABLE_${name}} CACHE INTERNAL "" FORCE)
endmacro()
14 changes: 7 additions & 7 deletions CMake/ctkMacroTargetLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,17 @@ macro(ctkMacroGetAllNonProjectTargetLibraries all_target_libraries varname)
list(REMOVE_ITEM _tmp_list ${all_project_libraries})
endif()
set(${varname} ${_tmp_list})
#message(STATUS varname:${varname}:${${varname}})
#message(varname:${varname}:${${varname}})
endmacro()

#! \ingroup CMakeUtilities
macro(ctkMacroShouldAddExternalProject libraries_variable_name resultvar)
if(NOT DEFINED NON_CTK_DEPENDENCIES)
message(FATAL_ERROR "Variable NON_CTK_DEPENDENCIES is undefined !")
endif()
list(FIND NON_CTK_DEPENDENCIES ${libraries_variable_name} index)
set(${resultvar} FALSE)
if(${index} GREATER -1)
set(${resultvar} TRUE)
if(DEFINED NON_CTK_DEPENDENCIES)
list(FIND NON_CTK_DEPENDENCIES ${libraries_variable_name} index)

if(${index} GREATER -1)
set(${resultvar} TRUE)
endif()
endif()
endmacro()
Loading

0 comments on commit ed4b1ad

Please sign in to comment.