I’m trying to add something to a larger C++ project which is developed using CMake. In the part I’m adding, I want to use Magick++.
If I’m only compiling my small example program
#include <Magick++.h>
int main()
{
Magick::Image image;
return 0;
}
with
g++ -o example example.cxx
it fails since it doesn’t find “Magick++.h”.
If I’m using
g++ -I /usr/include/ImageMagick -o example example.cxx
I get “undefined reference” errors.
If I follow the instructions on http://www.imagemagick.org/script/magick++.php and compile using
g++ `Magick++-config --cxxflags --cppflags` -o example example.cxx `Magick++-config --ldflags --libs`
it works.
Now:
How do I incorporate this into the larger project that uses CMake? How do I have to change the CMakeLists.txt?
There is FindImageMagick.cmake module in the basic CMake distribution, so you are lucky.
You should add something like this this to the CMakeLists.txt:
After that, you can use following variables:
So you can do just