Skip to content

Instantly share code, notes, and snippets.

@smutch
Created September 30, 2019 04:10
Show Gist options
  • Save smutch/26e80a593b6afbec33053b6dab1244e6 to your computer and use it in GitHub Desktop.
Save smutch/26e80a593b6afbec33053b6dab1244e6 to your computer and use it in GitHub Desktop.
sh: Generate the appropriate contents of CMAKE_PREFIX_PATH for the loaded set of modules.
#!/usr/bin/env bash
# Generate the appropriate contents of CMAKE_PREFIX_PATH for the loaded set of modules.
# Author: S. Mutch (2019)
#
# Usage:
# CMAKE_PREFIX_PATH=`cmake_prefix_path` cmake ..
cmake_prefix_path=""
modules=$(module list -t 2>&1 | tail -n +2)
for module in $modules; do
cmake_prefix_path+=$(module show $module 2>&1 | grep ' LIBRARY_PATH' | cut -d' ' -f 3 | sed 's/\(.*\)\/lib.*/\1:/g')
done
cmake_prefix_path=$(echo $cmake_prefix_path | sed 's/: /:/g')
echo $cmake_prefix_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment