Commit 3ba0ecce authored by Sebastien Barre's avatar Sebastien Barre
Browse files

ENH: add macros/vars to handle copy of the Tcl/Tk support files if needed

parent e2be0b5d
# ----------------------------------------------------------------------------
# VTK_GET_TCL_TK_VERSION
# Return the major/minor version of the Tcl/Tk library used by VTK.
#
# in: tcl_tk_major_version: name of the var the major version is written to
# tcl_tk_minor_version: name of the var the minor version is written to
#
# ex: VTK_GET_TCL_TK_VERSION ("TCL_TK_MAJOR_VERSION" "TCL_TK_MINOR_VERSION")
# SET (TCL_TK_VERSION "${TCL_TK_MAJOR_VERSION}.${TCL_TK_MINOR_VERSION}")
MACRO (VTK_GET_TCL_TK_VERSION tcl_tk_major_version tcl_tk_minor_version)
# Try to find the current Tcl/Tk version by matching TK_INTERNAL_PATH
# or TCL_LIBRARY against some version numbers
SET (${tcl_tk_major_version} "")
SET (${tcl_tk_minor_version} "")
FOREACH (tcl_tk_minor_version_try "2" "3" "4")
IF ("${TK_INTERNAL_PATH}" MATCHES "tk8${tcl_tk_minor_version_try}")
SET (${tcl_tk_major_version} "8")
SET (${tcl_tk_minor_version} ${tcl_tk_minor_version_try})
ENDIF ("${TK_INTERNAL_PATH}" MATCHES "tk8${tcl_tk_minor_version_try}")
IF ("${TCL_LIBRARY}" MATCHES "tcl8${tcl_tk_minor_version_try}")
SET (${tcl_tk_major_version} "8")
SET (${tcl_tk_minor_version} ${tcl_tk_minor_version_try})
ENDIF ("${TCL_LIBRARY}" MATCHES "tcl8${tcl_tk_minor_version_try}")
ENDFOREACH (tcl_tk_minor_version_try)
ENDMACRO (VTK_GET_TCL_TK_VERSION)
# ----------------------------------------------------------------------------
# VTK_GET_TCL_SUPPORT_FILES, VTK_GET_TK_SUPPORT_FILES
# Get a list of Tcl/Tk support files for a given Tcl/Tk repository.
# Tcl/Tk support files are additional files that are mandatory for Tcl/Tk
# to work properly. Linking against Tcl/Tk shared/static library is just
# not enough, Tcl/Tk needs to access those files at run-time.
# A typical Tcl/Tk installation will store support files in sub-directories
# inside the Tcl/Tk lib directory, organized by version number.
# Example:
# c:/tcl/lib/tcl8.4
# c:/tcl/lib/tcl8.3
# c:/tcl/lib/tk8.4
# c:/tcl/lib/tk8.3
# A typical source repository is organized differently:
# c:/tcl8.4.5/library
# c:/tk8.4.5/library
# Given the path to the Tcl support lib dir, VTK_GET_TCL_SUPPORT_FILES will
# return the corresponding list of support files.
# Given the path to the Tk support lib dir, VTK_GET_TK_SUPPORT_FILES will
# return the corresponding list of support files.
#
# in: support_lib_dir: path to the Tcl (or Tk) support lib dir
# list: name of the var the list is written to
MACRO (VTK_GET_TCL_SUPPORT_FILES tcl_support_lib_dir list)
# Tcl support files (*.tcl + encoding + tclIndex, etc.)
FILE (GLOB TCL_SUPPORT_FILES_TCL "${tcl_support_lib_dir}/*.tcl")
FILE (GLOB TCL_SUPPORT_FILES_ENC "${tcl_support_lib_dir}/encoding/*.enc")
SET (${list}
"${tcl_support_lib_dir}/tclIndex"
${TCL_SUPPORT_FILES_TCL}
${TCL_SUPPORT_FILES_ENC})
ENDMACRO (VTK_GET_TCL_SUPPORT_FILES)
MACRO (VTK_GET_TK_SUPPORT_FILES tk_support_lib_dir list)
# Tk support files (*.tcl + tclIndex, etc.)
FILE (GLOB TK_SUPPORT_FILES_TCL "${tk_support_lib_dir}/*.tcl")
SET (${list}
"${tk_support_lib_dir}/tclIndex"
${TK_SUPPORT_FILES_TCL})
ENDMACRO (VTK_GET_TK_SUPPORT_FILES)
# ----------------------------------------------------------------------------
# VTK_COPY_TCL_TK_SUPPORT_FILES
# Copy Tcl/Tk support files to a different location.
# See VTK_GET_TCL_SUPPORT_FILES for more info about support files.
# Given the paths to the Tcl and Tk support lib dirs, this macro will copy
# the appropriate support files to destination dirs, recreating the subdirs.
#
# in: tcl_support_lib_dir: path to the Tcl support lib dir
# tcl_support_lib_dest: destination dir for the Tcl support lib files
# tk_support_lib_dir: path to the Tk support lib dir
# tk_support_lib_dest: destination dir for the Tk support lib files
#
# ex: VTK_COPY_TCL_TK_SUPPORT_FILES (
# "c:/tcl/lib/tcl8.4" "d:/vtk-bin/TclTk/lib/tcl8.4"
# "c:/tcl/lib/tk8.4" "d:/vtk-bin/TclTk/lib/tk8.4")
# this will copy support files from:
# c:/tcl/lib/tcl8.4
# c:/tcl/lib/tk8.4
# to:
# d:/vtk-bin/TclTk/lib/tcl8.4
# d:/vtk-bin/TclTk/lib/tk8.4
MACRO (VTK_COPY_TCL_TK_SUPPORT_FILES tcl_support_lib_dir tcl_support_lib_dest tk_support_lib_dir tk_support_lib_dest)
# Get the support files and copy them to dest dir
# Check if EXISTS to work around CONFIGURE_FILE bug (if file does not
# exist, it would create the subdirs anyway)
VTK_GET_TCL_SUPPORT_FILES(${tcl_support_lib_dir} "TCL_SUPPORT_FILES")
FOREACH (file ${TCL_SUPPORT_FILES})
IF (EXISTS ${file})
STRING (REGEX REPLACE "${tcl_support_lib_dir}/" "" filebase ${file})
CONFIGURE_FILE (${file} "${tcl_support_lib_dest}/${filebase}" COPYONLY)
ENDIF (EXISTS ${file})
ENDFOREACH (file)
VTK_GET_TK_SUPPORT_FILES(${tk_support_lib_dir} "TK_SUPPORT_FILES")
FOREACH (file ${TK_SUPPORT_FILES})
IF (EXISTS ${file})
STRING (REGEX REPLACE "${tk_support_lib_dir}/" "" filebase ${file})
CONFIGURE_FILE (${file} "${tk_support_lib_dest}/${filebase}" COPYONLY)
ENDIF (EXISTS ${file})
ENDFOREACH (file)
ENDMACRO (VTK_COPY_TCL_TK_SUPPORT_FILES)
# ----------------------------------------------------------------------------
# VTK_COPY_TCL_TK_SUPPORT_FILES_TO_BUILD_DIR
# Front-end to VTK_COPY_TCL_TK_SUPPORT_FILES, this macro will copy the
# appropriate Tcl/Tk support files to a project build directory.
# The support files will be copied simultaneously to all configuration
# sub-directories (Release, RelInfo, Debug, etc.) if needed.
# The Tcl/Tk version is retrieved automatically and used to create
# the subdirectories (see example below)
#
# in: tcl_support_lib_dir: path to the Tcl support lib dir
# tk_support_lib_dir: path to the Tk support lib dir
# build_dir: project build dir
# dir: relative subdir inside the build dir, into which the
# support files will be copied.
#
# ex: VTK_COPY_TCL_TK_SUPPORT_FILES_TO_BUILD_DIR (
# "c:/tcl/lib/tcl8.4" "c:/tcl/lib/tk8.4" "d:/vtk-bin" "TclTk/lib")
# if this project is configured to use TclTk 8.4, this will copy support
# files from:
# c:/tcl/lib/tcl8.4
# c:/tcl/lib/tk8.4
# to:
# d:/vtk-bin/TclTk/lib/tcl8.4
# d:/vtk-bin/TclTk/lib/tk8.4
# or (if configuration types are supported by the generator):
# d:/vtk-bin/Release/TclTk/lib/tcl8.4
# d:/vtk-bin/Release/TclTk/lib/tk8.4
# d:/vtk-bin/Debug/TclTk/lib/tcl8.4
# d:/vtk-bin/Debug/TclTk/lib/tk8.4
# etc.
MACRO (VTK_COPY_TCL_TK_SUPPORT_FILES_TO_BUILD_DIR tcl_support_lib_dir tk_support_lib_dir build_dir dir)
# For each configuration type (Debug, RelInfo, Release, etc.)
# Copy the TclTk support files to the corresponding sub-directory inside
# the build dir
VTK_GET_TCL_TK_VERSION ("TCL_TK_MAJOR_VERSION" "TCL_TK_MINOR_VERSION")
IF (TCL_TK_MAJOR_VERSION AND TCL_TK_MINOR_VERSION)
SET (TCL_TK_VERSION "${TCL_TK_MAJOR_VERSION}.${TCL_TK_MINOR_VERSION}")
IF (CMAKE_CONFIGURATION_TYPES)
SET (CONFIG_TYPES ${CMAKE_CONFIGURATION_TYPES})
ELSE (CMAKE_CONFIGURATION_TYPES)
SET (CONFIG_TYPES .)
ENDIF (CMAKE_CONFIGURATION_TYPES)
FOREACH (config "${CONFIG_TYPES}")
VTK_COPY_TCL_TK_SUPPORT_FILES (
"${tcl_support_lib_dir}"
"${build_dir}/${config}/${dir}/tcl${TCL_TK_VERSION}"
"${tk_support_lib_dir}"
"${build_dir}/${config}/${dir}/tk${TCL_TK_VERSION}"
)
ENDFOREACH (config)
ENDIF (TCL_TK_MAJOR_VERSION AND TCL_TK_MINOR_VERSION)
ENDMACRO (VTK_COPY_TCL_TK_SUPPORT_FILES_TO_BUILD_DIR)
......@@ -592,15 +592,17 @@ ENDIF(VTK_USE_PARALLEL)
# Configure Tcl wrapping support.
IF(VTK_WRAP_TCL)
INCLUDE(${CMAKE_ROOT}/Modules/FindTCL.cmake)
INCLUDE(${VTK_SOURCE_DIR}/CMake/vtkTclTkMacros.cmake)
# 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)
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 VTK.")
ENDFOREACH(entry)
......@@ -623,19 +625,21 @@ IF(VTK_WRAP_TCL)
OPTION(TCL_TK_STATIC "Build with static Tcl/Tk support. TCL_LIBRARY and TK_LIBRARY must point to the corresponding Tcl/Tk static libraries (example, tcl84sx.lib, tk84sx.lib)." OFF)
MARK_AS_ADVANCED(TCL_TK_STATIC)
IF(TCL_TK_STATIC AND WIN32)
IF(TK_LIBRARY MATCHES tk84)
SET(TRY_TK_RESOURCE_FILE_IN
${VTK_SOURCE_DIR}/Rendering/tkInternals/tk84/win/rc)
ENDIF(TK_LIBRARY MATCHES tk84)
FIND_FILE(TK_RESOURCE_FILE tk.rc ${TRY_TK_RESOURCE_FILE_IN} DOC "The resource file required to add the proper resources to a static Tk build")
MARK_AS_ADVANCED(TK_RESOURCE_FILE)
ENDIF (TCL_TK_STATIC AND WIN32)
ENDIF(VTK_WRAP_TCL)
# If TCL_TK_STATIC is meant to be used in C++, then we have to create a
# variable with a VTK_ prefix (it will be configured in vtkToolkits.h.in)
VTK_PREPARE_CMAKEDEFINE("" TCL_TK_STATIC VTK_TCL_TK_STATIC)
# If TCL_TK_COPY_SUPPORT_LIBRARY is meant to be used in C++, then we
# have to create a variable with a VTK_ prefix (it will be configured
# in vtkToolkits.h.in)
VTK_PREPARE_CMAKEDEFINE(
"" TCL_TK_COPY_SUPPORT_LIBRARY VTK_TCL_TK_COPY_SUPPORT_LIBRARY)
INSTALL_FILES(/lib/vtk/CMake FILES
${VTK_SOURCE_DIR}/CMake/vtkTclTkMacros.cmake)
#-----------------------------------------------------------------------------
# Configure Python wrapping support.
IF(VTK_WRAP_PYTHON)
......@@ -785,7 +789,7 @@ CONFIGURE_FILE(${VTK_SOURCE_DIR}/UseVTK.cmake.in
${VTK_BINARY_DIR}/UseVTK.cmake COPYONLY IMMEDIATE)
CONFIGURE_FILE(${VTK_SOURCE_DIR}/vtkToolkits.h.in
${VTK_BINARY_DIR}/vtkToolkits.h @ONLY IMMEDIATE)
${VTK_BINARY_DIR}/vtkToolkits.h @ONLY)
#-----------------------------------------------------------------------------
# The entire VTK tree should use the same include path.
......
......@@ -71,8 +71,13 @@ SET(VTK_USE_X "@VTK_USE_X@")
SET(VTK_WRAP_JAVA "@VTK_WRAP_JAVA@")
SET(VTK_WRAP_PYTHON "@VTK_WRAP_PYTHON@")
SET(VTK_WRAP_TCL "@VTK_WRAP_TCL@")
SET(TCL_TK_STATIC "@TCL_TK_STATIC@")
SET(TK_RESOURCE_FILE "@TK_RESOURCE_FILE@")
SET(TCL_TK_STATIC "@TCL_TK_STATIC@")
SET(TCL_TK_COPY_SUPPORT_LIBRARY "@TCL_TK_COPY_SUPPORT_LIBRARY@")
SET(TCL_SUPPORT_LIBRARY_PATH "@TCL_SUPPORT_LIBRARY_PATH@")
SET(TK_SUPPORT_LIBRARY_PATH "@TK_SUPPORT_LIBRARY_PATH@")
SET(VTK_TCL_TK_MACROS "@VTK_TCL_TK_MACROS_CONFIG@")
# The VTK executable locations.
SET(VTK_TCL_HOME "@VTK_TCL_HOME_CONFIG@")
......
......@@ -85,6 +85,8 @@ ENDIF(VTK_RENDERING_NEED_TK_INTERNAL)
# CMake extension module directory.
SET(VTK_LOAD_CMAKE_EXTENSIONS_MACRO_CONFIG
"${VTK_SOURCE_DIR}/CMake/vtkLoadCMakeExtensions.cmake")
SET(VTK_TCL_TK_MACROS_CONFIG
"${VTK_SOURCE_DIR}/CMake/vtkTclTkMacros.cmake")
SET(VTK_CMAKE_EXTENSIONS_DIR_CONFIG ${VTK_BINARY_DIR}/CMake)
# Library dependencies file.
......@@ -198,6 +200,8 @@ SET(VTK_TK_INTERNAL_ROOT_CONFIG ${CMAKE_INSTALL_PREFIX}/include/vtk)
# CMake extension module directory and macro file.
SET(VTK_LOAD_CMAKE_EXTENSIONS_MACRO_CONFIG
"${CMAKE_INSTALL_PREFIX}/lib/vtk/CMake/vtkLoadCMakeExtensions.cmake")
SET(VTK_TCL_TK_MACROS_CONFIG
"${CMAKE_INSTALL_PREFIX}/lib/vtk/CMake/vtkTclTkMacros.cmake")
SET(VTK_CMAKE_EXTENSIONS_DIR_CONFIG ${CMAKE_INSTALL_PREFIX}/lib/vtk/CMake)
# Library dependencies file.
......
......@@ -48,6 +48,9 @@
/* Whether we are linking to Tcl/Tk statically. */
#cmakedefine VTK_TCL_TK_STATIC
/* Wheter the Tcl/Tk support files are copied to the build dir */
#cmakedefine VTK_TCL_TK_COPY_SUPPORT_LIBRARY
/* Debug leaks support. */
#cmakedefine VTK_DEBUG_LEAKS
......
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