Skip to content

Environment scripts

Mayeul d'Avezac edited this page Jun 16, 2014 · 5 revisions

In order to run newly compiled programs in the build directory, it is generally useful to set the LD_LIBRARY_PATH (and DYLD_LIBRARY_PATH on Macs) to point towards the location of external or internal libraries. To this end, there are three new functions:

add_to_ld_path(<PATH0> # Add PATH to (DY)LD_LIBRARY_PATH 
  <PATH1>              # Can be a directory or a library
  ...                  # Files ending with .a are ignored
)
add_to_py_paths(<PATHS>) # Add PATH to PYTHONPATH

These two functions create files in ${CMAKE_BINARY_DIR}/paths with one directory per line. These files can be edited by hand or by other scripts. When using add_to_*path, paths are unique. Environment scripts are created using the following function:

create_environment(
  [PATH <path/to/script>]            # Name of the script to create
                                     # Defaults to envscript.sh
  [SCRIPT <path/to/template]         # File to use as a template (call to configure_file)
  [EXECUTABLE <path/to/executable>]  # An executable to ... execute
  [WORKING_DIRECTORY <wd>]           # A directory to navigate to before execution
  [PYTHON]                           # Also changes PYTHONPATH
)