synfig
synfig copied to clipboard
build: Use conan to build synfig
To build, you do something like
cd conan-recipes/gtk/all
conan export . gtk/3.24.34@
cd ../../gtkmm/all
conan export . gtkmm/3.24.6@
cd ../../../
mkdir build
conan install .. -if ./modules/ --build=missing
# if on powershell
$env:PKG_CONFIG_PATH = "$($(pwd).Path)/modules"
# if on bash
PKG_CONFIG_PATH = $PKG_CONFIG_PATH:$(pwd)/modules
./modules/activate_run.ps1
# if on powershell
cmake -DCMAKE_MODULE_PATH="$([RegEx]::Escape($(pwd)))/modules" ..
# if on bash
cmake -DCMAKE_MODULE_PATH="$(pwd)/modules" -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release
I wrote two powershell scripts to automate this (since currently I tried it only on Windows) 1-conan-export.ps1 and 2-conan-build.ps1.
@hesham-essam
Can you check with this PR? https://github.com/synfig/synfig/pull/2622
@hesham-essam
I suggest to split this PR. Extract Conan scripts and recipes into a separate PR, so I can merge them without issues, after that we can continue with CMake.
This pull request introduces 2 alerts when merging f4d567770eb572125c0fb1af8964653f6b0f05ac into 86a334636a1d6f2913addce98bf15674d03e6a1b - view on LGTM.com
new alerts:
- 1 for Unused named argument in formatting call
- 1 for Unused import
@hesham-essam
I suggest to split this PR. Extract Conan scripts and recipes into a separate PR, so I can merge them without issues, after that we can continue with CMake.
I will try making this PR compile correctly first here in the CI, and locally on linux and windows, then I will split things up into multiple PRs if that's okay.
I will try making this PR compile correctly first here in the CI, and locally on linux and windows, then I will split things up into multiple PRs if that's okay.
Sure.
This pull request introduces 2 alerts when merging 0f52af830cc5b6415a1075e71258344246df84d6 into 3bf0203ba1fc3f093945820d6512130263c79cb3 - view on LGTM.com
new alerts:
- 1 for Unused named argument in formatting call
- 1 for Unused import
This pull request introduces 1 alert when merging 049e84e7ea0361a4439126ca474837b1de294595 into 3bf0203ba1fc3f093945820d6512130263c79cb3 - view on LGTM.com
new alerts:
- 1 for Unused named argument in formatting call
@ice0 This builds locally fine on Windows and Linux. Please try it since my environment isn't the most standard one.
First run 1-conan-export, then 2-conan-build, then activate the run environment in "conan_build/modules/activate_run.[sh/ps1]".
- It stops the build with an error (PS):
CMake Error at synfig-studio/src/gui/CMakeLists.txt:36 (add_executable):
Target "synfigstudio" links to target "PkgConfig::GTKMM" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
The issue is missing pkg-config on Windows.
+ pkg-config
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (pkg-config:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Fixed by using x64 Native Tools Command Prompt for VS 2019 and pkg-config from MSYS2.
cmake --build . --config Release -j8
Doesn't work with MSBuild. Fixed by passing CL_MPcount.
cmake --build . --config Release -- /p:CL_MPcount=8
build_imagestarget doesn't builds. The issue issynfig_tool.execan't find the libraries.
@ice0 On windows it seems that the run environment wasn't activated. I added pkgconf as a build dependency so it should've been added to the path in the run environment.
Did you use the script or run cmake without it?
If not, you should run modules/activate_run.ps1 first.
@ice0 On windows it seems that the run environment wasn't activated. I added pkgconf as a build dependency so it should've been added to the path in the run environment. Did you use the script or run cmake without it? If not, you should run
modules/activate_run.ps1first.
First I tried to use Developer's PowerShell for VS 2019 to build Synfig.
It fails to build gettext library and stops with error libintl.res.obj : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'. The issue was due to the "Developer's PowerShell for VS 2019" being run in 32-bit mode and there is no Developers PowerShell x64 as they did for the command line (I mean x64 Native Tools Command Prompt for VS 2019).
Next I tried to use x64 Native Tools Command Prompt for VS 2019 and it builds all packages fine, but stops when trying to build Synfig.
The problem here is that I can't use activate_run.ps1 to switch environment from command-line and I missed that activate_run.bat is already there.
So I switched to standard PowerShell. Some packages could not be built due to missing CMake (standard PowerShell didn't add VS CMake binary to the PATH). Fixed this by adding CMake as a build dependency for those packages, so they used Conan's CMake. After that Synfig builds fine, but there is no GTK icons (it's ok, copied them manually), but it stops on start with error message:
...
synfig(5732) [15:56:48] info: Loading Custom Workspace List...
synfig(5732) [15:56:48] info: Init auto recovery...
synfig(5732) [15:56:48] info: Loading Settings...
synfig(5732) [15:56:48] info: Init Tools...
synfig(5732) [15:56:48] info: Checking auto-recover...
synfig(5732) [15:56:48] info: Done.
Fontconfig error: Cannot load default config file: No such file: (null)
There are a couple of issues with conan that I will fix, then I will come back to this PR. These being:
- Gettext provided by conan provides
msgmergeandmsgfmtbut does not defineGETTEXT_MSGMERGE_EXECUTABLEnorGETTEXT_MSGFMT_EXECUTABLEcmake variablesand it also does not provide. Hopefully I will do a PR for this by tomorrow.libintlfor Windows - Conan's Gtk 3 is broken on Windows, and I believe it could be broken on Linux as well. The problem is mixing shared and static libraries which causes problems with glib. See https://github.com/conan-io/conan-center-index/issues/11022 and https://github.com/conan-io/conan/issues/11396. I made these PRs to fix the problem:
- https://github.com/conan-io/conan-center-index/pull/11040
- https://github.com/conan-io/conan-center-index/pull/11041
- https://github.com/conan-io/conan-center-index/pull/11093
- https://github.com/conan-io/conan-center-index/pull/11171
- https://github.com/conan-io/conan-center-index/pull/11212
- https://github.com/conan-io/conan-center-index/pull/11209
- https://github.com/conan-io/conan-center-index/pull/11208
- https://github.com/conan-io/conan-center-index/pull/11166
Conan is in the middle of migrating to v2, which has a new API, so I had to copy and edit a number of recipes. As migration takes place, I will remove these recipes one by one.
This is an overhaul of the PR. My intent is to get rid of environment activation entirely. I took a page from what vcpkg did, and copied all dlls to synfig's bin directory.
I only tested this on Windows using VS2022, but I will get around to linux and VS2017. To build (using powershell) you do something like:
.\1-conan-export.ps1
mkdir build
cd build
conan install .. -if . -pr default --build=missing
cmake --preset=default -Ax64 -DCMAKE_BUILD_TYPE=Release -S .. -B .
cmake --build . -j8 --config Release
Also still missing:
- Themes
- gdk-pixbuf svg loader (needs a recipe for librsvg).
- ffmpeg (there is a recipe in conan, but I didn't test it yet)
This pull request introduces 3 alerts when merging 1c89ce9666c79ec442ddad15c97d62932d85dbed into 5aee83b4f54d15f1b4b3b216e1122da064c69d63 - view on LGTM.com
new alerts:
- 1 for Except block handles 'BaseException'
- 1 for Unused import
- 1 for Variable defined multiple times
This builds fine on linux locally. To build, you do something like
./1-conan-export.sh
mkdir build
cd build
conan install .. -if . -pr default --build=missing
cmake --preset=release -DCMAKE_BUILD_TYPE=Release -S .. -B .
make -j8
This pull request introduces 5 alerts when merging 7a30285cda4b82281ae372f2bd5ab9a821e847a4 into 9cecd2abe143e29cf0564e511183beebab7dfafb - view on LGTM.com
new alerts:
- 2 for Wrong name for an argument in a call
- 2 for Except block handles 'BaseException'
- 1 for Unused import