|
@@ -18,6 +18,13 @@
|
|
|
#
|
|
|
###########################################################################
|
|
|
|
|
|
+include(CMakeParseArguments)
|
|
|
+include(ctkListToString)
|
|
|
+
|
|
|
+if(NOT DEFINED EP_LIST_SEPARATOR)
|
|
|
+ set(EP_LIST_SEPARATOR "^^")
|
|
|
+endif()
|
|
|
+
|
|
|
if(NOT EXISTS "${EXTERNAL_PROJECT_DIR}")
|
|
|
set(EXTERNAL_PROJECT_DIR ${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/SuperBuild)
|
|
|
endif()
|
|
@@ -26,6 +33,13 @@ if(NOT DEFINED EXTERNAL_PROJECT_FILE_PREFIX)
|
|
|
set(EXTERNAL_PROJECT_FILE_PREFIX "External_")
|
|
|
endif()
|
|
|
|
|
|
+# Compute -G arg for configuring external projects with the same CMake generator:
|
|
|
+if(CMAKE_EXTRA_GENERATOR)
|
|
|
+ set(EP_CMAKE_GENERATOR "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
|
|
|
+else()
|
|
|
+ set(EP_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
|
|
|
+endif()
|
|
|
+
|
|
|
#
|
|
|
# superbuild_include_once()
|
|
|
#
|
|
@@ -49,45 +63,364 @@ macro(superbuild_include_once)
|
|
|
set_property(GLOBAL PROPERTY ${_property_name} 1)
|
|
|
endmacro()
|
|
|
|
|
|
-macro(_epd_status txt)
|
|
|
- if(NOT __epd_first_pass)
|
|
|
- message(STATUS ${txt})
|
|
|
+#!
|
|
|
+#! mark_as_superbuild(<varname1>[:<vartype1>] [<varname2>[:<vartype2>] [...]])
|
|
|
+#!
|
|
|
+#! mark_as_superbuild(
|
|
|
+#! VARS <varname1>[:<vartype1>] [<varname2>[:<vartype2>] [...]]
|
|
|
+#! [PROJECT <projectname>]
|
|
|
+#! [LABELS <label1> [<label2> [...]]]
|
|
|
+#! [CMAKE_CMD]
|
|
|
+#! )
|
|
|
+#!
|
|
|
+#! PROJECT corresponds to a <projectname> that will be added using 'ExternalProject_Add' function.
|
|
|
+#! If not specified and called within a project file, it defaults to the value of 'SUPERBUILD_TOPLEVEL_PROJECT'
|
|
|
+#! Otherwise, it defaults to 'CMAKE_PROJECT_NAME'.
|
|
|
+#!
|
|
|
+#! VARS is an expected list of variables specified as <varname>:<vartype> to pass to <projectname>
|
|
|
+#!
|
|
|
+#!
|
|
|
+#! LABELS is an optional list of label to associate with the variable names specified using 'VARS' and passed to
|
|
|
+#! the <projectname> as CMake CACHE args of the form:
|
|
|
+#! -D<projectname>_EP_LABEL_<label1>=<varname1>;<varname2>[...]
|
|
|
+#! -D<projectname>_EP_LABEL_<label2>=<varname1>;<varname2>[...]
|
|
|
+#!
|
|
|
+function(mark_as_superbuild)
|
|
|
+ set(options CMAKE_CMD)
|
|
|
+ set(oneValueArgs PROJECT)
|
|
|
+ set(multiValueArgs VARS LABELS)
|
|
|
+ cmake_parse_arguments(_sb "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
+
|
|
|
+ set(_vars ${_sb_UNPARSED_ARGUMENTS})
|
|
|
+
|
|
|
+ set(_named_parameters_expected 0)
|
|
|
+ if(_sb_PROJECT OR _sb_LABELS OR _sb_VARS)
|
|
|
+ set(_named_parameters_expected 1)
|
|
|
+ set(_vars ${_sb_VARS})
|
|
|
endif()
|
|
|
-endmacro()
|
|
|
|
|
|
-macro(ctkMacroCheckExternalProjectDependency proj)
|
|
|
+ if(_named_parameters_expected AND _sb_UNPARSED_ARGUMENTS)
|
|
|
+ message(FATAL_ERROR "Arguments '${_sb_UNPARSED_ARGUMENTS}' should be associated with VARS parameter !")
|
|
|
+ endif()
|
|
|
+
|
|
|
+ foreach(var ${_vars})
|
|
|
+ set(_type_specified 0)
|
|
|
+ if(${var} MATCHES ":")
|
|
|
+ set(_type_specified 1)
|
|
|
+ endif()
|
|
|
+ # XXX Display warning with variable type is also specified for cache variable.
|
|
|
+ set(_var ${var})
|
|
|
+ if(NOT _type_specified)
|
|
|
+ get_property(_type_set_in_cache CACHE ${_var} PROPERTY TYPE SET)
|
|
|
+ set(_var_name ${_var})
|
|
|
+ set(_var_type "STRING")
|
|
|
+ if(_type_set_in_cache)
|
|
|
+ get_property(_var_type CACHE ${_var_name} PROPERTY TYPE)
|
|
|
+ endif()
|
|
|
+ set(_var ${_var_name}:${_var_type})
|
|
|
+ endif()
|
|
|
+ list(APPEND _vars_with_type ${_var})
|
|
|
+ endforeach()
|
|
|
+
|
|
|
+ if(_sb_CMAKE_CMD)
|
|
|
+ set(optional_arg_CMAKE_CMD "CMAKE_CMD")
|
|
|
+ endif()
|
|
|
+
|
|
|
+ _sb_append_to_cmake_args(VARS ${_vars_with_type} PROJECT ${_sb_PROJECT} LABELS ${_sb_LABELS} ${optional_arg_CMAKE_CMD})
|
|
|
+endfunction()
|
|
|
+
|
|
|
+#!
|
|
|
+#! _sb_extract_varname_and_vartype(<cmake_varname_and_type> <varname_var> [<vartype_var>])
|
|
|
+#!
|
|
|
+#! <cmake_varname_and_type> corresponds to variable name and variable type passed as "<varname>:<vartype>"
|
|
|
+#!
|
|
|
+#! <varname_var> will be set to "<varname>"
|
|
|
+#!
|
|
|
+#! <vartype_var> is an optional variable name that will be set to "<vartype>"
|
|
|
+function(_sb_extract_varname_and_vartype cmake_varname_and_type varname_var)
|
|
|
+ set(_vartype_var ${ARGV2})
|
|
|
+ string(REPLACE ":" ";" varname_and_vartype ${cmake_varname_and_type})
|
|
|
+ list(GET varname_and_vartype 0 _varname)
|
|
|
+ list(GET varname_and_vartype 1 _vartype)
|
|
|
+ set(${varname_var} ${_varname} PARENT_SCOPE)
|
|
|
+ if(_vartype_var MATCHES ".+")
|
|
|
+ set(${_vartype_var} ${_vartype} PARENT_SCOPE)
|
|
|
+ endif()
|
|
|
+endfunction()
|
|
|
+
|
|
|
+#!
|
|
|
+#! _sb_cmakevar_to_cmakearg(<cmake_varname_and_type> <cmake_arg_var> <cmake_arg_type> [<varname_var> [<vartype_var>]])
|
|
|
+#!
|
|
|
+#! <cmake_varname_and_type> corresponds to variable name and variable type passed as "<varname>:<vartype>"
|
|
|
+#!
|
|
|
+#! <cmake_arg_var> is a variable name that will be set to "-D<varname>:<vartype>=${<varname>}"
|
|
|
+#!
|
|
|
+#! <cmake_arg_type> is set to either CMAKE_CACHE or CMAKE_CMD.
|
|
|
+#! CMAKE_CACHE means that the generated cmake argument will be passed to
|
|
|
+#! ExternalProject_Add as CMAKE_CACHE_ARGS.
|
|
|
+#! CMAKE_CMD means that the generated cmake argument will be passed to
|
|
|
+#! ExternalProject_Add as CMAKE_ARGS.
|
|
|
+#!
|
|
|
+#! <varname_var> is an optional variable name that will be set to "<varname>"
|
|
|
+#!
|
|
|
+#! <vartype_var> is an optional variable name that will be set to "<vartype>"
|
|
|
+function(_sb_cmakevar_to_cmakearg cmake_varname_and_type cmake_arg_var cmake_arg_type)
|
|
|
+ set(_varname_var ${ARGV3})
|
|
|
+ set(_vartype_var ${ARGV4})
|
|
|
+
|
|
|
+ # XXX Add check for <cmake_arg_type> value
|
|
|
+
|
|
|
+ _sb_extract_varname_and_vartype(${cmake_varname_and_type} _varname _vartype)
|
|
|
+
|
|
|
+ set(_var_value "${${_varname}}")
|
|
|
+ get_property(_value_set_in_cache CACHE ${_varname} PROPERTY VALUE SET)
|
|
|
+ if(_value_set_in_cache)
|
|
|
+ get_property(_var_value CACHE ${_varname} PROPERTY VALUE)
|
|
|
+ endif()
|
|
|
+
|
|
|
+ if(cmake_arg_type STREQUAL "CMAKE_CMD")
|
|
|
+ # Separate list item with <EP_LIST_SEPARATOR>
|
|
|
+ set(ep_arg_as_string "")
|
|
|
+ ctk_list_to_string(${EP_LIST_SEPARATOR} "${_var_value}" _var_value)
|
|
|
+ endif()
|
|
|
+
|
|
|
+ set(${cmake_arg_var} -D${_varname}:${_vartype}=${_var_value} PARENT_SCOPE)
|
|
|
+
|
|
|
+ if(_varname_var MATCHES ".+")
|
|
|
+ set(${_varname_var} ${_varname} PARENT_SCOPE)
|
|
|
+ endif()
|
|
|
+ if(_vartype_var MATCHES ".+")
|
|
|
+ set(${_vartype_var} ${_vartype} PARENT_SCOPE)
|
|
|
+ endif()
|
|
|
+endfunction()
|
|
|
+
|
|
|
+#!
|
|
|
+#! _sb_append_to_cmake_args(
|
|
|
+#! VARS <varname1>:<vartype1> [<varname2>:<vartype2> [...]]
|
|
|
+#! [PROJECT <projectname>]
|
|
|
+#! [LABELS <label1> [<label2> [...]]]
|
|
|
+#! [CMAKE_CMD]
|
|
|
+#! )
|
|
|
+#!
|
|
|
+#! PROJECT corresponds to a <projectname> that will be added using 'ExternalProject_Add' function.
|
|
|
+#! If not specified and called within a project file, it defaults to the value of 'SUPERBUILD_TOPLEVEL_PROJECT'
|
|
|
+#! Otherwise, it defaults to 'CMAKE_PROJECT_NAME'.
|
|
|
+#!
|
|
|
+#! VARS is an expected list of variables specified as <varname>:<vartype> to pass to <projectname>
|
|
|
+#!
|
|
|
+#!
|
|
|
+#! LABELS is an optional list of label to associate with the variable names specified using 'VARS' and passed to
|
|
|
+#! the <projectname> as CMake CACHE args of the form:
|
|
|
+#! -D<projectname>_EP_LABEL_<label1>=<varname1>;<varname2>[...]
|
|
|
+#! -D<projectname>_EP_LABEL_<label2>=<varname1>;<varname2>[...]
|
|
|
+#!
|
|
|
+function(_sb_append_to_cmake_args)
|
|
|
+ set(options CMAKE_CMD)
|
|
|
+ set(oneValueArgs PROJECT)
|
|
|
+ set(multiValueArgs VARS LABELS)
|
|
|
+ cmake_parse_arguments(_sb "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
+
|
|
|
+ if(NOT _sb_PROJECT)
|
|
|
+ if(SUPERBUILD_TOPLEVEL_PROJECT)
|
|
|
+ set(_sb_PROJECT ${SUPERBUILD_TOPLEVEL_PROJECT})
|
|
|
+ else()
|
|
|
+ set(_sb_PROJECT ${CMAKE_PROJECT_NAME})
|
|
|
+ endif()
|
|
|
+ endif()
|
|
|
+
|
|
|
+ set(_cmake_arg_type "CMAKE_CACHE")
|
|
|
+ if(_sb_CMAKE_CMD)
|
|
|
+ set(_cmake_arg_type "CMAKE")
|
|
|
+ set(optional_arg_CMAKE_CMD "CMAKE_CMD")
|
|
|
+ endif()
|
|
|
+ set(_ep_property "${_cmake_arg_type}_ARGS")
|
|
|
+ set(_ep_varnames "")
|
|
|
+ foreach(varname_and_vartype ${_sb_VARS})
|
|
|
+ if(NOT TARGET ${_sb_PROJECT})
|
|
|
+ set_property(GLOBAL APPEND PROPERTY ${_sb_PROJECT}_EP_${_ep_property} ${varname_and_vartype})
|
|
|
+ _sb_extract_varname_and_vartype(${varname_and_vartype} _varname)
|
|
|
+ set_property(GLOBAL APPEND PROPERTY ${_sb_PROJECT}_EP_PROPERTIES ${_ep_property})
|
|
|
+ else()
|
|
|
+ message(FATAL_ERROR "Function _sb_append_to_cmake_args not allowed is project already added !")
|
|
|
+ endif()
|
|
|
+ list(APPEND _ep_varnames ${_varname})
|
|
|
+ endforeach()
|
|
|
+
|
|
|
+ if(_sb_LABELS)
|
|
|
+ set_property(GLOBAL APPEND PROPERTY ${_sb_PROJECT}_EP_LABELS ${_sb_LABELS})
|
|
|
+ foreach(label ${_sb_LABELS})
|
|
|
+ set_property(GLOBAL APPEND PROPERTY ${_sb_PROJECT}_EP_LABEL_${label} ${_ep_varnames})
|
|
|
+ endforeach()
|
|
|
+ endif()
|
|
|
+endfunction()
|
|
|
+
|
|
|
+function(_sb_get_external_project_arguments proj varname)
|
|
|
+
|
|
|
+ mark_as_superbuild(${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${proj}:BOOL)
|
|
|
+
|
|
|
+ # Set list of CMake args associated with each label
|
|
|
+ get_property(_labels GLOBAL PROPERTY ${proj}_EP_LABELS)
|
|
|
+ if(_labels)
|
|
|
+ list(REMOVE_DUPLICATES _labels)
|
|
|
+ foreach(label ${_labels})
|
|
|
+ get_property(${proj}_EP_LABEL_${label} GLOBAL PROPERTY ${proj}_EP_LABEL_${label})
|
|
|
+ list(REMOVE_DUPLICATES ${proj}_EP_LABEL_${label})
|
|
|
+ _sb_append_to_cmake_args(PROJECT ${proj}
|
|
|
+ VARS ${proj}_EP_LABEL_${label}:STRING)
|
|
|
+ endforeach()
|
|
|
+ endif()
|
|
|
+
|
|
|
+ foreach(cmake_arg_type CMAKE_CMD CMAKE_CACHE)
|
|
|
+
|
|
|
+ set(_ep_property "CMAKE_CACHE_ARGS")
|
|
|
+ if(cmake_arg_type STREQUAL "CMAKE_CMD")
|
|
|
+ set(_ep_property "CMAKE_ARGS")
|
|
|
+ endif()
|
|
|
+
|
|
|
+ get_property(_args GLOBAL PROPERTY ${proj}_EP_${_ep_property})
|
|
|
+ foreach(var ${_args})
|
|
|
+ _sb_cmakevar_to_cmakearg(${var} cmake_arg ${cmake_arg_type})
|
|
|
+ set_property(GLOBAL APPEND PROPERTY ${proj}_EP_PROPERTY_${_ep_property} ${cmake_arg})
|
|
|
+ endforeach()
|
|
|
+
|
|
|
+ endforeach()
|
|
|
+
|
|
|
+ set(_ep_arguments "")
|
|
|
+ get_property(_properties GLOBAL PROPERTY ${proj}_EP_PROPERTIES)
|
|
|
+ if(_properties)
|
|
|
+ list(REMOVE_DUPLICATES _properties)
|
|
|
+ foreach(property ${_properties})
|
|
|
+ get_property(${proj}_EP_PROPERTY_${property} GLOBAL PROPERTY ${proj}_EP_PROPERTY_${property})
|
|
|
+ list(APPEND _ep_arguments ${property} ${${proj}_EP_PROPERTY_${property}})
|
|
|
+ endforeach()
|
|
|
+ endif()
|
|
|
+
|
|
|
+ list(APPEND _ep_arguments LIST_SEPARATOR ${EP_LIST_SEPARATOR})
|
|
|
|
|
|
- # Set indent variable if needed
|
|
|
- if(NOT DEFINED __indent)
|
|
|
- set(__indent "")
|
|
|
+ list(APPEND _ep_arguments CMAKE_GENERATOR ${EP_CMAKE_GENERATOR})
|
|
|
+
|
|
|
+ set(${varname} ${_ep_arguments} PARENT_SCOPE)
|
|
|
+endfunction()
|
|
|
+
|
|
|
+function(_sb_update_indent proj)
|
|
|
+ superbuild_stack_size(SUPERBUILD_PROJECT_STACK _stack_size)
|
|
|
+ set(_indent "")
|
|
|
+ if(_stack_size GREATER 0)
|
|
|
+ foreach(not_used RANGE 1 ${_stack_size})
|
|
|
+ set(_indent " ${_indent}")
|
|
|
+ endforeach()
|
|
|
+ endif()
|
|
|
+ set_property(GLOBAL PROPERTY SUPERBUILD_${proj}_INDENT ${_indent})
|
|
|
+endfunction()
|
|
|
+
|
|
|
+function(superbuild_message proj msg)
|
|
|
+ if(NOT SUPERBUILD_FIRST_PASS)
|
|
|
+ get_property(_indent GLOBAL PROPERTY SUPERBUILD_${proj}_INDENT)
|
|
|
+ message(STATUS "SuperBuild - ${_indent}${msg}")
|
|
|
+ endif()
|
|
|
+endfunction()
|
|
|
+
|
|
|
+#!
|
|
|
+#! superbuild_stack_content(<stack_name> <output_var>)
|
|
|
+#!
|
|
|
+#! <stack_name> corresponds to the name of stack.
|
|
|
+#!
|
|
|
+#! <output_var> is the name of CMake variable that will be set with the content
|
|
|
+#! of the stack identified by <stack_name>.
|
|
|
+function(superbuild_stack_content stack_name output_var)
|
|
|
+ get_property(_stack GLOBAL PROPERTY ${stack_name})
|
|
|
+ set(${output_var} ${_stack} PARENT_SCOPE)
|
|
|
+endfunction()
|
|
|
+
|
|
|
+#!
|
|
|
+#! superbuild_stack_size(<stack_name> <output_var>)
|
|
|
+#!
|
|
|
+#! <stack_name> corresponds to the name of stack.
|
|
|
+#!
|
|
|
+#! <output_var> is the name of CMake variable that will be set with the size
|
|
|
+#! of the stack identified by <stack_name>.
|
|
|
+function(superbuild_stack_size stack_name output_var)
|
|
|
+ get_property(_stack GLOBAL PROPERTY ${stack_name})
|
|
|
+ list(LENGTH _stack _stack_size)
|
|
|
+ set(${output_var} ${_stack_size} PARENT_SCOPE)
|
|
|
+endfunction()
|
|
|
+
|
|
|
+#!
|
|
|
+#! superbuild_stack_push(<stack_name> <value>)
|
|
|
+#!
|
|
|
+#! <stack_name> corresponds to the name of stack.
|
|
|
+#!
|
|
|
+#! <value> is appended to the stack identified by <stack_name>.
|
|
|
+function(superbuild_stack_push stack_name value)
|
|
|
+ set_property(GLOBAL APPEND PROPERTY ${stack_name} ${value})
|
|
|
+endfunction()
|
|
|
+
|
|
|
+#!
|
|
|
+#! superbuild_stack_pop(<stack_name> <item_var>)
|
|
|
+#!
|
|
|
+#! <stack_name> corresponds to the name of stack.
|
|
|
+#!
|
|
|
+#! <item_var> names a CMake variable that will be set with the item
|
|
|
+#! removed from the stack identified by <stack_name>.
|
|
|
+function(superbuild_stack_pop stack_name item_var)
|
|
|
+ get_property(_stack GLOBAL PROPERTY ${stack_name})
|
|
|
+ list(LENGTH _stack _stack_size)
|
|
|
+ if(_stack_size GREATER 0)
|
|
|
+ math(EXPR _index_to_remove "${_stack_size} - 1")
|
|
|
+ list(GET _stack ${_index_to_remove} _item)
|
|
|
+ list(REMOVE_AT _stack ${_index_to_remove})
|
|
|
+ set_property(GLOBAL PROPERTY ${stack_name} ${_stack})
|
|
|
+ set(${item_var} ${_item} PARENT_SCOPE)
|
|
|
+ endif()
|
|
|
+endfunction()
|
|
|
+
|
|
|
+#
|
|
|
+# superbuild_include_dependencies(<project>)
|
|
|
+#
|
|
|
+# superbuild_include_dependencies(PROJECT_VAR <project_var>)
|
|
|
+#
|
|
|
+macro(superbuild_include_dependencies)
|
|
|
+ set(options)
|
|
|
+ set(oneValueArgs PROJECT_VAR)
|
|
|
+ set(multiValueArgs)
|
|
|
+ cmake_parse_arguments(_sb "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
+
|
|
|
+ # XXX Implement invalid parameter checking
|
|
|
+
|
|
|
+ if(NOT "x" STREQUAL "x${_sb_PROJECT_VAR}")
|
|
|
+ set(proj ${${_sb_PROJECT_VAR}})
|
|
|
else()
|
|
|
- set(__indent "${__indent} ")
|
|
|
+ set(proj ${_sb_UNPARSED_ARGUMENTS})
|
|
|
endif()
|
|
|
|
|
|
# Sanity checks
|
|
|
if(NOT DEFINED ${proj}_DEPENDENCIES)
|
|
|
- message(FATAL_ERROR "${__indent}${proj}_DEPENDENCIES variable is NOT defined !")
|
|
|
+ message(FATAL_ERROR "${proj}_DEPENDENCIES variable is NOT defined !")
|
|
|
+ endif()
|
|
|
+
|
|
|
+ superbuild_stack_size(SUPERBUILD_PROJECT_STACK _stack_size)
|
|
|
+ if(_stack_size EQUAL 0)
|
|
|
+ set(SUPERBUILD_TOPLEVEL_PROJECT ${proj})
|
|
|
endif()
|
|
|
|
|
|
+ _sb_update_indent(${proj})
|
|
|
+
|
|
|
# Keep track of the projects
|
|
|
- list(APPEND __epd_${CMAKE_PROJECT_NAME}_projects ${proj})
|
|
|
+ list(APPEND __epd_${SUPERBUILD_TOPLEVEL_PROJECT}_projects ${proj})
|
|
|
|
|
|
- # Is this the first run ? (used to set the <CMAKE_PROJECT_NAME>_USE_SYSTEM_* variables)
|
|
|
- if(${proj} STREQUAL ${CMAKE_PROJECT_NAME} AND NOT DEFINED __epd_first_pass)
|
|
|
+ # Is this the first run ? (used to set the <SUPERBUILD_TOPLEVEL_PROJECT>_USE_SYSTEM_* variables)
|
|
|
+ if(${proj} STREQUAL ${SUPERBUILD_TOPLEVEL_PROJECT} AND NOT DEFINED SUPERBUILD_FIRST_PASS)
|
|
|
message(STATUS "SuperBuild - First pass")
|
|
|
- set(__epd_first_pass TRUE)
|
|
|
- endif()
|
|
|
-
|
|
|
- # Set message strings
|
|
|
- set(__${proj}_indent ${__indent})
|
|
|
- set(__${proj}_superbuild_message "SuperBuild - ${__indent}${proj}[OK]")
|
|
|
- if(${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
|
|
|
- set(__${proj}_superbuild_message "${__${proj}_superbuild_message} (SYSTEM)")
|
|
|
+ set(SUPERBUILD_FIRST_PASS TRUE)
|
|
|
endif()
|
|
|
|
|
|
# Display dependency of project being processed
|
|
|
if("${${proj}_DEPENDENCIES}" STREQUAL "")
|
|
|
- _epd_status(${__${proj}_superbuild_message})
|
|
|
+ set(_msg "${proj}[OK]")
|
|
|
+ if(${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${proj})
|
|
|
+ set(_msg "${_msg} (SYSTEM)")
|
|
|
+ endif()
|
|
|
+ superbuild_message(${proj} ${_msg})
|
|
|
else()
|
|
|
set(dependency_str " ")
|
|
|
foreach(dep ${${proj}_DEPENDENCIES})
|
|
@@ -98,18 +431,20 @@ macro(ctkMacroCheckExternalProjectDependency proj)
|
|
|
set(dependency_str "${dependency_str}${dep}, ")
|
|
|
endif()
|
|
|
endforeach()
|
|
|
- _epd_status("SuperBuild - ${__indent}${proj} => Requires${dependency_str}")
|
|
|
+ superbuild_message(${proj} "${proj} => Requires${dependency_str}")
|
|
|
endif()
|
|
|
|
|
|
foreach(dep ${${proj}_DEPENDENCIES})
|
|
|
- if(${${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}})
|
|
|
- set(${CMAKE_PROJECT_NAME}_USE_SYSTEM_${dep} ${${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}})
|
|
|
+ if(${${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${proj}})
|
|
|
+ set(${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${dep} ${${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${proj}})
|
|
|
endif()
|
|
|
- #if(__epd_first_pass)
|
|
|
- # message("${CMAKE_PROJECT_NAME}_USE_SYSTEM_${dep} set to [${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}:${${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}}]")
|
|
|
+ #if(SUPERBUILD_FIRST_PASS)
|
|
|
+ # message("${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${dep} set to [${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${proj}:${${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${proj}}]")
|
|
|
#endif()
|
|
|
endforeach()
|
|
|
|
|
|
+ superbuild_stack_push(SUPERBUILD_PROJECT_STACK ${proj})
|
|
|
+
|
|
|
# Include dependencies
|
|
|
foreach(dep ${${proj}_DEPENDENCIES})
|
|
|
get_property(_is_included GLOBAL PROPERTY External_${dep}_FILE_INCLUDED)
|
|
@@ -127,70 +462,79 @@ macro(ctkMacroCheckExternalProjectDependency proj)
|
|
|
endif()
|
|
|
endforeach()
|
|
|
|
|
|
+ superbuild_stack_pop(SUPERBUILD_PROJECT_STACK proj)
|
|
|
+
|
|
|
# If project being process has dependencies, indicates it has also been added.
|
|
|
if(NOT "${${proj}_DEPENDENCIES}" STREQUAL "")
|
|
|
- _epd_status(${__${proj}_superbuild_message})
|
|
|
- endif()
|
|
|
-
|
|
|
- # Update indent variable
|
|
|
- string(LENGTH "${__indent}" __indent_length)
|
|
|
- math(EXPR __indent_length "${__indent_length}-2")
|
|
|
- if(NOT ${__indent_length} LESS 0)
|
|
|
- string(SUBSTRING "${__indent}" 0 ${__indent_length} __indent)
|
|
|
+ set(_msg "${proj}[OK]")
|
|
|
+ if(${SUPERBUILD_TOPLEVEL_PROJECT}_USE_SYSTEM_${proj})
|
|
|
+ set(_msg "${_ok_message} (SYSTEM)")
|
|
|
+ endif()
|
|
|
+ superbuild_message(${proj} ${_msg})
|
|
|
endif()
|
|
|
|
|
|
- if(${proj} STREQUAL ${CMAKE_PROJECT_NAME} AND __epd_first_pass)
|
|
|
+ if(${proj} STREQUAL ${SUPERBUILD_TOPLEVEL_PROJECT} AND SUPERBUILD_FIRST_PASS)
|
|
|
message(STATUS "SuperBuild - First pass - done")
|
|
|
- unset(__indent)
|
|
|
- if(${CMAKE_PROJECT_NAME}_SUPERBUILD)
|
|
|
- set(__epd_first_pass FALSE)
|
|
|
- endif()
|
|
|
|
|
|
- unset(${CMAKE_PROJECT_NAME}_DEPENDENCIES) # XXX - Refactor
|
|
|
-
|
|
|
- foreach(possible_proj ${__epd_${CMAKE_PROJECT_NAME}_projects})
|
|
|
- if(NOT ${possible_proj} STREQUAL ${CMAKE_PROJECT_NAME})
|
|
|
-
|
|
|
- set_property(GLOBAL PROPERTY ${EXTERNAL_PROJECT_FILE_PREFIX}${possible_proj}_FILE_INCLUDED 0)
|
|
|
-
|
|
|
- # XXX - Refactor - The following code should be re-organized
|
|
|
- if(DEFINED ${possible_proj}_enabling_variable)
|
|
|
- ctkMacroShouldAddExternalproject(${${possible_proj}_enabling_variable} add_project)
|
|
|
- if(${add_project})
|
|
|
- list(APPEND ${CMAKE_PROJECT_NAME}_DEPENDENCIES ${possible_proj})
|
|
|
- else()
|
|
|
- # XXX HACK
|
|
|
- if(${possible_proj} STREQUAL "VTK"
|
|
|
- AND CTK_LIB_Scripting/Python/Core_PYTHONQT_USE_VTK)
|
|
|
- list(APPEND ${CMAKE_PROJECT_NAME}_DEPENDENCIES VTK)
|
|
|
- else()
|
|
|
- unset(${${possible_proj}_enabling_variable}_INCLUDE_DIRS)
|
|
|
- unset(${${possible_proj}_enabling_variable}_LIBRARY_DIRS)
|
|
|
- unset(${${possible_proj}_enabling_variable}_FIND_PACKAGE_CMD)
|
|
|
- if(${CMAKE_PROJECT_NAME}_SUPERBUILD)
|
|
|
- message(STATUS "SuperBuild - ${possible_proj}[OPTIONAL]")
|
|
|
- endif()
|
|
|
- endif()
|
|
|
- endif()
|
|
|
- else()
|
|
|
- list(APPEND ${CMAKE_PROJECT_NAME}_DEPENDENCIES ${possible_proj})
|
|
|
- endif()
|
|
|
- # XXX
|
|
|
+ unset(${SUPERBUILD_TOPLEVEL_PROJECT}_DEPENDENCIES) # XXX - Refactor
|
|
|
|
|
|
- else()
|
|
|
+ set(SUPERBUILD_FIRST_PASS FALSE)
|
|
|
+
|
|
|
+ foreach(possible_proj ${__epd_${SUPERBUILD_TOPLEVEL_PROJECT}_projects})
|
|
|
+
|
|
|
+ set_property(GLOBAL PROPERTY ${EXTERNAL_PROJECT_FILE_PREFIX}${possible_proj}_FILE_INCLUDED 0)
|
|
|
|
|
|
+ if(NOT ${possible_proj} STREQUAL ${SUPERBUILD_TOPLEVEL_PROJECT})
|
|
|
+ set(_include_project 1)
|
|
|
+ if(COMMAND superbuild_is_external_project_includable)
|
|
|
+ superbuild_is_external_project_includable("${possible_proj}" _include_project)
|
|
|
+ endif()
|
|
|
+ if(_include_project)
|
|
|
+ list(APPEND ${SUPERBUILD_TOPLEVEL_PROJECT}_DEPENDENCIES ${possible_proj})
|
|
|
+ else()
|
|
|
+ superbuild_message(STATUS "${possible_proj}[OPTIONAL]")
|
|
|
+ endif()
|
|
|
endif()
|
|
|
endforeach()
|
|
|
|
|
|
- list(REMOVE_DUPLICATES ${CMAKE_PROJECT_NAME}_DEPENDENCIES)
|
|
|
+ list(REMOVE_DUPLICATES ${SUPERBUILD_TOPLEVEL_PROJECT}_DEPENDENCIES)
|
|
|
|
|
|
- if(${CMAKE_PROJECT_NAME}_SUPERBUILD)
|
|
|
- ctkMacroCheckExternalProjectDependency(${CMAKE_PROJECT_NAME})
|
|
|
+ if(${SUPERBUILD_TOPLEVEL_PROJECT}_SUPERBUILD)
|
|
|
+ superbuild_include_dependencies(${SUPERBUILD_TOPLEVEL_PROJECT})
|
|
|
endif()
|
|
|
|
|
|
+ set(SUPERBUILD_FIRST_PASS TRUE)
|
|
|
endif()
|
|
|
|
|
|
- if(__epd_first_pass)
|
|
|
+ if(_sb_PROJECT_VAR)
|
|
|
+ set(${_sb_PROJECT_VAR} ${proj})
|
|
|
+ endif()
|
|
|
+
|
|
|
+ if(SUPERBUILD_FIRST_PASS)
|
|
|
return()
|
|
|
+ else()
|
|
|
+ unset(${proj}_EXTERNAL_PROJECT_ARGS)
|
|
|
+ _sb_get_external_project_arguments(${proj} ${proj}_EXTERNAL_PROJECT_ARGS)
|
|
|
+ #message("${proj}_EXTERNAL_PROJECT_ARGS:${${proj}_EXTERNAL_PROJECT_ARGS}")
|
|
|
endif()
|
|
|
endmacro()
|
|
|
+
|
|
|
+#!
|
|
|
+#! Convenient macro allowing to define a "empty" project in case an external one is provided
|
|
|
+#! using for example <proj>_DIR.
|
|
|
+#! Doing so allows to keep the external project dependency system happy.
|
|
|
+#!
|
|
|
+#! \ingroup CMakeUtilities
|
|
|
+macro(superbuild_add_empty_external_project proj dependencies)
|
|
|
+
|
|
|
+ ExternalProject_Add(${proj}
|
|
|
+ SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
|
|
|
+ BINARY_DIR ${proj}-build
|
|
|
+ DOWNLOAD_COMMAND ""
|
|
|
+ CONFIGURE_COMMAND ""
|
|
|
+ BUILD_COMMAND ""
|
|
|
+ INSTALL_COMMAND ""
|
|
|
+ DEPENDS
|
|
|
+ ${dependencies}
|
|
|
+ )
|
|
|
+endmacro()
|