Skip to content

Instantly share code, notes, and snippets.

@grodtron
Created October 22, 2015 01:41
Show Gist options
  • Save grodtron/91fae162314e8c6bce9a to your computer and use it in GitHub Desktop.
Save grodtron/91fae162314e8c6bce9a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Fix Broken cmake files for llvm-3.5-dev
# See : https://bugs.launchpad.net/ubuntu/+source/llvm/+bug/1387011
target='/usr/share/llvm-3.5/cmake/LLVMConfig.cmake'
sudo patch --backup $target <<HEREDOC
--- original
+++ repaired
@@ -43,7 +43,7 @@
set(LLVM_INCLUDE_DIRS "/usr/lib/llvm-3.5/include")
set(LLVM_LIBRARY_DIRS "/usr/lib/llvm-3.5/lib")
set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS")
-set(LLVM_CMAKE_DIR "/usr/lib/llvm-3.5/share/llvm/cmake")
+set(LLVM_CMAKE_DIR "/usr/share/llvm-3.5/cmake")
set(LLVM_TOOLS_BINARY_DIR "/usr/lib/llvm-3.5/bin")
if(NOT TARGET LLVMSupport)
HEREDOC
# Update LLVMExports by creating the targets and giving their
# locations.
target_cmake=/usr/share/llvm-3.5/cmake/LLVMExports.cmake
backup_cmake=$target_cmake.bak
if [ ! -f $backup_cmake ]
then
sudo cp $target_cmake $backup_cmake
fi
tmp=$(mktemp)
libdir=$(llvm-config --libdir)
for file in $(llvm-config --libnames)
do
target=$(echo $file | sed 's/lib\(.*\)\.a/\1/')
echo "add_library($target STATIC IMPORTED)" \
>> $tmp
echo "set_property(TARGET $target PROPERTY IMPORTED_LOCATION "\
"\"$libdir/lib$target.a\")"\
>> $tmp
done
cat $target_cmake >> $tmp
sudo mv $tmp $target_cmake
sudo chown --reference=$backup_cmake $target_cmake
sudo chmod --reference=$backup_cmake $target_cmake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment