How do I install vigra on macOS Mojave? - bash

I need to use CellProfiler 2.2.0 and for that I need vigra. I followed the instructions you can find here, or at least as I interpreted them. In short:
I cloned the git-repository.
cd ~/git/vigra.
mkdir a directory to build and cd to that one
cmake
However, when I want make the package at step 5), I run into this:
swvanderlaan#Sanders-MBP ~/git
$ git clone git#github.com:ukoethe/vigra.git
Cloning into 'vigra'...
remote: Enumerating objects: 49815, done.
remote: Total 49815 (delta 0), reused 0 (delta 0), pack-reused 49815
Receiving objects: 100% (49815/49815), 106.46 MiB | 7.64 MiB/s, done.
Resolving deltas: 100% (36407/36407), done.
swvanderlaan#Sanders-MBP ~/git
$ cd vigra/
swvanderlaan#Sanders-MBP ~/git/vigra
$ ls
CMakeLists.txt LICENSE.txt README.md azure-pipelines.yml config docsrc include src test vigranumpy
swvanderlaan#Sanders-MBP ~/git/vigra
$ mkdir -v build
mkdir: created directory 'build'
swvanderlaan#Sanders-MBP ~/git/vigra
$ cd build/
swvanderlaan#Sanders-MBP ~/git/vigra/build
$ cmake ../src/
-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.14)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/swvanderlaan/git/vigra/build
swvanderlaan#Sanders-MBP ~/git/vigra/build
$ make
Scanning dependencies of target vigraimpex
[ 4%] Building CXX object impex/CMakeFiles/vigraimpex.dir/bmp.o
/Users/swvanderlaan/git/vigra/src/impex/bmp.cxx:38:10: fatal error: 'vigra/config.hxx' file not found
#include "vigra/config.hxx"
^~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [impex/CMakeFiles/vigraimpex.dir/bmp.o] Error 1
make[1]: *** [impex/CMakeFiles/vigraimpex.dir/all] Error 2
make: *** [all] Error 2
How do I fix this?
Thanks and best,
Sander
My system: macOS Mojave 10.14.5 with brew:
brew config
HOMEBREW_VERSION: 2.1.6
ORIGIN: https://github.com/Homebrew/brew
HEAD: fddf5b16bd8df577380a1d810d17825ef611b81f
Last commit: 3 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 6b7110635d52dbecd386c7c538b812da87dc2da3
Core tap last commit: 18 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1001
Git: 2.22.0 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_212
macOS: 10.14.5-x86_64
CLT: 10.2.1.0.1.1554506761
Xcode: 10.2.1
CLT headers: 10.2.1.0.1.1554506761
XQuartz: 2.7.11 => /opt/X11

