I started learning cmake about 2 weeks ago and sort of. So far I have managed to create and package (with the packaging format in my native system) libc++abi , libc++ , llvm 3.4 all with cmake ( libc++abi with my cmake setting) for RHEL 6.x, Fedora 20+ and Ubuntu 12.04 LTS +.
I would like to create a C ++ build environment that
- Relieves us of our dependency on GNU GCC and
libstdc++ completely (therefore, we donβt want LLVM RPM / DEB from these aforementioned distributions or LLVM Debian / Ubuntu nightly packages download site) - Allows us to fully learn C ++ 11 and C ++ 1y . In other words, we can at any time try to solve the problem of bloodletting LLVM / clang, while keeping all of our build systems clean with package management systems.
However, I fell into the trap of trying to build clang 3.4 with cmake , on the build host running Ubuntu 12.04 LTS 64bit, with pure clang 3.3 that I created without any dependency on GNU libstdc++ , along with libc++ 3.3 and libc++abi . The later two have no libstdc++ dependency. I also built this path.
I know the Clang - Getting Started webpage well and have used it successfully. But this is exactly what I do not want to use. They are also incorrect: CMakeLists.txt of clang 3.4 clearly states the following:
1
See lines 1 and 2. But I did not find any LLVM documentation regarding how to set 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 this is not so! LLVM + compiler-rt was installed on the build host using 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 the necessary cmake modules are - right in the system!
I would appreciate a hint on how to get clang 3.4 to build using cmake with LLVM 3.4 + compiler-rt 3.4 already installed.
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
This is better. Looks like clang 3.4 default CMakeLists.txt is not even QA-ed x- (Yikes x - (