Failed to find "glu32" in "" with CMAKE_CXX_LIBRARY_ARCHITECTURE "" - c++

I'm trying to compile cryptonotecoinwallet repo using CMake with VS2010 compiler (according to the comments I got for this question)
I tried to add the below line to the CMake file and the cache file, but no luck.
set (CMAKE_PREFIX_PATH "C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64")
I tried to compile it using the command line, but got the same error.
D:\My Documents\Fiverr\C++ and Qt\FitsoCoin\cryptonotewallet>cmake.exe -DBOOST_ROOT=C:\\boost_1_66_0 -DBOOST_LIBRARYDIR=C:\\boost_1_66_0\\lib32-msvc-1
0.0:C:\\boost_1_66_0\\libs -G "Visual Studio 10 2010" .
CMake Error at C:/Qt/Qt5.2.0/5.2.0/msvc2010_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:16 (message):
Failed to find "glu32" in "" with CMAKE_CXX_LIBRARY_ARCHITECTURE "".
Call Stack (most recent call first):
C:/Qt/Qt5.2.0/5.2.0/msvc2010_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:52 (_qt5gui_find_extra_libs)
C:/Qt/Qt5.2.0/5.2.0/msvc2010_opengl/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:152 (include)
CMakeLists.txt:19 (find_package)
Any ideas how to fix this?
Thanks.

If you want to point CMake (and Find* scripts) to directory with a libraries, set CMAKE_LIBRARY_PATH variable:
set(CMAKE_LIBRARY_PATH "C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib/x64")
Variable CMAKE_PREFIX_PATH, which you are trying to set, is expected to point to installation prefix. This prefix is used when search a library, but only with subdirectories like lib/ appended to it.

Related

CMake cannot find packages within Qt6 installation

I am in the process of trying to build a project through CMake and I set environmental variable Qt6_DIR to the directory containing Qt6Config.cmake. However the build doesn't seem to be able to find any of the other dependencies it needs within the Qt6 installation & I'm not sure what needs to be done next. I see references to other possible environmental variables like "Qt6CoreTools_DIR" and I'm wondering if I really need to set each of these independently or if there's a toolchain containing this information that needs to be properly linked to.
-- GUI Frontend: Qt6
CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
By not providing "FindQt6CoreTools.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt6CoreTools", but CMake did not find one.
Could not find a package configuration file provided by "Qt6CoreTools"
(requested version 6.2.3) with any of the following names:
Qt6CoreToolsConfig.cmake
qt6coretools-config.cmake
Add the installation prefix of "Qt6CoreTools" to CMAKE_PREFIX_PATH or set
"Qt6CoreTools_DIR" to a directory containing one of the above files. If
"Qt6CoreTools" provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsDependencies.cmake:9 (find_dependency)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake:34 (include)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:71 (find_package)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
src/CMakeLists.txt:22 (find_package)
CMake Warning at C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:71 (find_package):
Found package configuration file:
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake
but it set Qt6WidgetsTools_FOUND to FALSE so package "Qt6WidgetsTools" is
considered to be NOT FOUND. Reason given by package:
Qt6WidgetsTools could not be found because dependency Qt6CoreTools could
not be found.
Call Stack (most recent call first):
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
src/CMakeLists.txt:22 (find_package)
CMake Warning at C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package):
Found package configuration file:
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake
but it set Qt6Widgets_FOUND to FALSE so package "Qt6Widgets" is considered
to be NOT FOUND. Reason given by package:
Target "Qt6::Widgets" was not found.
Call Stack (most recent call first):
src/CMakeLists.txt:22 (find_package)
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
Found package configuration file:
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
NOT FOUND. Reason given by package:
Target "Qt6::Core" was not found.
Call Stack (most recent call first):
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLDependencies.cmake:91 (_qt_internal_find_dependencies)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake:40 (include)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
src/CMakeLists.txt:22 (find_package)
CMake Warning at C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package):
Found package configuration file:
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake
but it set Qt6OpenGL_FOUND to FALSE so package "Qt6OpenGL" is considered to
be NOT FOUND. Reason given by package:
Qt6OpenGL could not be found because dependency Qt6Core could not be found.
Call Stack (most recent call first):
src/CMakeLists.txt:22 (find_package)
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
Found package configuration file:
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
NOT FOUND. Reason given by package:
Target "Qt6::Core" was not found.
Call Stack (most recent call first):
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLDependencies.cmake:91 (_qt_internal_find_dependencies)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake:40 (include)
C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsDependencies.cmake:91 (_qt_internal_find_dependencies)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsConfig.cmake:40 (include)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
src/CMakeLists.txt:22 (find_package)
CMake Warning at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
Found package configuration file:
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake
but it set Qt6OpenGL_FOUND to FALSE so package "Qt6OpenGL" is considered to
be NOT FOUND. Reason given by package:
Qt6OpenGL could not be found because dependency Qt6Core could not be found.
Call Stack (most recent call first):
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsDependencies.cmake:91 (_qt_internal_find_dependencies)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsConfig.cmake:40 (include)
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package)
src/CMakeLists.txt:22 (find_package)
CMake Warning at C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package):
Found package configuration file:
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsConfig.cmake
but it set Qt6OpenGLWidgets_FOUND to FALSE so package "Qt6OpenGLWidgets" is
considered to be NOT FOUND. Reason given by package:
Qt6OpenGLWidgets could not be found because dependency Qt6OpenGL could not
be found.
Call Stack (most recent call first):
src/CMakeLists.txt:22 (find_package)
CMake Error at src/CMakeLists.txt:22 (find_package):
Found package configuration file:
C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6/Qt6Config.cmake
but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
FOUND. Reason given by package:
Failed to find Qt component "Widgets".
Expected Config file at
"C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake" exists
Failed to find Qt component "OpenGL".
Expected Config file at
"C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGL/Qt6OpenGLConfig.cmake" exists
Failed to find Qt component "OpenGLWidgets".
Expected Config file at
"C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6OpenGLWidgets/Qt6OpenGLWidgetsConfig.cmake"
exists
According to QTBUG-97615 the proper support of configuring the build with single Qt6_DIR isn't supported (yet?), and the 'official' way to configure your application build is to use CMAKE_PREFIX_PATH (as suggested in other answers).
However if your tools don't support such appoach easily (like VisualStudio/VSCode), there is a workaround for such case (I've discovered it while digging the messy cmake-scripts of Qt6).
You can use QT_ADDITIONAL_PACKAGES_PREFIX_PATH to specify the Qt root (along with Qt6_DIR to hook it initially).
And the command line will look as follows (just to illustrate the approach):
cmake -DQt6_DIR:PATH=C:/Qt6/6.2.3/mingw_64/lib/cmake/Qt6 -DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=C:/Qt6/6.2.3/mingw_64 ..
Both these variables are easily configurable through UI in VisualStudio/VSCode.
Happy building! :)
Add this to your root cmake.
list(APPEND CMAKE_PREFIX_PATH "~/Qt/6.3.0/gcc_64")
Change the path as needed.
Alternatively You can set it as env var.
export PATH="~/Qt/6.3.0/gcc_64/:$PATH"
Since I see some people in the comments asking specifically for VS(-Code) settings/configuration, the following worked for me on Windows:
I set CMAKE_PREFIX_PATH to C:/Qt/6.4.2/msvc2019_64 (substitute C:/Qt/6.4.2 with your Qt installation path and version).
Note: with Qt 5, you could use [..]/msvc2019_64/lib/cmake, this doesn't work for Qt 6 anymore. If you need multiple paths in CMAKE_PREFIX_PATH, join them with a semicolon (;).
An example .vscode/settings.json could look like this:
{
"cmake.configureSettings": {
"CMAKE_PREFIX_PATH": "C:/Qt/6.4.2/msvc2019_64"
}
}
From Qt Documentation:
There are different ways you can tell CMake about Qt, but the most common and recommended approach is to set the CMake cache variable CMAKE_PREFIX_PATH to include the Qt 6 installation prefix.
So you shoud add C:/Qt6/6.2.3/mingw_64/ to the CMAKE_PREFIX_PATH semicolon-separated list.
You could check whether CMAKE_PREFIX_PATH is set or modified by one of the cmake scripts supplied by the project.
I had the same problem with a different project on Linux OS and what seemed to work in the end was setting a project specific variable named QT_PREFIX to /opt/Qt/6.2.4/gcc_64/.
By looking at the project's file CMakeLists_Dependencies.cmake I noticed that CMAKE_PREFIX_PATH was being set by the script like this:
set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake").
My guess is, that this statement shadowed my definition of CMAKE_PREFIX_PATH from the command line.
I checked it by inserting the statement message(CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}") right below set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake").
When not setting QT_PREFIX, the output was CMAKE_PREFIX_PATH="/lib/cmake", no matter whether I included -DCMAKE_PREFIX_PATH=… on the command line or not. (/lib/cmake/ was not a valid path in my case.)
If QT_DIR was set as described above, the output was CMAKE_PREFIX_PATH="/opt/Qt/6.2.4/gcc_64//lib/cmake", which enabled cmake to find the directory, even despite the double slash.

Caffe2: make ops fails when installing densepose

I am trying to install DensePose but run into problems when executing make ops.
First I get error Caffe2Config.cmake not found, but after following the instructions here Caffe2 build from source the Caffe2Config.cmake ends up under the build directory.
Adding the path to the build folder gives then the following error:
CMake Error at /home/erikbylow/Code/LocalLibs/pytorch/build/Caffe2Config.cmake:14 (include):
include could not find load file:
/home/erikbylow/Code/LocalLibs/pytorch/build/public/utils.cmake
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
CMake Error at /home/erikbylow/Code/LocalLibs/pytorch/build/Caffe2Config.cmake:17 (include):
include could not find load file:
/home/erikbylow/Code/LocalLibs/pytorch/build/public/threads.cmake
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
CMake Error at /home/erikbylow/Code/LocalLibs/pytorch/build/Caffe2Config.cmake:88 (include):
include could not find load file:
/home/erikbylow/Code/LocalLibs/pytorch/build/public/cuda.cmake
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
The paths are clearly wrong since the requested cmake-files are under pytorch/cmake/public instead of pytorch/build/public.
How can one resolve that? I have just followed the instructions and the tests one makes along the way works. It seems to be the installation of Caffe2 that causes the problem?
In my case, setting the environment variable Caffe2_DIR to the directory of the missing files solved the problem.
As you mentioned, these files are in the pytorch/cmake/public directory instead of pytorch/build/public. To define the path of Caffe2 manually, open the CMakeLists.txt in the densepose folder, add one line in the beginning:
set(Caffe2_DIR "/home/erikbylow/Code/LocalLibs/pytorch/cmake/")
Run make ops again and the issue should be solved. If not, also try
set(Caffe2_DIR "/home/erikbylow/Code/LocalLibs/pytorch/torch/share/cmake/Caffe2/")
Also, after DensePose is successfully installed, remember to append its path to PYTHONPATH:
export PYTHONPATH=$PYTHONPATH:/path/to/densepose/

Private Headers issue compiling QtWebKit 5.212 against Qt 5.10.1