The easiest way to install vigra on Mac/Linux/Windows without compiling anything is to use conda:
conda install -c conda-forge vigra
Note: Vigra supports a number of optional dependencies. That build supports many of them, but if you're interested in a particular feature, you can check the conda-forge built script for vigra:
https://github.com/conda-forge/vigra-feedstock/blob/master/recipe/build.sh
[I know this answer is much too late to be helpful, and it sounds like you didn't really need vigra anyway. But hopefully this is useful for any future googlers out there that might come across this page.]

Related

How can I make homebrew's cmake to use system clang

OS: MacOS 12.4
Installed cmake with
brew install cmake
cmake version 3.23.3
Installed clang with
xcode-select --install
clang++ version is 13.1.6
Trying to build ccls:
git clone https://github.com/MaskRay/ccls.git
mkdir build && cd build
cmake ..
And getting following output
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- The C compiler identification is AppleClang 13.1.6.13160021
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Setting build type to 'Release' as none was specified.
CMake Error at CMakeLists.txt:72 (find_package):
By not providing "FindClang.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Clang", but
CMake did not find one.
Could not find a package configuration file provided by "Clang" with any of
the following names:
ClangConfig.cmake
clang-config.cmake
Add the installation prefix of "Clang" to CMAKE_PREFIX_PATH or set
"Clang_DIR" to a directory containing one of the above files. If "Clang"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/Users/umed/projects/MaskRay/ccls/build/CMakeFiles/CMakeOutput.log".
See also "/Users/umed/projects/MaskRay/ccls/build/CMakeFiles/CMakeError.log".
Is there anyway to make brew's cmake work with system clang?
The question is not correct. CMake uses the system clang successfully, but it can't find clang libraries required by the project.
The Build manual lists the requirements, one of them is
Clang+LLVM headers and libraries, version >= 7
You get errors because you have not provided that dependency.
brew install llvm#13

cmake build failed on macos catalina 10.15

I have recently installed macos catalina with Xcode 11.1 and updated cmake, clang and llvm
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
$ cmake --version
cmake version 3.15.4
$ which cmake
/usr/local/bin/cmake
$ clang --version
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ which clang
/usr/bin/clang
The CMakeLists.txt looks as bellow:
cmake_minimum_required(VERSION 3.14)
project("ROZZETA" VERSION 0.0.1 LANGUAGES C)
# Allow us to import cmake scripts from ./cmake
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# Compiler flags
set(CMAKE_C_COMPILER /usr/bin/clang CACHE PATH "")
find_package(GMP REQUIRED)
add_executable(Rozzeta main.c)
target_link_libraries(Rozzeta gmp libgmp libgmp.a)
cmake detected gmp successfully :
/usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=c++ -G "CodeBlocks - Unix Makefiles" /<path to project>
-- The C compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Using toolchain file: .
-- Found GMP: /usr/local/include/gmp.h and /usr/local/lib/libgmp.a
-- Configuring done
-- Generating done
build failed :
cmake --build .
Scanning dependencies of target Rozzeta
[ 50%] Building C object CMakeFiles/Rozzeta.dir/main.c.o
/Users/gajaka/CLionProjects/Rozzeta/main.c:4:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
^~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/Rozzeta.dir/main.c.o] Error 1
make[1]: *** [CMakeFiles/Rozzeta.dir/all] Error 2
make: *** [all] Error 2
I have compiled manually with:
cc main.c -lgmp
Anyone can help me with this ?
Many thanks in advance
It was very frustrating for me! I am personally using CLion from jetbrains, while tried to build old codes written in C/C++, it's giving me error because MacOS 10.15, Catalina removed the C headers pkg used to be in Mojave. So, found another way around and tried.
If you have installed XCode 11.1, then open the terminal and run the following command:
xcode-select --install
then,
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
Now, you are good to go. Try to build using cmake.
If you're calling find_package(GMP ...) in your CMake file, why not use the GMP-specific variables it populates? It looks like CMake successfully finds GMP installed on your system (based on your CMake log), so try using the GMP_* variables that should be populated:
cmake_minimum_required(VERSION 3.14)
project("ROZZETA" VERSION 0.0.1 LANGUAGES C)
# Allow us to import cmake scripts from ./cmake
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
# Compiler flags
set(CMAKE_C_COMPILER /usr/bin/clang CACHE PATH "")
find_package(GMP REQUIRED)
add_executable(Rozzeta main.c)
# Use the populated GMP variables here.
target_include_directories(Rozzeta PRIVATE ${GMP_INCLUDE_DIR})
target_link_libraries(Rozzeta PRIVATE ${GMP_LIB})
after
xcode-select --install
I got a clang but no cmake so I did
brew install cmake
which installed cmake for Catalina.
In order to compile programs with cmake and XCode's toolchain in Mac OS 10.15 (Catalina) you must install xcode command line utility tools + make some additional symlinks (#Roy said about it, but forgot to mention other two):
$ xcode-select --install
$ sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
$ for i in {Platforms,Toolchains,Tools}; do sudo ln -sn /Applications/Xcode.app/Contents/Developer/$i /Library/Developer/CommandLineTools/$i; done

How to use cmake to let command "pkg_check_modules" be passed in Windows with git-bash

I want to build nss-pem on Windows by cmake with git-bash(or msys or cygwin). cmake found pkg-config in my cygwin's bin directory. I also added the directory path into PKG_CONFIG_PATH, and added .pc file and built-nss-lib into the directory I added. But I still got error when cmake exe the line pkg_check_modules(NSS REQUIRED "nss")
$PKG_CONFIG_PATH:
User#host MINGW64 ~/Desktop/nss-pem/build
$ echo $PKG_CONFIG_PATH
/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
CMake Error:
User#host MINGW64 ~/Desktop/nss-pem/build
$ cmake ../src
-- Checking for module 'nss'
-- No package 'nss' found
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPkgConfig.cmake:412 (message):
A required package was not found
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.9/Modules/FindPkgConfig.cmake:588 (_pkg_check_modules_internal)
CMakeLists.txt:7 (pkg_check_modules)
nss.pc:
# nss pkg-config
prefix=D:/Projects/library/nss
exec_prefix=${prefix}
includedir=${prefix}
libdir=${exec_prefix}/WIN954.0_x86_64_64_OPT.OBJ/lib/
Name: nss
Description: The nss library
Version: 3.32
Cflags: -I${includedir}/WIN954.0_x86_64_64_OPT.OBJ/include -I${includedir}/public/nss
Libs: -L${libdir} -lnss3 -lnspr4
What is the correct way to build this project? And what is the best way to setup the unix-like environment to build projects on Windows?
 
