CMake third-party library installation

折月煮酒 提交于 2020-06-12 07:27:10

问题


I'm new in programming. And for my study project I need to install a third-party library for using with CMake (GitHub project).

I use Arch OS on my PC. Usually I build all non-repository packages in: ~/aur. CMake version is 3.17.

Then I try to build a library according to the instructions:

...
cmake --config Debug "-DCMAKE_BUILD_TYPE=Debug" ..

it makes me an error:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PNG_INCLUDE_DIR
   used as include directory in directory /home/wizki/aur/P0267_RefImpl/P0267_RefImpl/Tests

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

If I ignore this error and build this library using:

cmake --build .

The building is succesful, but durin my project building I have an error:

CMake Error at CMakeLists.txt:15 (find_package):
  By not providing "Findio2d.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "io2d", but
  CMake did not find one.

Could not find a package configuration file provided by "io2d" with any of
  the following names:

    io2dConfig.cmake
    io2d-config.cmake

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

-- Configuring incomplete, errors occurred!

After a web search I've tried this solution: Daniweb. libpng and zlib packages are installed; FindPNG.cmake exists in /usr/share/cmake-3.17/Modules/. But my $CMAKE_INCLUDE_PATH and $CMAKE_LIBRARY_PATH are empty:

[wizki@evix Debug]$ echo $CMAKE_INCLUDE_PATH

[wizki@evix Debug]$ echo $CMAKE_LIBRARY_PATH

I've tried to search in FindPNG.cmake for paths, but no result. From CMake wiki I suppose that one of the library path is /usr/lib. I've tried to build a library inside, but I have a same issue.

What can I try next?


回答1:


Assuming you are studying for the C++ Nanodegree Project on Udacity. I was stuck on the same issue and I found out that during the installation of IO2D after you execute the following command in the terminal

cmake --build . 

execute the following command

sudo make install

this will copy the necessary files at places where Cmake can find them.

Therefore, the complete process looks like this

git clone --recurse-submodules https://github.com/cpp-io2d/P0267_RefImpl
cd P0267_RefImpl
mkdir Debug
cd Debug
cmake --config Debug "-DCMAKE_BUILD_TYPE=Debug" ..
cmake --build .
sudo make install

I found the solution here - https://github.com/udacity/CppND-Route-Planning-Project/issues/1#issuecomment-569472612

PS: As you are new to programming I would like to share a tip that many times other people also have the same issue and it is easier to find a solution in the "Issues" tab of a GitHub repo.



来源:https://stackoverflow.com/questions/61025954/cmake-third-party-library-installation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!