CMake build system for G'MIC

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

-DPRERELEASE_TAG="mmddyy"

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

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 ?

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?

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!

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:

@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.

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

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?

Thanks!

No, the Makefile entry:

gmic_stdlib.h:
	@echo -n "> Retrieve G'MIC Standard Library..."
	@$(WGET) gmic_stdlib.h http://gmic.eu/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: ).

Thanks David, I got confused by the different targets…

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…

Thanks!

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

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

$ mkdir foo && cd foo
$ git clone https://github.com/dtschump/gmic.git
$ cd gmic
$ wget https://gist.githubusercontent.com/aferrero2707/2ae108dd19bba4a9406c8cd3167a4d2a/raw/555d21987b3b8a3878b3e54ba2203809ef5affaf/CMakeLists.txt
$ 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.

You need to specify the build target:

-DCMAKE_BUILD_TYPE=Release

or

-DCMAKE_BUILD_TYPE=Debug

or

-DCMAKE_BUILD_TYPE=RelWithDebInfo

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

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

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 !

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

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

2 Likes

Hello

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

Compiling…

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
  "/usr/lib/gimp/2.0/plug-ins/gmic_gimp".

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.