Posted to tcl by STEVE!!!!!!!!!! at Wed Nov 26 00:03:43 GMT 2014view pretty

# - Find the Tcl package path.
# This module finds where Tcl is looking for installed packages.  It
# sets the following variable:
#  TCL_PACKAGE_PATH       = path to Tcl packages (tcllib etc)
#
#  Copyright (c) 2013, 2014 Steve Havelka
#
#  Redistribution and use is allowed according to the terms of the LICENSE
#  file.
#

file (WRITE ${CMAKE_BINARY_DIR}/readpkgPath.tcl "puts [join $auto_path {;}]")

# Retrieve the value of $tcl_pkgPath from the tclsh that's been found.
execute_process (COMMAND ${TCL_TCLSH} ${CMAKE_BINARY_DIR}/readpkgPath.tcl
                 OUTPUT_VARIABLE TCL_DETECTED_MODULE_DIRS
                 OUTPUT_STRIP_TRAILING_WHITESPACE)

foreach (DIR ${TCL_DETECTED_MODULE_DIRS})
  if (IS_DIRECTORY "${DIR}")
    set (TCL_PACKAGE_PATH "${DIR}" CACHE PATH "path to Tcl packages")
    break ()
  endif()
endforeach()

# remove the temporary tcl script
file (REMOVE ${CMAKE_BINARY_DIR}/readpkgPath.tcl)