1# Attempt to build up the path/ld_library_path/python path needed to run VTK.
2# On Windows simply executing the .bat file should be enough, on Linux/Mac the
3# file can be sourced in the shell. You can also copy and paste the relevant
4# parts into other files if preferred.
5#
6# Note: Now only setting the path to the latest configuration used (for MSVC/Xcode)
7
8set(cfg_bit "")
9if (CMAKE_CONFIGURATION_TYPES)
10  set(cfg_bit ".$<CONFIG>")
11endif ()
12
13if(WIN32)
14  set(VTK_PATH_SHELL_SCRIPT "windows_path${cfg_bit}.bat")
15  set(PATH_FORMAT "set xxx_path_var=xxx_add_path;%xxx_path_var%\r\n")
16  set(PATH_VARIABLE "PATH")
17  set(PATH_SEPARATOR ";")
18elseif(UNIX)
19  set(VTK_PATH_SHELL_SCRIPT "unix_path${cfg_bit}.sh")
20  if(APPLE)
21    set(DYLD "DYLD")
22  else()
23    set(DYLD "LD")
24  endif()
25  set(PATH_VARIABLE "${DYLD}_LIBRARY_PATH")
26  set(PATH_SEPARATOR ":")
27  set(PATH_FORMAT "export xxx_path_var=xxx_add_path:\${xxx_path_var}\n")
28endif()
29
30# set the script file name
31set(PATH_FILENAME "${VTK_BINARY_DIR}/${VTK_PATH_SHELL_SCRIPT}")
32
33set(cfg_subdir "")
34if (CMAKE_CONFIGURATION_TYPES)
35  set(cfg_subdir "/$<CONFIG>")
36endif ()
37
38# FOR THE PATH VARIABLE
39# replace the path to the executables
40string(REPLACE "xxx_add_path" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}${cfg_subdir}" PATH_TEMP "${PATH_FORMAT}")
41# replace the name of the platform-specific path environment variable
42string(REPLACE "xxx_path_var" "${PATH_VARIABLE}" PATH_LINES "${PATH_TEMP}")
43
44if(VTK_WRAP_PYTHON)
45  # FOR THE PYTHONPATH VARIABLE, if PYTHON is wrapped
46  # replace the path to the python-specific files
47  string(REPLACE "xxx_add_path" "${VTK_BUILD_PYTHON_MODULES_DIR}" PATH_TEMP "${PATH_FORMAT}")
48  # replace pathvar by PYTHONPATH
49  string(REPLACE "xxx_path_var" "PYTHONPATH" PATH_TEMP "${PATH_TEMP}")
50  # apped the line to the file
51  set(PATH_LINES "${PATH_LINES}${PATH_TEMP}")
52endif()
53
54# write to file
55file(GENERATE
56  OUTPUT  "${PATH_FILENAME}"
57  CONTENT "${PATH_LINES}")
58