ubuntu 上的 1.8.20 的 Doxygen Build 因 Clang 而失败

Doxygen Build failing for 1.8.20 on ubuntu with Clang

这些是我安装 doxygen 1.8.20 所遵循的步骤:

apt-get install graphviz
apt-get install bison
apt-get install flex
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
tar -xvzf libiconv-1.16.tar.gz
cd libiconv-1.16
./configure --prefix=/usr/local/libiconv
make
make install
wget http://doxygen.nl/files/doxygen-1.8.20.src.tar.gz
gunzip doxygen-1.8.20.src.tar.gz
tar -xf doxygen-1.8.20.src.tar
cd doxygen-1.8.20
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -Duse_libclang=ON ..

此时我得到以下输出:

CMake Error at CMakeLists.txt:51 (find_package):
  Could not find a package configuration file provided by "LLVM" with any of
  the following names:

    LLVMConfig.cmake
    llvm-config.cmake

  Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
  "LLVM_DIR" to a directory containing one of the above files.  If "LLVM"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/doxygen-1.8.20/build/CMakeFiles/CMakeOutput.log".

现在我得到了 LLVM 包:

apt-get install llvm
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -Duse_libclang=ON ..

此时我得到以下输出:

CMake Error at CMakeLists.txt:52 (find_package):
  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!

获取 clang 包:

apt-get install clang

得到同样的错误:

CMake Error at CMakeLists.txt:52 (find_package):
  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 "/home/doxygen-1.8.20/build/CMakeFiles/CMakeOutput.log".

现在怎么办?

发现这是随 apt-get install llvmapt-get install clang 安装的 llvm 和 clang 的问题。这将安装两者的版本 6。

执行以下命令而不是这些命令:

apt install llvm-10 clang-10 libclang-10-dev

然后运行

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -Duse_libclang=ON ..

将产生成功的输出:

-- Found PythonInterp: /usr/bin/python (found version "2.7.17")
-- Found FLEX: /usr/bin/flex (found version "2.6.4")
-- Found BISON: /usr/bin/bison (found version "3.0.4")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Looking for iconv_open
-- Looking for iconv_open - found
-- Performing Test ICONV_COMPILES
-- Performing Test ICONV_COMPILES - Success
-- Found Iconv: In glibc
-- One (and only one) of the ICONV_ACCEPTS_... tests must pass
-- Performing Test ICONV_ACCEPTS_NONCONST_INPUT
-- Performing Test ICONV_ACCEPTS_NONCONST_INPUT - Success
-- Performing Test ICONV_ACCEPTS_CONST_INPUT
-- Performing Test ICONV_ACCEPTS_CONST_INPUT - Failed
-- The javacc executable not found, using existing files
-- Configuring done
-- Generating done
-- Build files have been written to: /home/libiconv-1.16/doxygen-1.8.20/build

然后继续 makemake install