Package: clang-4.0 Version: 1:4.0.1~+rc1-1 Followup-For: Bug #862328 Hi,
After some digging, here is what I've come up with: 1- Dependencies I think that ClangConfig.cmake (and the symlinks,... described above) and its two sibling files should be provided by libclang-x.y-dev not by clang-x.y. Most of the targets provided by this CMake file are installed with libclang-x.y-dev so that makes much more sense (and LLVMConfig.cmake is provided by llvm-x.y-dev) However, some target artifacts are provided by other packages as well: - clang (executable) by clang-x.y - clang-format (executable) by clang-format-x.y If these artifacts are not installed during configure, CMake will error- complain about that. I'm not really sure what's the best approach here but, as is, the package providing ClangConfig.cmake must depends on clang-x.y and clang-format-x.y in order to work. 2- Fixing find_package(Clang) Install ClangConfig.cmake and siblings in /usr/lib/llvm-x.y/lib/cmake/clang (instead of /usr/share/llvm-x.y/cmake) Add a symlink /usr/share/clang-x.y/cmake -> /usr/lib/llvm-x.y/lib/cmake/clang This matches what's done for LLVMConfig.cmake This way find_package(Clang) can automatically find the config files. To be consistent with LLVMConfig.cmake the symlink can instead be put in /usr/lib/clang-x.y/cmake 3- Fixing CLANG_INSTALL_PREFIX Apply the attached patch (fix-cmake-clang-confix.patch based on the 5.0 snapshot) to ClangConfig.cmake in the clang sources to fix the prefix location With that ClangConfig.cmake and siblings can correctly compute the path of the target artifacts 4- Fixing clang executable name The targets files expect the clang executable to be named and located in /usr/lib/llvm-x.y/bin/clang-x.y but the rules file (line 374) strips its version suffixes. I'm not sure why this was done but I guess we can either: - not rename the executable (and fix /usr/bin/clang-x.y symlink and maybe others) - fix the ClangTargets-*.cmake file post generation to strip the version suffix With these changes, one should be able to use the provided ClangConfig.cmake and its targets. I'm not really able to test that much more, nor provide a full patch for the packaging repo but I can test any .deb that would have such fixes (including the 5.0 snapshots). Regards, Sylvain -- System Information: Debian Release: 9.0 APT prefers testing APT policy: (990, 'testing'), (800, 'stable-updates'), (800, 'stable'), (700, 'unstable'), (90, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 4.9.0-2-amd64 (SMP w/8 CPU cores) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages clang-4.0 depends on: ii binutils 2.28-4 ii libc6 2.24-10 ii libc6-dev 2.24-10 ii libclang-common-4.0-dev 1:4.0.1~+rc1-1 ii libclang1-4.0 1:4.0.1~+rc1-1 ii libgcc-6-dev 6.3.0-16 ii libgcc1 1:6.3.0-16 ii libjsoncpp1 1.7.4-3 ii libllvm4.0 1:4.0.1~+rc1-1 ii libobjc-6-dev 6.3.0-16 ii libstdc++-6-dev 6.3.0-16 ii libstdc++6 6.3.0-16 Versions of packages clang-4.0 recommends: ii llvm-4.0-dev 1:4.0.1~+rc1-1 ii python 2.7.13-2 Versions of packages clang-4.0 suggests: pn clang-4.0-doc <none> pn gnustep <none> pn gnustep-devel <none> -- no debconf information
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index be6d1d7257..b97afbf7c0 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -28,16 +28,7 @@ set(CLANG_CONFIG_LLVM_CMAKE_DIR) set(CLANG_CONFIG_EXPORTS_FILE) # Generate ClangConfig.cmake for the install tree. -set(CLANG_CONFIG_CODE " -# Compute the installation prefix from this LLVMConfig.cmake file location. -get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") -# Construct the proper number of get_filename_component(... PATH) -# calls to compute the installation prefix. -string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}") -foreach(p ${_count}) - set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE} -get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)") -endforeach(p) +set(CLANG_CONFIG_CODE "set(CLANG_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}") set(CLANG_CONFIG_LLVM_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")