在CMake (c++, ImageMagick)中设置路径
Set path in CMake (C++, ImageMagick)
我正试图添加一些东西到使用CMake开发的更大的c++项目。在我要添加的部分,我想使用magick++。
如果我只编译我的小示例程序
#include <Magick++.h>
int main()
{
Magick::Image image;
return 0;
}
g++ -o example example.cxx
它失败了,因为它没有找到" magick++ .h"。
如果我使用
g++ -I /usr/include/ImageMagick -o example example.cxx
我得到"未定义的引用"错误。
如果我按照http://www.imagemagick.org/script/magick++.php上的说明使用
编译g++ `Magick++-config --cxxflags --cppflags` -o example example.cxx `Magick++-config --ldflags --libs`
。
:我如何将其纳入使用CMake的更大项目?我如何改变CMakeLists.txt?
有FindImageMagick。cmake模块在基本的cmake发行版,所以你是幸运的。你应该在CMakeLists.txt:
中添加如下内容find_package(ImageMagick COMPONENTS Magick++)
之后,可以使用以下变量:
ImageMagick_FOUND - TRUE if all components are found.
ImageMagick_INCLUDE_DIRS - Full paths to all include dirs.
ImageMagick_LIBRARIES - Full paths to all libraries.
ImageMagick_<component>_FOUND - TRUE if <component> is found.
ImageMagick_<component>_INCLUDE_DIRS - Full path to <component> include dirs.
ImageMagick_<component>_LIBRARIES
所以你可以直接写
include_directories(${ImageMagick_INCLUDE_DIRS})
target_link_libraries(YourApp ${ImageMagick_LIBRARIES})
相关文章:
- 在C++中设置基于操作系统的文件路径
- 为 QFileDialog 设置默认的 UNC 路径
- 将Visual Studio Code路径设置为.clang_format文件
- 如何设置 CMake 来构建包含路径包含的代码,如 #include < libdir/lib>?
- 在Visual Studio Code(.json配置)中设置相对于工作区路径的c / c ++项目的包含路径
- 如何从客户端为COM服务器设置dll搜索路径?
- 为自定义路径类型设置提升property_tree
- 如何在C++(JNI)中设置正在运行的JVM的类路径
- 如何在 pybind11 项目中设置包含路径
- 如何在不设置完整路径的情况下访问 c++ 中的资源
- 在makefile中设置GCC路径
- CMAKE3:将通往MPI标头的路径设置
- 在Windows上设置编译器路径
- 设置所需DLL文件的自定义路径:电子应用
- 通过程序代码行设置C++包含路径
- 如何正确设置Windows路径以通过CMAKE轻松识别
- WT:未设置文档根或设置为空路径
- 我正在尝试在Eclipse中构建一个C 项目,但是即使在使用MINGW路径设置路径变量之后,也会获得构建错误
- 如何使用Qt Windows中的设置路径属性从命令行运行应用程序(.exe)时在命令行上打印日志
- 在CMake (c++, ImageMagick)中设置路径