1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
|
###############################################################################
# configure tcl
# TCL support is currently unstable. Show the warning message
message(WARNING "TCL support is currently unstable.But if we you still want to use it, please go ahead!")
if(WRAP_ITK_INSTALL_COMPONENT_PER_MODULE)
message(WARNING "Option WRAP_ITK_INSTALL_COMPONENT_PER_MODULE is not supported for TCL wrapping language")
endif()
find_package(TCL REQUIRED)
# Hide useless settings provided by FindTCL.
foreach(entry TCL_LIBRARY_DEBUG
TK_LIBRARY_DEBUG
TCL_STUB_LIBRARY
TCL_STUB_LIBRARY_DEBUG
TK_STUB_LIBRARY
TK_STUB_LIBRARY_DEBUG
TK_WISH)
set(${entry} "${${entry}}" CACHE INTERNAL "This value is not used by ITK.")
endforeach()
include_directories(${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH})
###############################################################################
# store the current dir, so it can be reused later
set(ITK_WRAP_TCL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "tcl source dir")
set(ITK_WRAP_TCL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "tcl binary dir")
###############################################################################
# create the tcl directory in the classindex dir
file(MAKE_DIRECTORY ${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/tcl)
macro(itk_wrap_module_tcl library_name)
set(ITK_WRAP_TCL_LIBRARY_DEPS )
set(ITK_WRAP_TCL_LIBRARY_DECLS )
set(ITK_WRAP_TCL_LIBRARY_CALLS )
set(ITK_WRAP_TCL_CXX_FILES )
endmacro()
macro(itk_end_wrap_module_tcl)
# Loop over the extra swig input files and add them to the generated files
# lists. Guess that the generated cxx output will have the same name as
# the .i input file.
foreach(source ${WRAPPER_LIBRARY_SWIG_INPUTS})
get_filename_component(base_name ${source} NAME_WE)
itk_wrap_submodule_tcl("${base_name}")
itk_end_wrap_submodule_tcl("${base_name}")
endforeach()
# create the tcl customization stuff in the main module
# it allow to group the tcls module in a single shared lib, by loading the int
# functions of the module. I also import the objects from the submodules in the
# main module.
#
# It uses ITK_WRAP_TCL_LIBRARY_DECLS, ITK_WRAP_TCL_LIBRARY_CALLS
configure_file("${ITK_WRAP_TCL_SOURCE_DIR}/main_module_ext.i.in"
"${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/tcl/${WRAPPER_LIBRARY_NAME}_ext.i"
@ONLY)
)
# set some var reused later
set(interface_file "${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/${WRAPPER_LIBRARY_NAME}.i")
set(lib ${WRAPPER_LIBRARY_NAME}Tcl)
set(cpp_file "${CMAKE_CURRENT_BINARY_DIR}/${WRAPPER_LIBRARY_NAME}Tcl.cpp")
set(swig_command ${SWIG_EXECUTABLE})
if(ITK_USE_CCACHE)
set(swig_command ${CCACHE_EXECUTABLE} ${swig_command})
endif()
# and generate c++ code from the main module swig interface.
add_custom_command(
OUTPUT ${cpp_file}
COMMAND ${swig_command} -c++ -tcl -O -features autodoc=1 # -Werror
# -fcompact
-w509 # Overloaded method
-w365 # operator+= ignored
-w366 # operator-= ignored
-w367 # operator*= ignored
-w368 # operator/= ignored
-w378 # operator!= ignored
-w503 # Can't wrap 'operator []' unless renamed to a valid identifier.
-w508 # Declaration of '???' shadows declaration accessible via operator->()
### TODO: remove that once the bug for std::vector is fixed ###
-w401 # Maybe you forgot to instantiate 'XXX' using %template.
###
-w350 -w394 -w395 # operator new/new[]/delete[] ignored
-o ${cpp_file}
-I${GENERATORS_SRC_DIR}
-I${WRAP_ITK_TYPEDEFS_DIRECTORY}/tcl
-I${WRAP_ITK_TYPEDEFS_DIRECTORY}
-outdir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
${interface_file}
WORKING_DIRECTORY ${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/tcl
DEPENDS ${DEPS} ${ITK_WRAP_TCL_LIBRARY_DEPS} ${interface_file} ${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/tcl/${WRAPPER_LIBRARY_NAME}_ext.i ${SWIG_EXECUTABLE}
)
WRAP_ITK_BINDINGS_INSTALL("/Tcl" "${tcl_file}")
# build all the c++ files from this module in a common lib
set(lib ${WRAPPER_LIBRARY_NAME}Tcl)
add_library(${lib} SHARED ${cpp_file} ${ITK_WRAP_TCL_CXX_FILES} ${WRAPPER_LIBRARY_CXX_SOURCES})
if(CMAKE_COMPILER_IS_GNUCC)
# disable warnings generated by swig
set_target_properties(${lib} PROPERTIES COMPILE_FLAGS "-Wno-missing-field-initializers -Wno-shadow")
endif()
target_link_libraries(${lib} ${WRAPPER_LIBRARY_LINK_LIBRARIES} ${TCL_LIBRARY})
if(${module_prefix}_WRAP_EXPLICIT AND NOT ${WRAPPER_LIBRARY_NAME} STREQUAL ITKTclBase)
target_link_libraries(${lib} ${WRAPPER_LIBRARY_NAME}Explicit)
endif()
add_dependencies(${lib} ${WRAPPER_LIBRARY_NAME}Swig)
install(TARGETS "${lib}"
DESTINATION "${ITK_INSTALL_LIBRARY_DIR}/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}/Tcl"
COMPONENT ${WRAP_ITK_INSTALL_COMPONENT_IDENTIFIER}RuntimeLibraries
)
if(NOT EXTERNAL_WRAP_ITK_PROJECT)
# don't depends on the targets from wrapitk in external projects
foreach(dep ${WRAPPER_LIBRARY_DEPENDS})
add_dependencies(${lib} ${dep}Swig)
endforeach()
endif()
endmacro()
macro(itk_end_wrap_submodule_tcl group_name)
set(base_name ${group_name})
# the default typemaps, exception handler, and includes
set(ITK_WRAP_TCL_SWIG_EXT "%import tclBase.i\n\n${ITK_WRAP_TCL_SWIG_EXT}")
# create the swig interface for all the groups in the module
#
set(interface_file "${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/${base_name}.i")
set(lib ${group_name}Tcl)
set(cpp_file "${CMAKE_CURRENT_BINARY_DIR}/${base_name}Tcl.cpp")
# create the tcl customization for that wrap_*.cmake file.
configure_file("${ITK_WRAP_TCL_SOURCE_DIR}/module_ext.i.in"
"${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/tcl/${group_name}_ext.i"
@ONLY)
)
# prepare dependencies
set(DEPS )
foreach(dep ${WRAPPER_LIBRARY_DEPENDS})
list(APPEND DEPS ${${dep}SwigFiles})
endforeach()
set(swig_command ${SWIG_EXECUTABLE})
if(ITK_USE_CCACHE)
set(swig_command ${CCACHE_EXECUTABLE} ${swig_command})
endif()
# and run swig to produce the c++ file and the .tcl file
add_custom_command(
OUTPUT ${cpp_file}
COMMAND ${swig_command} -c++ -tcl -O -features autodoc=1 # -Werror
# -fcompact
-w509 # Overloaded method
-w365 # operator+= ignored
-w366 # operator-= ignored
-w367 # operator*= ignored
-w368 # operator/= ignored
-w378 # operator!= ignored
-w503 # Can't wrap 'operator []' unless renamed to a valid identifier
-w508 # Declaration of '???' shadows declaration accessible via operator->()
### TODO: remove that once the bug for std::vector is fixed ###
-w401 # Maybe you forgot to instantiate 'XXX' using %template.
###
-w350 -w394 -w395 # operator new/new[]/delete[] ignored
-o ${cpp_file}
-I${GENERATORS_SRC_DIR}
-I${WRAP_ITK_TYPEDEFS_DIRECTORY}/tcl
-I${WRAP_ITK_TYPEDEFS_DIRECTORY}
-outdir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
${interface_file}
WORKING_DIRECTORY ${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/tcl
DEPENDS ${DEPS} ${interface_file} ${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/tcl/${base_name}_ext.i ${SWIG_EXECUTABLE}
# ${ITK_WRAP_TCL_LIBRARY_DEPS}
)
# gcc visibility can't be used without getting errors when passing objects
# from one module to an other
#
# if(CMAKE_COMPILER_IS_GNUCC)
# set_target_properties(${lib} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
# endif()
# add the c++ files which will be generated by the swig command to the
# list of tcl related c++ files, so they can be built at the end
# of the current module.
list(APPEND ITK_WRAP_TCL_CXX_FILES ${cpp_file})
# add needed files to the deps list
list(APPEND ITK_WRAP_TCL_LIBRARY_DEPS "${WRAPPER_MASTER_INDEX_OUTPUT_DIR}/tcl/${base_name}_ext.i" "${cpp_file}")
# add this wrap_*.cmake stuff to the list of modules to init in the main module.
# first the extern c declaration
string(REGEX REPLACE "^(.)(.+)$" "\\1" first "${group_name}")
string(REGEX REPLACE "^(.)(.+)$" "\\2" rest "${group_name}")
string(TOUPPER "${first}" first)
string(TOLOWER "${rest}" rest)
set(capital_group_name "${first}${rest}tcl")
set(ITK_WRAP_TCL_LIBRARY_DECLS "${ITK_WRAP_TCL_LIBRARY_DECLS}extern \"C\" int ${capital_group_name}_Init( Tcl_Interp* );\n")
# and the call of the extern function
set(ITK_WRAP_TCL_LIBRARY_CALLS "${ITK_WRAP_TCL_LIBRARY_CALLS} ${capital_group_name}_Init( interp );\n")
endmacro()
macro(itk_wrap_one_type_tcl wrap_method wrap_class swig_name template_params)
endmacro()
macro(ADD_TCL_CONFIG_TEMPLATE base_name wrap_class swig_name template_params)
endmacro()
macro(itk_wrap_submodule_tcl module)
set(ITK_WRAP_TCL_SWIG_EXT "")
endmacro()
macro(itk_wrap_named_class_tcl class swig_name)
# store the current class wrapped, so we can generate the typemaps for itk::ImageSource
set(ITK_WRAP_TCL_CURRENT_CLASS "${class}")
set(ITK_WRAP_TCL_CURRENT_SWIG_NAME "${swig_name}")
endmacro()
macro(itk_wrap_template_tcl name types)
endmacro()
macro(itk_wrap_simple_type_tcl wrap_class swig_name)
if("${wrap_class}" MATCHES "<.*>")
string(REGEX REPLACE "^([^<]+)< *(.+) *>([^>]*)$" "\\1" cpp_name "${wrap_class}")
string(REGEX REPLACE "^([^<]+)< *(.+) *>([^>]*)$" "\\2" template_params "${wrap_class}")
string(REGEX REPLACE "^([^<]+)< *(.+) *>([^>]*)$" "\\3" ext_def "${wrap_class}")
else()
set(cpp_name "${wrap_class}")
set(template_params NO_TEMPLATE)
set(ext_def "")
endif()
string(REGEX REPLACE ".*::" "" simple_name "${cpp_name}")
# message("${wrap_class} -- ${swig_name}")
# message("${cpp_name} -- ${template_params} -- ${ext_def}")
# can't use that because std_vector.i complains loudly (with an error) about invalid superclass when that superclass is a std::vector
# not wrapped with %template
# but we can't declare them outside the current file without making swig use function defined outside
# TODO: reenable that once that bug is fixed
#
# if("${cpp_name}" STREQUAL "itk::VectorContainer" AND NOT "${swig_name}" MATCHES "Pointer$")
# # add a template definition for the superclass which is not in ITK
# string(REGEX REPLACE "^[^,]+, *(.+) *$" "\\1" superclass_template_param "${template_params}")
# if("${superclass_template_param}" MATCHES "::")
# set(param "${superclass_template_param}")
# string(REPLACE "::" "" superclass_template_param "${superclass_template_param}")
# string(REPLACE "unsigned" "U" superclass_template_param "${superclass_template_param}")
# string(REPLACE "signed" "S" superclass_template_param "${superclass_template_param}")
# string(REPLACE "char" "C" superclass_template_param "${superclass_template_param}")
# string(REPLACE "short" "S" superclass_template_param "${superclass_template_param}")
# string(REPLACE "long" "L" superclass_template_param "${superclass_template_param}")
# string(REPLACE "float" "F" superclass_template_param "${superclass_template_param}")
# string(REPLACE "double" "D" superclass_template_param "${superclass_template_param}")
# string(REPLACE " " "" superclass_template_param "${superclass_template_param}")
# string(REPLACE "<" "" superclass_template_param "${superclass_template_param}")
# string(REPLACE ">" "" superclass_template_param "${superclass_template_param}")
# string(REPLACE "," "" superclass_template_param "${superclass_template_param}")
# set(ITK_WRAP_TCL_SWIG_EXT "${ITK_WRAP_TCL_SWIG_EXT}%template(${swig_name}_Superclass) std::vector< ${superclass_template_param} >;\n")
# endif()
# endif()
# This part is useless because swig doesn't recognize that std::map< X, Y > is the same than
# std::map< X, Y, std::less< X > > and doesn't support a third parameter in the template
# specification.
# TODO: make a bugreport
#
# if("${cpp_name}" STREQUAL "itk::MapContainer" AND NOT "${swig_name}" MATCHES "Pointer$")
# # add a template definition for the superclass which is not in ITK
# string(REGEX REPLACE "^[^,]+, *(.+) *$" "\\1" superclass_template_param "${template_params}")
# if("${superclass_template_param}" MATCHES "::")
# set(param "${superclass_template_param}")
# string(REPLACE "::" "" superclass_template_param "${superclass_template_param}")
# string(REPLACE "unsigned" "U" superclass_template_param "${superclass_template_param}")
# string(REPLACE "signed" "S" superclass_template_param "${superclass_template_param}")
# string(REPLACE "char" "C" superclass_template_param "${superclass_template_param}")
# string(REPLACE "short" "S" superclass_template_param "${superclass_template_param}")
# string(REPLACE "long" "L" superclass_template_param "${superclass_template_param}")
# string(REPLACE "float" "F" superclass_template_param "${superclass_template_param}")
# string(REPLACE "double" "D" superclass_template_param "${superclass_template_param}")
# string(REPLACE " " "" superclass_template_param "${superclass_template_param}")
# string(REPLACE "<" "" superclass_template_param "${superclass_template_param}")
# string(REPLACE ">" "" superclass_template_param "${superclass_template_param}")
# string(REPLACE "," "" superclass_template_param "${superclass_template_param}")
# set(ITK_WRAP_TCL_SWIG_EXT "${ITK_WRAP_TCL_SWIG_EXT}%template(${swig_name}_Superclass) std::map< unsigned long, ${superclass_template_param}, std::less< unsigned long > >;\n")
# endif()
# endif()
endmacro()
###############################################################################
# Create the TclUtils library
if(NOT EXTERNAL_WRAP_ITK_PROJECT)
add_subdirectory(Tests)
macro(itk_end_wrap_modules_tcl)
###############################################################################
# Configure pkgIndex.tcl for the build tree.
if(CMAKE_CONFIGURATION_TYPES)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
set(ITK_WRAP_TCL_PACKAGE_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${config}")
configure_file("${ITK_WRAP_TCL_SOURCE_DIR}/pkgIndex.tcl.in"
"${ITK_WRAP_TCL_BINARY_DIR}/${config}/pkgIndex.tcl"
@ONLY)
endforeach()
else()
set(ITK_WRAP_TCL_PACKAGE_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
configure_file("${ITK_WRAP_TCL_SOURCE_DIR}/pkgIndex.tcl.in"
"${ITK_WRAP_TCL_BINARY_DIR}/pkgIndex.tcl"
@ONLY)
endif()
# configure pkgIndex.tcl for the installed tree
set(ITK_WRAP_TCL_PACKAGE_DIR "${ITK_INSTALL_LIBRARY_DIR}/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}/Tcl")
configure_file("${ITK_WRAP_TCL_SOURCE_DIR}/pkgIndex.tcl.in"
"${ITK_WRAP_TCL_BINARY_DIR}/InstallOnly/itkwish_wont_find_me_here/pkgIndex.tcl"
@ONLY)
WRAP_ITK_BINDINGS_INSTALL(/Tcl "${ITK_WRAP_TCL_BINARY_DIR}/InstallOnly/itkwish_wont_find_me_here/pkgIndex.tcl")
#install the actual executable
install(FILES ${ITK_WRAP_TCL_SOURCE_DIR}/itkinteraction.tcl
${ITK_WRAP_TCL_SOURCE_DIR}/itktesting.tcl
${ITK_WRAP_TCL_SOURCE_DIR}/itkdata.tcl
${ITK_WRAP_TCL_SOURCE_DIR}/itkutils.tcl
DESTINATION "${ITK_INSTALL_LIBRARY_DIR}/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}/Tcl"
COMPONENT ${WRAP_ITK_INSTALL_COMPONENT_IDENTIFIER}RuntimeLibraries
)
endmacro()
macro(itk_wrap_modules_tcl)
add_subdirectory(${ITK_WRAP_TCL_SOURCE_DIR}/TclBase)
endmacro()
else()
macro(itk_end_wrap_modules_tcl)
# just do nothing
endmacro()
macro(itk_wrap_modules_tcl)
# just do nothing
endmacro()
endif()
|