If someone is interested, I can volunteer to try migrating the G’MIC makefiles to CMake, for better dependencies checking and also to automatically generate a suitable pkg-config file.
Just give me green light if you think it is a good idea…
If someone is interested, I can volunteer to try migrating the G’MIC makefiles to CMake, for better dependencies checking and also to automatically generate a suitable pkg-config file.
Just give me green light if you think it is a good idea…
That is maybe a good idea to have an alternative to the Makefile
, but that would also mean you are OK to do the maintenance and bug fixes in the future
The current Makefile
works great for me, so what would bring the use of CMake
in this case ?
A Cmake based build system could provide better checking of dependencies, with some more informative messages if required packages are not found, and hopefully a more compact build configuration file. Or could allow to enable/disable specific features from the command line, if needed in future.
Surely I’m ready to maintain the cmake configuration once it is ready!
any progress on this front? @Carmelo_DrRaw
There was no work done yet on this simply because it seemed that the existing build system was OK for all situations. However, if a cmake-based system would help making G’MIC more compatible with various distros, I’m ready to resurrect the topic, and help with writing/maintaining the CMakeFiles! In which case, I can start doing some work in September.
@Carmelo_DrRaw the current build system is maybe OK only for some situations, and a PITA for others. See Patching the Makefile
@darix @David_Tschumperle @Morgan_Hardwood
Hi there! I have started to write an experimental CMakeLists.txt file for compiling G’MIC.
It would be great if somebody could test it and give me feedback. The building is currently limited to the CLI interface and the GIMP plug-in.
Also, it does not check for all the optional dependencies, and is not tested under Windows.
Here is how to use it:
build
folder in the main G’MIC source treebuild
sub-foldercmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=the_install_prefix ../ && make
make install
or sudo make install
depending if the install prefix is in your home or is some system pathI confirm that your steps work!
Thanks for checking! So this most likely means that the automatic detection of X11 libraries and XShm extensions works fine under gentoo.
Did you also compile the gimp plug-in?
The other advantage is that optional packages (like OpenEXR support) are only enabled if the corresponding libraries are found. Maybe some of them should be changed to “REQUIRED”?
Um, I guess? I didn’t pass any flags other than what you wrote, and I think I saw two executables before I deleted the whole thing after the successful test.
That sounds generally good, but for Gentoo there needs to be a way to disable/enable support for an optional component regardless of whether the dependency for such a component is present. For example even though a user (“they”) might have OpenEXR installed, they may also have USE="-openexr"
which means the package should not compile support for OpenEXR. Is there a way?
See https://devmanual.gentoo.org/ebuild-writing/functions/src_configure/configuring/index.html
The G’MIC ebuild currently in Gentoo has these optional components:
$ equery uses gmic
[ Legend : U - final flag setting for installation]
[ : I - package is installed with flag ]
[ Colors : set, unset ]
* Found these USE flags for media-gfx/gmic-1.6.5.1:
U I
+ + X : Add support for X11
+ + ffmpeg : Enable ffmpeg/libav-based audio/video codec support
- - fftw : Use FFTW library for computing Fourier transforms
- - graphicsmagick : Enable support for many common image file formats using the GraphicsMagick++ library
+ + jpeg : Add JPEG image support
- - opencv : Enable support for webcams using the OpenCV library
+ + openexr : Support for the OpenEXR graphics file format
+ + openmp : Build support for the OpenMP (support parallel computing), requires >=sys-devel/gcc-4.2 built with USE="openmp"
+ + png : Add support for libpng (PNG images)
+ + tiff : Add support for the TIFF image format
+ + zlib : Add support for zlib (de)compression
Maybe we could take as example some other cmake-based package with optional
dependencies? Like rawtherapee and/or darktable?
And see how the use flags are connected with cmake options…
Just like this:
option(USE_OPENEXR "Enable OpenEXR support" ON)
#...
if(USE_OPENEXR)
find_package(OpenEXR)
if(OpenEXR_FOUND)
# ...
endif(OpenEXR_FOUND)
endif(USE_OPENEXR)
From the cmake side this is clearly the way to go, my doubts were more on
the gentoo ebuild side… for example how to set -DUSE_OPENEXR=ON/OFF based
on the emerge use flags.
I think this page explains everything:
https://devmanual.gentoo.org/eclass-reference/cmake-utils.eclass/
Precisely. So as long as the CMake script supports optional components, the Gentoo side of things is happy.
I am just trying it on OSX 10.10 with macPorts:
and get these messages:
X11_INCLUDE_DIR: /opt/local/include/usr/X11R6/include
X11_INCLUDE_DIRs:
X11_LIBRARY_DIR:
X11_LIBRARY_DIRS:
I am not just familiar with cmake, hence you have maybe an idea?
Karsten
It is strange that cmake does not report any library directory for X11… does it compile fine?
Unluckily not!
Where should the folders be located. I have build,cmake and src in gmic folder?
Here is the log
build $ cmake -DCMAKE_BUILD_TYPE=Release …/cmake; make
– The CXX compiler identification is AppleClang 7.0.2.7000181
– The C compiler identification is AppleClang 7.0.2.7000181
– Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
– Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
– Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Found PkgConfig: /opt/local/bin/pkg-config (found version “0.29.1”)
– Found ZLIB: /usr/lib/libz.dylib (found version “1.2.5”)
– Looking for XOpenDisplay in /opt/local/lib/libX11.dylib;/opt/local/lib/libXext.dylib
– Looking for XOpenDisplay in /opt/local/lib/libX11.dylib;/opt/local/lib/libXext.dylib - found
– Looking for gethostbyname
– Looking for gethostbyname - found
– Looking for connect
– Looking for connect - found
– Looking for remove
– Looking for remove - found
– Looking for shmat
– Looking for shmat - found
– Looking for IceConnectionNumber in ICE
– Looking for IceConnectionNumber in ICE - found
– Found X11: /opt/local/lib/libX11.dylib
X11_INCLUDE_DIR: /opt/local/include/usr/X11R6/include
X11_INCLUDE_DIRs:
X11_LIBRARY_DIR: /opt/local/lib
X11_LIBRARY_DIRS:
– Checking for module ‘fftw3>=3.0’
– Found fftw3, version 3.3.4
– Found TIFF: /opt/local/lib/libtiff.dylib (found version “4.0.6”)
– Found PNG: /usr/local/lib/libpng.a (found version “1.2.41”)
– Found JPEG: /opt/local/lib/libjpeg.dylib
– Checking for module ‘OpenEXR’
– Found OpenEXR, version 2.2.0
– Checking for module ‘gimp-2.0’
– Found gimp-2.0, version 2.8.18
– Checking for module ‘gimpui-2.0’
– Found gimpui-2.0, version 2.8.18
– Configuring done
CMake Error at CMakeLists.txt:180 (add_executable):
Cannot find source file:
./src/gmic.h
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error at CMakeLists.txt:180 (add_executable):
Target “gmic_gimp” links to item "-lpthread " which has leading or trailing
whitespace. This is now an error according to policy CMP0004.
CMake Error at CMakeLists.txt:152 (add_executable):
Target “gmic” links to item "-lpthread " which has leading or trailing
whitespace. This is now an error according to policy CMP0004.
CMake Error: CMake can not determine linker language for target: gmic_gimp
CMake Error: Cannot determine link language for target “gmic_gimp”.
CMake Error: CMake can not determine linker language for target: gmic
CMake Error: Cannot determine link language for target “gmic”.
– Generating done
– Build files have been written to: /Users/karo/sw/gmic/build
Scanning dependencies of target gmic_gimp
make[2]: *** No rule to make target `CMakeFiles/gmic_gimp.dir/build’. Stop.
make[1]: *** [CMakeFiles/gmic_gimp.dir/all] Error 2
make: *** [all] Error 2
build $
Sorry, I updated the CMakeLists.txt file but had no time yet to write a comment here… the new version is meant to be put in the main gmic directory, instead of a “cmake” subdirectory. I think that this makes more sense and is more in line with what other software packages do.
That’s why you get this error:
Previously the sources where searched in ../src
.
Could you please move the cmake/CMakeLists.txt
file in the root directory of the gmic sources, and try again? I have also corrected the instructions in my previous post…
By the way @Carmelo_DrRaw, -DCMAKE_BUILD_TYPE=Release
works but RelWithDebInfo
does not. Haven’t tried debug
.
Hmm, next trial delivers this:
build $ cmake -DCMAKE_BUILD_TYPE=Release …/; make
X11_INCLUDE_DIR: /opt/local/include/usr/X11R6/include
X11_INCLUDE_DIRs:
X11_LIBRARY_DIR: /opt/local/lib
X11_LIBRARY_DIRS:
– Configuring done
CMake Error at CMakeLists.txt:180 (add_executable):
Target “gmic_gimp” links to item "-lpthread " which has leading or trailing
whitespace. This is now an error according to policy CMP0004.
CMake Error at CMakeLists.txt:152 (add_executable):
Target “gmic” links to item "-lpthread " which has leading or trailing
whitespace. This is now an error according to policy CMP0004.
– Generating done
– Build files have been written to: /Users/karo/sw/gmic/build
[ 20%] Building CXX object CMakeFiles/gmic_gimp.dir/src/gmic.cpp.o
In file included from /Users/karo/sw/gmic/src/gmic.cpp:1917:
In file included from /Users/karo/sw/gmic/src/gmic.h:168:
/Users/karo/sw/gmic/src/./CImg.h:190:10: fatal error: ‘initializer_list’ file
not found
#include <initializer_list>
^
1 error generated.
make[2]: *** [CMakeFiles/gmic_gimp.dir/src/gmic.cpp.o] Error 1
make[1]: *** [CMakeFiles/gmic_gimp.dir/all] Error 2
make: *** [all] Error 2
build $