CMake build system for G'MIC

(Carmelo Dr Raw) #41

The caveat is that we do not want to modify the code, only the build system…

Well, in fact the tag must be given by whoever runs cmake. So it’s up to you to set


when you invoke cmake. For the moment I could not come up with a better solution… is that acceptable?

(Karsten R) #42

Sure, very good!
By the way under bash the tag has to given as -DPRERELEASE_TAG=\\“081516\\” ! (there should be three backslashes)

What about the switching the # singlethread option for fftw3 ?

(Morgan Hardwood) #43

Hello, what is the status with the CMake build system for G’MIC? Is there anything that needs testing? Is it ready to be merged upstream?

(Carmelo Dr Raw) #44

The status is the following:

  • the version in the github gist provides cmake switches for all the Gentoo use flags. The switches are activated by default, but the corresponding packages are not required, only enabled if detected
  • I am testing the CMakeLists.txt with my GIMP AppImage builds, and so far I have not found any issues
  • the CMakeLists.txt was not tested so far under OSX or Windows
  • I am ready to provide support and maintenance for it. In fact, the CMakeLists.txt is rather simple and I do not expect too much maintenance needed once it is working…
  • as to wether to merge it upstream , I let @David_Tschumperle to decide what to do.

In any case, some testing with the Gentoo emerge system would be definitely interesting!

(David Tschumperlé) #45

I gave a try today and unfortunately, this didn’t work for me.
It’s probably my fault. I’ve tested putting the build folder both in the gmic/ and gmic/src/ folder, and got different error messages for these two cases.
As I’m not sure I did the things right, I’ll probably test again before complaining too much :slight_smile:

(Carmelo Dr Raw) #46

@David_Tschumperle: The usage is pretty simple:

  • put the CMakeLists.txt file in the top gmic/ folder
  • mkdir build; cd build
  • cmake [options] .. && make && make install

What I forgot to mention is that the current cmake build system only works with official releases, not with git clones… this is the next thing I need to work on, probably with some help from David.

Compiling Error
(David Tschumperlé) #47

That is exactly what I’ve done yes, but on the git clone indeed.

(Carmelo Dr Raw) #48

Ok, here comes my first question concerning how to build from git sources: the gmic target depends on gmic_stdlib.h header, which in turn requires gmic in order to be generated… how do I get out of this apparently circular dependency?


(David Tschumperlé) #49

No, the Makefile entry:

	@echo -n "> Retrieve G'MIC Standard Library..."
	@$(WGET) gmic_stdlib.h
	@touch gmic_stdlib.h
	@echo " done!"

shows that gmic is not necessary to retrieve file gmic_stdlib.h.
Makefile entry stdlib: indeed generates this file too (and upload it on the G’MIC server if possible), but this is not an entry you should call by yourself (I do :slight_smile: ).

(Carmelo Dr Raw) #50

Thanks David, I got confused by the different targets…

(Carmelo Dr Raw) #51

I have updated the CMakeLists.txt file so that it can correctly compile sources cloned from git.

In particular, the build system will download the CImg.h and gmic_stdlib.h headers using the cmake

file(DOWNLOAD ...)

command, so that the choice of the specific program to be used (wget, curl, etc…) is delegated to the cmake system itself.

If anyone tests the new CMakeLists.txt, I’d be interested to know if it works or not…


(David Tschumperlé) #52

I’m testing it right now. Will tell you how it goes :slight_smile:

(David Tschumperlé) #53

Still got the compiling issues. I’m starting from a clean directory:

$ mkdir foo && cd foo
$ git clone
$ cd gmic
$ wget
$ mkdir build && cd build
$ cmake ../

(works OK until now).

$ make

and I get a bunch of errors. Not sure why I get those…

If you have any idea…

EDIT : of course, if I type :

$ cd ../src && make

it works as expected.

(Carmelo Dr Raw) #54

You need to specify the build target:






(David Tschumperlé) #55

I see… Isn’t it possible to assign this flag a “default” value, probably Release ?

(Carmelo Dr Raw) #56

I think it should be possible, I’ll look into that a bit later…

(David Tschumperlé) #57

OK, I’m waiting for you then.
I’m almost ready for a new release (1.7.6). Including your CMakeLists.txt could be a good addition !

(Carmelo Dr Raw) #58

Ok, it was actually a 30 seconds modification… the build type now defaults to Release if nothing is specified.

(David Tschumperlé) #59

I confirm, this works. I’ll include this file in the final release then, thank you !

(Morgan Hardwood) #60


cd ~/programs
git clone code-gmic
cd code-gmic/
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX="$HOME/programs/gmic" ../
make -j8 install


Compiled successfully, but installation failed with:

CMake Error at cmake_install.cmake:90 (file):
  file INSTALL cannot copy file
  "/home/morgan/programs/code-gmic/build/gmic_gimp" to

The user should be able to install to a custom folder if system-wide installation is not desired, for example because the user is compiling in a sandbox, or because the user wants to install this for a GIMP git bleeding-edge build which is confined to its own folder so as not to conflict with the GIMP stable build installed system-wide by the package manager.
CMAKE_INSTALL_PREFIX enables that, but it doesn’t seem to be implemented for the GIMP plugin.