Commit e03f0ed7 authored by Julien Malik's avatar Julien Malik

COMP: implement support for OPTIONAL_DEPENDS

parent 78f03b62
......@@ -10,6 +10,11 @@ macro(_otb_module_use_recurse mod)
foreach(dep IN LISTS ${mod}_DEPENDS)
_otb_module_use_recurse(${dep})
endforeach()
foreach(dep IN LISTS ${mod}_OPTIONAL_DEPENDS)
if (${otb-module}_ENABLED)
_otb_module_use_recurse(${dep})
endif()
endforeach()
if(${mod}_INCLUDE_DIRS)
include_directories(${${mod}_INCLUDE_DIRS})
endif()
......@@ -39,11 +44,12 @@ endmacro()
# otb_module_load(<module>)
#
# Loads variables describing the given module:
# <module>_LOADED = True if the module has been loaded
# <module>_DEPENDS = List of dependencies on other modules
# <module>_LIBRARIES = Libraries to link
# <module>_INCLUDE_DIRS = Header search path
# <module>_LIBRARY_DIRS = Library search path (for outside dependencies)
# <module>_LOADED = True if the module has been loaded
# <module>_DEPENDS = List of dependencies on other modules
# <module>_OPTIONAL_DEPENDS = List of dependencies on other modules
# <module>_LIBRARIES = Libraries to link
# <module>_INCLUDE_DIRS = Header search path
# <module>_LIBRARY_DIRS = Library search path (for outside dependencies)
macro(otb_module_load mod)
if(NOT ${mod}_LOADED)
include("${OTB_MODULES_DIR}/${mod}.cmake" OPTIONAL)
......
set(@otb-module@_LOADED 1)
set(@otb-module@_DEPENDS "@otb-module-DEPENDS@")
set(@otb-module@_OPTIONAL_DEPENDS "@otb-module-OPTIONAL_DEPENDS@")
set(@otb-module@_LIBRARIES "@otb-module-LIBRARIES@")
set(@otb-module@_INCLUDE_DIRS "@otb-module-INCLUDE_DIRS@")
set(@otb-module@_LIBRARY_DIRS "@otb-module-LIBRARY_DIRS@")
......
......@@ -26,12 +26,13 @@ macro(otb_module _name)
set(OTB_MODULE_${otb-module}_DECLARED 1)
set(OTB_MODULE_${otb-module-test}_DECLARED 1)
set(OTB_MODULE_${otb-module}_DEPENDS "")
set(OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS "")
set(OTB_MODULE_${otb-module-test}_DEPENDS "${otb-module}")
set(OTB_MODULE_${otb-module}_DESCRIPTION "description")
set(OTB_MODULE_${otb-module}_EXCLUDE_FROM_DEFAULT 0)
set(OTB_MODULE_${otb-module}_ENABLE_SHARED 0)
foreach(arg ${ARGN})
if("${arg}" MATCHES "^(DEPENDS|TEST_DEPENDS|DESCRIPTION|DEFAULT)$")
if("${arg}" MATCHES "^(DEPENDS|OPTIONAL_DEPENDS|TEST_DEPENDS|DESCRIPTION|DEFAULT)$")
set(_doing "${arg}")
elseif("${arg}" MATCHES "^EXCLUDE_FROM_DEFAULT$")
set(_doing "")
......@@ -48,6 +49,8 @@ macro(otb_module _name)
message(AUTHOR_WARNING "Unknown argument [${arg}]")
elseif("${_doing}" MATCHES "^DEPENDS$")
list(APPEND OTB_MODULE_${otb-module}_DEPENDS "${arg}")
elseif("${_doing}" MATCHES "^OPTIONAL_DEPENDS$")
list(APPEND OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS "${arg}")
elseif("${_doing}" MATCHES "^TEST_DEPENDS$")
list(APPEND OTB_MODULE_${otb-module-test}_DEPENDS "${arg}")
elseif("${_doing}" MATCHES "^DESCRIPTION$")
......@@ -61,6 +64,7 @@ macro(otb_module _name)
endif()
endforeach()
list(SORT OTB_MODULE_${otb-module}_DEPENDS) # Deterministic order.
list(SORT OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS) # Deterministic order.
list(SORT OTB_MODULE_${otb-module-test}_DEPENDS) # Deterministic order.
endmacro()
......@@ -102,12 +106,26 @@ macro(otb_module_impl)
add_custom_target(${otb-module}-all ALL SOURCES ${_srcs})
otb_module_use(${OTB_MODULE_${otb-module}_DEPENDS})
foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS)
if (${dep}_ENABLED)
otb_module_use(${dep})
endif()
endforeach()
if(NOT DEFINED ${otb-module}_LIBRARIES)
set(${otb-module}_LIBRARIES "")
foreach(dep IN LISTS OTB_MODULE_${otb-module}_DEPENDS)
list(APPEND ${otb-module}_LIBRARIES "${${dep}_LIBRARIES}")
endforeach()
foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS)
if (${dep}_ENABLED)
list(APPEND ${otb-module}_LIBRARIES "${${dep}_LIBRARIES}")
endif()
endforeach()
if(${otb-module}_LIBRARIES)
list(REMOVE_DUPLICATES ${otb-module}_LIBRARIES)
endif()
......@@ -146,7 +164,7 @@ macro(otb_module_impl)
endif()
if(EXISTS ${${otb-module}_SOURCE_DIR}/app/CMakeLists.txt AND NOT ${otb-module}_NO_SRC)
# TODO : check the use of the following line
# TODO : check the utility of the following line
# set_property(GLOBAL APPEND PROPERTY OTBTargets_MODULES ${otb-module})
add_subdirectory(app)
endif()
......@@ -183,6 +201,7 @@ macro(otb_module_impl)
set(otb-module-EXPORT_CODE-install "${${otb-module}_EXPORT_CODE_INSTALL}")
set(otb-module-DEPENDS "${OTB_MODULE_${otb-module}_DEPENDS}")
set(otb-module-OPTIONAL_DEPENDS "${OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS}")
set(otb-module-LIBRARIES "${${otb-module}_LIBRARIES}")
set(otb-module-INCLUDE_DIRS-build "${${otb-module}_INCLUDE_DIRS}")
set(otb-module-INCLUDE_DIRS-install "\${OTB_INSTALL_PREFIX}/${${otb-module}_INSTALL_INCLUDE_DIR}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment