CMake cannot find packages within Qt6 installation - c++

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.

Related

get_property could not find TARGET, from ExternalProject

I'm running into a CMake issue that I am a little stumped by. It involves a CMake project that builds dependencies for an application I develop at work. I now have to add a new dependency, libnest2d, which itself also has three dependencies, of which some are also new.
To get libnest2d to build I have this ExternalProject_Add call:
ExternalProject_Add(libnest2d
GIT_REPOSITORY https://github.com/tamasmeszaros/libnest2d.git
GIT_TAG da4782500da4eb8cb6e38e5e3f10164ec5a59778
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
DEPENDS BoostHeaders nlopt Clipper
)
This project depends on the Boost Headers, NLopt and Clipper. Those Boost headers and Clipper are fine, but it somehow complains about NLopt with the following errors:
CMake Error at /usr/share/cmake-3.16/Modules/ExternalProject.cmake:2962 (get_property):
get_property could not find TARGET nlopt. Perhaps it has not yet been
created.
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:3239 (_ep_add_configure_command)
projects/libnest2d.cmake:5 (ExternalProject_Add)
CMakeLists.txt:61 (include)
CMake Error at /usr/share/cmake-3.16/Modules/ExternalProject.cmake:2964 (get_property):
get_property could not find TARGET nlopt. Perhaps it has not yet been
created.
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:3239 (_ep_add_configure_command)
projects/libnest2d.cmake:5 (ExternalProject_Add)
CMakeLists.txt:61 (include)
CMake Error at /usr/share/cmake-3.16/Modules/ExternalProject.cmake:1783 (get_property):
get_property could not find TARGET nlopt. Perhaps it has not yet been
created.
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:2064 (ExternalProject_Get_Property)
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:2966 (_ep_get_step_stampfile)
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:3239 (_ep_add_configure_command)
projects/libnest2d.cmake:5 (ExternalProject_Add)
CMakeLists.txt:61 (include)
CMake Error at /usr/share/cmake-3.16/Modules/ExternalProject.cmake:1785 (message):
External project "nlopt" has no stamp_dir
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:2064 (ExternalProject_Get_Property)
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:2966 (_ep_get_step_stampfile)
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:3239 (_ep_add_configure_command)
projects/libnest2d.cmake:5 (ExternalProject_Add)
CMakeLists.txt:61 (include)
So it states that the nlopt target is not defined. However that target is defined using another ExternalProject_Add call, the same as the other two dependencies:
ExternalProject_Add(nlopt
GIT_REPOSITORY https://github.com/stevengj/nlopt.git
GIT_TAG v2.6.2
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)
ExternalProject_Add(BoostHeaders
URL http://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.bz2
URL_HASH SHA1=694ae3f4f899d1a80eb7a3b31b33be73c423c1ae
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/BoostHeaders-prefix/src/BoostHeaders/boost" "${CMAKE_INSTALL_PREFIX}/include/boost"
)
ExternalProject_Add(Clipper
URL https://sourceforge.net/projects/polyclipping/files/clipper_ver6.4.2.zip
URL_HASH SHA1=b05c1f454c22576f867fc633b11337d053e9ea33
SOURCE_SUBDIR cpp
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)
Without the NLopt dependency, libnest2d builds fine (since I still have the dependency installed on my local system), but there is no guarantee that NLopt is built and installed before starting on libnest2d, and indeed this goes wrong if I execute this build in a VM with multiple threads.
If I temporarily remove the nlopt dependency and call cmake .. && make help then I see that nlopt is one of the available targets. I can also call make nlopt and it starts building NLopt as expected.
You can view my entire source code here: https://github.com/Ultimaker/cura-build-environment/tree/CURA-7259_pynest2d . As of this writing I'm on commit 39298d203d115b60d7093f0a801be1bad0ba7842.
Other problems I've found have not been the same and don't provide a solution for me:
This related question has the same error but it seems to be caused by a tool that OP was using, which I'm not using.
This question and this bug report were a problem with a target that was disabled by a build option, which is not the case for me. The target clearly exists and I made no option to disable it.
There was an old bug that caused this but it was fixed in CMake 2.8. I'm using CMake 3.16.3.
So to summarize, how can I cause the libnest2d external project to depend on NLopt? Why are two dependencies accepted, but one isn't?

Mapbox GL Native doesn't build ubuntu18

I'm trying to build Mapbox GL Native using cmake .. so I cloned the repository from GitHub:
$ git clone https://github.com/mapbox/mapbox-gl-native.git
$ cd mapbox-gl-native
$ mkdir build && cd build
$ cmake ./
then it returns this with the erros:
CMake Error at node_modules/#mapbox/cmake-node-module/module.cmake:126 (add_library):
Target "mbgl-node.abi-64" links to target "OpenGL::OpenGL" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
Call Stack (most recent call first):
platform/node/CMakeLists.txt:9 (add_node_module)
CMake Error at node_modules/#mapbox/cmake-node-module/module.cmake:126 (add_library):
Target "mbgl-node.abi-64" links to target "OpenGL::OpenGL" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
Call Stack (most recent call first):
platform/node/CMakeLists.txt:9 (add_node_module)
CMake Error at node_modules/#mapbox/cmake-node-module/module.cmake:126 (add_library):
Target "mbgl-node.abi-57" links to target "OpenGL::OpenGL" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
Call Stack (most recent call first):
platform/node/CMakeLists.txt:9 (add_node_module)
I need heeeelp, I've been here trying to fix this but I don't know what could be the problem..
Thanks guys!
If your OpenGL library path installation is defined in your ENV path,
you want to set up your CMAKE_PREFIX_PATH to your OpenGL installation path (you could set it in your top level CMakeList.txt).

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/

Failed to find "glu32" in "" with CMAKE_CXX_LIBRARY_ARCHITECTURE ""

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.

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.