On Windows 10, Visual Studio 2015, I'm building QtWebKit (5.212) against Qt 5.10.1, and I'm running into an error during the configuration part of the build.
Here is the command line I use:
perl Tools\Scripts\build-webkit --qt --release --only-webkit --no-ninja --cmakeargs="-Thost=x64 -DCMAKE_GENERATOR_PLATFORM=x64" -G \"Visual Studio 14 2015 Win64\" --prefix=E:\Qt-5.10.1\QtWebKitBin -v
Here is the error:
-- Performing Test Qt5Gui_PRIVATE_HEADER_FOUND
-- Performing Test Qt5Gui_PRIVATE_HEADER_FOUND - Failed
CMake Error at Source/cmake/OptionsQt.cmake:75 (message):
Header private/qhexstring_p.h is not found. Please make sure that:
1. Private headers of Qt5Gui are installed
2. Qt5Gui_PRIVATE_INCLUDE_DIRS is correctly defined in Qt5GuiConfig.cmake
Call Stack (most recent call first):
Source/cmake/OptionsQt.cmake:612 (CHECK_QT5_PRIVATE_INCLUDE_DIRS)
Source/cmake/WebKitCommon.cmake:50 (include)
CMakeLists.txt:139 (include)
-- Configuring incomplete, errors occurred!
The private header that it's using to do the test does exist in the Qt5 include directory, as one would expect, in this location:
E:\Qt-5.10.1\QtBin\include\QtGui\5.10.1\QtGui\private\qhexstring_p.h
The Qt5GuiConfig.cmake file exists only in the E:\Qt-5.10.1\QtBin\lib\cmake\Qt5Gui directory of the Qt installation (not in the QtWebKit source installation). I don't know if it's making use of this in any way.
What do I need to do to make the build find this directory as desired? Adding 'include\QtGui\5.10.1\QtGui\' to the INCLUDE env var doesn't work, but I don't believe that's the correct solution anyway.
Here are the parts of my environment related to the Qt directories:
INCLUDE = ...;E:\Qt-5.10.1\QtBin\include;E:\Qt-5.10.1\qt-everywhere-src-5.10.1\include
LIB = ...;E:\Qt-5.10.1\QtBin\lib;E:\Qt-5.10.1\qt-everywhere-src-5.10.1\lib
PATH = E:\Qt-5.10.1\qt-everywhere-src-5.10.1\qtbase\bin;E:\Qt-5.10.1\qt-everywhere-src-5.10.1\gnuwin32\bin;E:\Qt-5.10.1\QtBin\bin;...
QtBin is the directory with my compiled Qt 5.10.1.
qt-everywhere-src-5.10.1 is the Qt 5.10.1 source package
Thanks in advance for any help. I couldn't find any answers searching Google or StackOverflow.
According to the wiki, you should try to define CMAKE_PREFIX_PATH to point to your Qt installation
For example :
perl Tools\Scripts\build-webkit --qt --release --only-webkit --no-ninja --cmakeargs="-Thost=x64 -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_PREFIX_PATH=c:\Qt\Qt5.6.0\5.6\msvc2015" -G \"Visual Studio 14 2015 Win64\" --prefix=E:\Qt-5.10.1\QtWebKitBin -v
Build on Windows using build-webkit fails because it was unable to find the location for this header file qhexstring_p.h. How to fix this error and although is not a standard way but it works.
Located the file qhexstring_p.h in your prefix directory, or your
preferred Qt Installation SDK
Go to this file Source\cmake\OptionsQt.cmake and change this
From this CHECK_QT5_PRIVATE_INCLUDE_DIRS(Gui private/qhexstring_p.h)
to this below
CHECK_QT5_PRIVATE_INCLUDE_DIRS(Gui
C:/SDK/qt5-5.7.0-vs2015/qt5-x86-static-release/include/QtGui/5.7.0/QtGui/private/qhexstring_p.h)
The path here must match the path to your Qt installation and to the exact location the missing file is located. This ensures the test to look for the private director for the Qt installation is successful.
Then locate the file Qt5GuiConfig.cmake in your Qt installation directory and set the variable Qt5Gui_PRIVATE_INCLUDE_DIRS to the location were you private headers are found with this below.
set(Qt5Gui_PRIVATE_INCLUDE_DIRS "${_qt5Gui_install_prefix}/include/QtGui/${Qt5Gui_VERSION_STRING}/QtGui" "${_qt5Gui_install_prefix}/include/QtCore/${Qt5Gui_VERSION_STRING}/QtCore")
And note this version QtWebKit (5.212) of is known to have several
bugs, so its best you go for those stable ones.
The Save and run
perl Tools\Scripts\build-webkit --qt --release --only-webkit --no-ninja --cmakeargs="-Thost=x64 -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_PREFIX_PATH=c:\Qt\Qt5.6.0\5.6\msvc2015" -G \"Visual Studio 14 2015 Win64\" --prefix=E:\Qt-5.10.1\QtWebKitBin -v
As you wanted, that should be able to run as expected.

Could NOT find HDF5 during compilation (server)

