Commit fc045318 authored by Brad King's avatar Brad King

Revert "Add a new function SWIG_GET_WRAPPER_DEPENDENCIES to UseSWIG.cmake"

This reverts commit 1088b027.

Wrapper dependency scanning (fix for #4147) does not work at CMake
configuration time if an input file is provided by a custom command
(regression #12307).  Revert to original behavior until a solution is
found.
parent 1088b027
......@@ -4,9 +4,6 @@
# - Define swig module with given name and specified language
# SWIG_LINK_LIBRARIES(name [ libraries ])
# - Link libraries to swig module
# SWIG_GET_WRAPPER_DEPENDENCIES(swigFile genWrapper language DEST_VARIABLE)
# - Put dependencies of the wrapper genWrapper generated by swig from
# swigFile in DEST_VARIABLE
# All other macros are for internal use only.
# To get the actual name of the swig module,
# use: ${SWIG_MODULE_${name}_REAL_NAME}.
......@@ -41,58 +38,6 @@ SET(SWIG_EXTRA_LIBRARIES "")
SET(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py")
#
# Get dependencies of the generated wrapper.
#
MACRO(SWIG_GET_WRAPPER_DEPENDENCIES swigFile genWrapper language DEST_VARIABLE)
GET_FILENAME_COMPONENT(swig_getdeps_basename ${swigFile} NAME_WE)
GET_FILENAME_COMPONENT(swig_getdeps_outdir ${genWrapper} PATH)
GET_SOURCE_FILE_PROPERTY(swig_getdeps_extra_flags "${swigFile}" SWIG_FLAGS)
IF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND")
SET(swig_getdeps_extra_flags "")
ENDIF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND")
IF(NOT swig_getdeps_outdir)
SET(swig_getdeps_outdir ${CMAKE_CURRENT_BINARY_DIR})
ENDIF(NOT swig_getdeps_outdir)
SET(swig_getdeps_depsfile
${swig_getdeps_outdir}/swig_${swig_getdeps_basename}_deps.txt)
GET_DIRECTORY_PROPERTY(swig_getdeps_include_directories INCLUDE_DIRECTORIES)
SET(swig_getdeps_include_dirs)
FOREACH(it ${swig_getdeps_include_directories})
SET(swig_getdeps_include_dirs ${swig_getdeps_include_dirs} "-I${it}")
ENDFOREACH(it)
EXECUTE_PROCESS(
COMMAND ${SWIG_EXECUTABLE}
-MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags}
${CMAKE_SWIG_FLAGS} -${language}
-o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile}
RESULT_VARIABLE swig_getdeps_result
ERROR_VARIABLE swig_getdeps_error
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(NOT ${swig_getdeps_error} EQUAL 0)
MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile}\" failed with output:\n${swig_getdeps_error}")
SET(swig_getdeps_dependencies "")
ELSE(NOT ${swig_getdeps_error} EQUAL 0)
FILE(READ ${swig_getdeps_depsfile} ${DEST_VARIABLE})
# Remove the first line
STRING(REGEX REPLACE "^.+: +\\\\\n +" ""
${DEST_VARIABLE} "${${DEST_VARIABLE}}")
# Clean the end of each line
STRING(REGEX REPLACE " +(\\\\)?\n" "\n" ${DEST_VARIABLE}
"${${DEST_VARIABLE}}")
# Clean beginning of each line
STRING(REGEX REPLACE "\n +" "\n"
${DEST_VARIABLE} "${${DEST_VARIABLE}}")
# clean paths
STRING(REGEX REPLACE "\\\\\\\\" "/" ${DEST_VARIABLE}
"${${DEST_VARIABLE}}")
STRING(REGEX REPLACE "\n" ";"
${DEST_VARIABLE} "${${DEST_VARIABLE}}")
ENDIF(NOT ${swig_getdeps_error} EQUAL 0)
ENDMACRO(SWIG_GET_WRAPPER_DEPENDENCIES)
#
# For given swig module initialize variables associated with it
#
......@@ -221,10 +166,6 @@ MACRO(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
IF(SWIG_MODULE_${name}_EXTRA_FLAGS)
SET(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS})
ENDIF(SWIG_MODULE_${name}_EXTRA_FLAGS)
SWIG_GET_WRAPPER_DEPENDENCIES("${swig_source_file_fullname}"
"${swig_generated_file_fullname}" ${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}
swig_extra_dependencies)
LIST(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${swig_extra_dependencies})
ADD_CUSTOM_COMMAND(
OUTPUT "${swig_generated_file_fullname}" ${swig_extra_generated_files}
COMMAND "${SWIG_EXECUTABLE}"
......
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