Update
I try to use git-bash and add cygwin/bin into my env variables. The command I used to call cmake is cmake -G "MSYS Makefiles" ../src. It seems that it occur some errors of path.
$ cmake -G "MSYS Makefiles" ../src
-- The C compiler identification is GNU 5.4.0
-- Check for working C compiler: C:/cygwin/bin/gcc.exe
-- Check for working C compiler: C:/cygwin/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/CMakeTestCCompiler .cmake:51 (message):
The C compiler "C:/cygwin/bin/gcc.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: C:/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/cygwin/bin/make.exe" "cmTC_bdb42/fast"
/usr/bin/make -f CMakeFiles/cmTC_bdb42.dir/build.make
CMakeFiles/cmTC_bdb42.dir/build
make[1]: Entering directory
'/cygdrive/c/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeTmp'
/bin/sh: /C/Program Files/CMake/bin/cmake.exe: No such file or directory
make[1]: *** [CMakeFiles/cmTC_bdb42.dir/build.make:65:
CMakeFiles/cmTC_bdb42.dir/testCCompiler.c.obj] Error 127
make[1]: Leaving directory
'/cygdrive/c/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:126: cmTC_bdb42/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/User/Desktop/nss-pem/build/CMakeFiles/CMakeError.log".
/bin/sh: /C/Program Files/CMake/bin/cmake.exe: No such file or directory: bash could not find cmake.exe, even if I modified the CMakeCache.txt. And the C compiler checking always fail. (I can manually compile the test file.)
So I gave up to work with git-bash, and turn to use Windows' cmd.exe with MinGW. Below is the steps what I done.
Clean up PATH env variables (remove cygwin's dirs).
Copy pkg-config.exe and the required dynamic libraries into MinGW/bin.
Create MinGW/lib/pkgconfig/nss.pc.
Below is the message returned:
C:\Users\IvenCJ7\Desktop\nss-pem\build>cmake -G "MinGW Makefiles" ../src
-- The C compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: C:/MinGW/bin/pkg-config.exe (found version "0.29.1")
-- Checking for module 'nss'
-- Found nss, version 3.32
-- Looking for lowkeyti.h
-- Looking for lowkeyti.h - found
-- Looking for NSSCKFWSlot_GetSlotID
-- Looking for NSSCKFWSlot_GetSlotID - not found
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/User/Desktop/nss-pem/build
cmake still cannot find the function, NSSCKFWSlot_GetSlotID in NSS. I made sure the function is in the NSS's include headers.
Below is the information that pkg-config return to me.
$ pkg-config --cflags --libs nss
-ID:/Projects/library/nss/WIN954.0_x86_64_64_OPT.OBJ/include
-ID:/Projects/library/nss/public/nss
-LD:/Projects/library/nss/WIN954.0_x86_64_64_OPT.OBJ/lib/ -lnss3 -lnspr4

caffe cmake error by ccache

When I successfully 'cmake ..' caffe build, I preceed with 'make all' command but came up with an error below. I don't know if there is something wrong with NVCC or gcc.
[ 1%] Built target proto
[ 1%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/layers/cuda_compile_generated_split_layer.cu.o
/usr/bin/ccache: invalid option -- 'E'
Usage:
ccache [options]
ccache compiler [compiler options]
compiler [compiler options] (via symbolic link)
Options:
-c, --cleanup delete old files and recalculate size counters
(normally not needed as this is done automatically)
-C, --clear clear the cache completely
-F, --max-files=N set maximum number of files in cache to N (use 0 for
no limit)
-M, --max-size=SIZE set maximum size of cache to SIZE (use 0 for no
limit; available suffixes: G, M and K; default
suffix: G)
-s, --show-stats show statistics summary
-z, --zero-stats zero statistics counters
-h, --help print this help text
-V, --version print version and copyright information
See also <http://ccache.samba.org>.
CMake Error at cuda_compile_generated_split_layer.cu.o.cmake:206 (message):
Error generating
/home/gpuusr/lpq/caffe-332/build/src/caffe/CMakeFiles/cuda_compile.dir/layers/./cuda_compile_generated_split_layer.cu.o
make[2]: *** [src/caffe/CMakeFiles/cuda_compile.dir/layers/cuda_compile_generated_split_layer.cu.o] Error 1
make[1]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2
make: *** [all] Error 2
I had a similar issue trying to build OpenCV with CUDA support. There's some odd interaction between CMake, CUDA, and ccache that I don't understand, it's trying to call ccache with invalid arguments. You can bypass this by specifying your system compiler for CUDA instead:
cmake -DCUDA_HOST_COMPILER=/usr/bin/g++ ..
(Or whatever compiler you're using.)
This used to be a bug in CMake. It was fixed with CMake release 3.4.0.
Proof
The code from here can be compiled with the following CMakeLists.txt.
cmake_minimum_required (VERSION 2.8.9 FATAL_ERROR)
project(CudaTest)
find_package(CUDA REQUIRED)
cuda_add_executable(hello_cuda hello.cu)
With /usr/lib/ccache on the PATH.
Building once with CMake 3.2 and once with CMake 3.7.1.
CMake 3.2:
$ make
...
/path/to/build-3.2
[100%] Building NVCC (Device) object CMakeFiles/hello_cuda.dir/hello_cuda_generated_hello.cu.o
/usr/bin/ccache: invalid option -- 'E'
...
CMake 3.7.1:
$ make
[ 50%] Building NVCC (Device) object CMakeFiles/hello_cuda.dir/hello_cuda_generated_hello.cu.o
[100%] Linking CXX executable hello_cuda
[100%] Built target hello_cuda
For the record
A small git bisect run over CMake 3.2.2 -- 3.7.1 shows that this is the commit that fixed it:
commit b405f01daaeaeda98d448e2f0d71ea685757a5bd
Author: Bill Hoffman <bill.hoffman#kitware.com>
Date: Fri Jun 12 14:16:09 2015 -0400
FindCUDA: Resolve a host compiler symlink only if it is Apple cc - clang
Otherwise using a "cc -> ccache" or similar symlink as the compiler
causes FindCUDA to select ccache as the host compiler. Update the logic
added by commit v3.1.0-rc1~354^2 (FindCUDA: Fix OSX Clang & no C
language enabled, 2014-06-12) to apply only in the specific case it is
needed.
This commit went into CMake 3.4.0. Compare git rev-list v3.4.0 | grep b405f01 with git rev-list v3.3.2 | grep b405f01.

Building and packaging LLVM clang 3.4 with cmake

I started studying cmake about 2 weeks ago and like it. Thus far, I have been successful in building and packaging (with the native system packaging format) libc++abi, libc++, llvm 3.4 all with cmake (libc++abi with my own cmake setup) for RHEL 6.x, Fedora 20+, and Ubuntu 12.04 LTS+.
I would like to create a C++ build environment that
Frees us from dependency on GNU GCC and libstdc++ completely (thus we don't want any LLVM RPM/DEB from these aforementioned distros or the LLVM Debian/Ubuntu nightly packages download site)
Enables us to explore fully C++11 and C++1y. In other words, we can try even the bleeding edge LLVM/clang anytime we want to while keeping all our build systems clean with package management systems.
Nevertheless, I hit a snag in attempting to build clang 3.4 with cmake, on a build host running Ubuntu 12.04 LTS 64bit, with a pure clang 3.3 built by me without any dependency on GNU libstdc++, together with libc++ 3.3 and libc++abi. The later two have no libstdc++ dependency either. I built both that way too.
I know of the Clang - Getting Started Web page really well and have used the instructions there successfully. But these are exactly what I don't want to use. They are incorrect too: the CMakeLists.txt of clang 3.4 clearly states the following:
1 # If we are not building as a part of LLVM, build Clang as an
2 # standalone project, using LLVM as an external library:
3 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
4 project(Clang)
5 cmake_minimum_required(VERSION 2.8)
6
7 set(CLANG_PATH_TO_LLVM_SOURCE "" CACHE PATH
8 "Path to LLVM source code. Not necessary if using an installed LLVM.")
9 set(CLANG_PATH_TO_LLVM_BUILD "" CACHE PATH
10 "Path to the directory where LLVM was built or installed.")
See line 1 and 2. But, I have not found any LLVM documentation regarding how to set the CLANG_PATH_TO_LLVM_BUILD. I tried the following:
cmake -DCLANG_PATH_TO_LLVM_BUILD="../../llvm-3.4/build" ..
and got the following errors:
$ clang3.4/_tars/clang-3.4/build$ cmake -DCLANG_PATH_TO_LLVM_BUILD="../../llvm-3.4/build" ..
-- The C compiler identification is Clang 3.3.0
-- The CXX compiler identification is Clang 3.3.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:39 (include):
include could not find load file:
AddLLVM
CMake Error at CMakeLists.txt:40 (include):
include could not find load file:
TableGen
-- Performing Test C_SUPPORTS_FLAG
-- Performing Test C_SUPPORTS_FLAG - Success
-- Performing Test CXX_SUPPORTS_FLAG
-- Performing Test CXX_SUPPORTS_FLAG - Success
-- Building with -fPIC
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.7.8")
-- Clang version: 3.4
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG - Success
CMake Error at utils/TableGen/CMakeLists.txt:3 (add_tablegen):
Unknown CMake command "add_tablegen".
-- Configuring incomplete, errors occurred!
But that's not right! The LLVM + compiler-rt has been installed on the build host with our own DEB. And,
$ llvm/clang3.4/_tars/clang-3.4/build$ ls /usr/share/llvm/cmake
AddLLVM.cmake ChooseMSVCCRT.cmake linux_issue.cmake LLVMConfigVersion.cmake pkg.cmake
AddLLVMDefinitions.cmake GetSVN.cmake LLVM-Config.cmake LLVMParseArguments.cmake TableGen.cmake
arch.cmake HandleLLVMOptions.cmake LLVMConfig.cmake LLVMProcessSources.cmake
So, all required cmake modules are there - right on the system!
I would appreciate a hint as to how to coerce clang 3.4 to build with cmake, with an already installed LLVM 3.4 + compiler-rt 3.4.
Update:
I decided to do the following:
$ llvm/clang3.4/_tars/clang-3.4/build$ cmake -DCLANG_PATH_TO_LLVM_BUILD="/usr" ..
-- Building with -fPIC
-- Clang version: 3.4
-- Found Subversion: /usr/bin/svn (found version "1.6.17")
-- Configuring done
-- Generating done
-- Build files have been written to: ../llvm/clang3.4/_tars/clang-3.4/build
../llvm/clang3.4/_tars/clang-3.4/build$ make -j 2
Scanning dependencies of target ClangDriverOptions
Scanning dependencies of target clang-tblgen
[ 0%] Building Options.inc...
[ 0%] ../llvm/clang3.4/_tars/clang-3.4/include/clang/Driver/Options.td:15:9: error: Could not find include file 'llvm/Option/OptParser.td'
include "llvm/Option/OptParser.td"
^
.../llvm/clang3.4/_tars/clang-3.4/include/clang/Driver/Options.td:15:9: Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangASTNodesEmitter.cpp.o
error: Unexpected input at top level
include "llvm/Option/OptParser.td"
^
make[2]: *** [include/clang/Driver/Options.inc.tmp] Error 1
make[1]: *** [include/clang/Driver/CMakeFiles/ClangDriverOptions.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentCommandInfoEmitter.cpp.o
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLTagsEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangSACheckersEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o
Linking CXX executable ../llvm/clang3.4/_tars/llvm-3.4/build/bin/clang-tblgen
[ 1%] Built target clang-tblgen
make: *** [all] Error 2
That's better. Looks like clang 3.4's default CMakeLists.txt is not even QA-ed x-( Yikes x-(
I decided to tough it out as any self-respecting engineer would do :) I simply vi-ed the following two files and add full path to the offending include, and then that's that.
Options.td
CC1AsOptions.td
Now I can build all desired LLVM main projects without libstdc++ dependency, all linked with libc++ and libc++abi. Hooray :)
So, I have confirmed that
Some instructions given in Getting Started: Building and Running Clang are misleading, e.g. 7.
All main LLVM projects (except compiler-rt AFAIK) can be built with cmake. There is no need to lump them together under the LLVM source tree for building. You definitely can build nearly all of them separately on Linux, unlike what these "official" documentation may lead you to believe :>
The LLVM team should really think through and minimize the apparent cyclic dependency among all projects. Bootstrapping LLVM/clang on various Linux distros (especially older ones such as RHEL 5.x) without GNU libstdc++ dependency is too tedious - speaking from my first hand experience. They can be done (I have done it :) but it's not for the faint of heart.
I think this project does what you're trying to do:
https://github.com/rsmmr/install-clang
I've used it on FC16+, but did run into bootstrapping issues on RHEL5.x.
I tried many ways and find that just copy llvm/include/llvm to this Driver dir and it will work.

Resources