I was able to compile perfectly a code using HDF5 in my computer but now I would like to compile it in a server.
In the server, HDF5 is well installed in the following path:
/usr/local/HDF_Group/HDF5/1.8.17/lib/
But I got this error during the compilation using CMake:
CMake Error at
/usr/local/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:148
(message): Could NOT find HDF5 (missing: HDF5_LIBRARIES
HDF5_INCLUDE_DIRS HDF5_HL_LIBRARIES) Call Stack (most recent call
first):
/usr/local/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:388
(_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.6/Modules/FindHDF5.cmake:690
(find_package_handle_standard_args) CMakeLists.txt:4 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
The beginning of my CMakeList.txt
FIND_PACKAGE(HDF5 REQUIRED)
find_package (HDF5 NAMES hdf5 COMPONENTS C static)
INCLUDE_DIRECTORIES
(${HDF5_INCLUDE_DIR}) message(STATUS ${HDF5_INCLUDE_DIR})
set (LINK_LIBS ${LINK_LIBS} ${HDF5_C_STATIC_LIBRARY})
include_directories(/usr/local/HDF_Group/)
link_directories(/usr/local/HDF_Group/HDF5/1.8.17/lib/)
link_directories(/usr/local/lib)
Could you please help me ?As I'm not well familiar with CMake, Maybe I did not link it properly...
Thank in advance,
EDIT: SOLVED
I solved my issue by doing this:
export HDF5_DIR=/usr/local/HDF_Group/HDF5/1.8.17/share/cmake
And I added it into my /home/user/.bashrc so that I don't have to do this command line each time.

Adding LLVM to my Cmake Project: Why are there hardcoded paths in LLVM's Cmake file?

I'm using LLVM/Clang in my C++ project. I can build and run everything fine with a Makefile.
I'm now trying to move to Cmake and I can't get things to work. Let me explain what I've done.
I'm following this tutorial:
http://llvm.org/docs/CMake.html#embedding
A relevant snippet from that webpage is:
From LLVM 3.5 onwards both the CMake and autoconf/Makefile build
systems export LLVM libraries as importable CMake targets.
Great! I'll go download LLVM 3.5 and I should be good to go. I went to the download page:
http://llvm.org/releases/download.html
and downloaded the pre-built binaries for Clang for Ubuntu 14.04 Linux.
Then, I added the following to my CMakeLists.txt file:
find_path (LLVM_DIR LLVM-Config.cmake
/home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake
)
message(STATUS "LLVM_DIR = ${LLVM_DIR}")
find_package(LLVM REQUIRED CONFIG)
(This is the same as the tutorial, except I set LLVM_DIR since it is currently in a non-standard location.)
When I run cmake, I get the following error:
[dev#beauty:/path/to/project/build (develop)] $ cmake ..
-- LLVM_DIR = /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake
CMake Error at /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake/LLVMConfig.cmake:50 (include):
include could not find load file:
/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake/LLVMExports.cmake
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)
CMake Error at /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake/LLVMConfig.cmake:53 (include):
include could not find load file:
/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake/LLVM-Config.cmake
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)
So Cmake seems to be finding LLVM's Cmake file, but Cmake is complaining about some path starting with /home/ben/.
Indeed, it appears that LLVM's LLVMConfig.cmake file has some absolute paths in it that are not relevant for my machine. For example:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu ] $ head ./share/llvm/cmake/LLVMConfig.cmake
# This file provides information and services to the final user.
set(LLVM_INSTALL_PREFIX "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install")
set(LLVM_VERSION_MAJOR 3)
set(LLVM_VERSION_MINOR 5)
set(LLVM_VERSION_PATCH 0)
set(LLVM_PACKAGE_VERSION 3.5.0)
set(LLVM_COMMON_DEPENDS )
Who's ben and what's he doing in this file? He shows up in a few more places:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu ] $ grep ben ./share/llvm/cmake/LLVMConfig.cmake
set(LLVM_INSTALL_PREFIX "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install")
set(LLVM_INCLUDE_DIRS "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/include")
set(LLVM_LIBRARY_DIRS "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/lib")
set(LLVM_CMAKE_DIR "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake")
set(LLVM_TOOLS_BINARY_DIR "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/bin")
Needless to say, those paths do not exist on my machine. I'm confused as to why these files have these paths in them? Am I supposed to run a tool or something to change these paths for my machine? Or do I need to change them all manually?
EDIT: Out of curiosity, I manually changed all those paths to point to paths on my machine:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake ] $ sed -i -e's/.home.ben.development.llvm.3.5.final.Phase3.Release.llvmCore-3.5.0-final.install/\/home\/dev\/Downloads\/clang+llvm-3.5.0-x86_64-linux-gnu/g' *
After that, Cmake no longer complained and my build proceeded.
I'd still like to know why I needed to do that.
Sounds like a LLVM bug. Feel free to enter it: http://llvm.org/bugs
We just have to build with 'Ninja' instead of 'Unix Makefiles' and that's all