Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake build support #4191

Merged
merged 155 commits into from
Aug 30, 2021
Merged

CMake build support #4191

merged 155 commits into from
Aug 30, 2021

Conversation

mathisloge
Copy link
Collaborator

@mathisloge mathisloge commented Nov 20, 2020

closes #4190

This PR would add CMake support to mapnik

Remaining work:

  • copy all plugins and fonts in appropiate folders when building
  • windows: copy plugin dlls and dependency dlls into executable dir
  • install: check if all targets are installed correctly.
  • install, windows: do we install dependency dlls too? or do we let the user handle that?
  • check visual studio cmake integration
  • set name from mapnik to libmapnik and append libmapnik- to wkt and json
  • add option for MAPNIK_THREADSAFE (also add mt to lib name) and set then Boost_USE_MULTITHREADED
  • ↑ should mt be added to the library name libmapnik.[so]/[.dll] when using MAPNIK_THREADSAFE? eg. libmapnik-mt.[so]/[.dll]
  • add MAPNIK_NO_ATEXIT. (what is the default value?)
  • add MAPNIK_NO_DLCLOSE (what is the default value?)
  • add MAPNIK_ENABLE_GLIBC_WORKAROUND (what is the default value?)
  • add MAPNIK_DEBUG (option will be false by default. But if using the CMakePresets (debug config) will set this to ON)
  • add option for MAPNIK_LOG and MAPNIK_DEFAULT_LOG_SEVERITY
  • rewrite FindWebP
  • add MAPNIK_STATS

@mathisloge mathisloge mentioned this pull request Nov 20, 2020
@mathisloge
Copy link
Collaborator Author

mathisloge commented Nov 20, 2020

f6b7bc0 and 5420ccd are needed for mscv support. I've patched these lines out at vcpkg.
f6b7bc0 is easy to understand

but i don't quite understand why msvc complains about the lines changed at 5420ccd.
It will complain that there is no constructor to call e.g. geometry(geometry_empty()). So somehow the inheritance got messed up?
Currently the solution is to fallback to the forwarding constructor.

@mathisloge
Copy link
Collaborator Author

@artemp there might be a missing file in the source tree:

#include "../shapeindex/quadtree.hpp"

I can't find any shapeindex/quadtree.hpp

@mathisloge
Copy link
Collaborator Author

mathisloge commented Nov 21, 2020

3eb00b9 adds the feature test for #include <execution> since some compilers are providing c++17 features but not the execution policies

@mathisloge
Copy link
Collaborator Author

So i think i've added all options and worked out the most common config errors.
I've tested the build with ubuntu20.04(works if i'm using boost >= 1.73 see #4235) and windows. OSX builds in the CI Pipeline at vcpkg. So i guess that it is okay, too. But i can't test it, since i don't have a mac.

So there aren't any todos left (except the naming thing mentioned above, thats to discuss)

@mathisloge mathisloge requested a review from artemp July 23, 2021 18:16
@mathisloge
Copy link
Collaborator Author

@artemp do you see a chance to merge this with v4.0?
I'm happy to maintain any issues related to cmake in the future.

@artemp
Copy link
Member

artemp commented Aug 25, 2021

@artemp do you see a chance to merge this with v4.0?
I'm happy to maintain any issues related to cmake in the future.

Is it ready? Just let me know and I'll merge. Thanks for your contributions!

@mathisloge
Copy link
Collaborator Author

I'm pretty happy with it. Possibly there are still hidden things somewhere, which probably only appear with increased use by other users. Time will tell.

The last question from the todo list:

should mt be added to the library name libmapnik.[so]/[.dll] when using MAPNIK_THREADSAFE? eg. libmapnik-mt.[so]/[.dll]

After the question is resolved, this can be merged from my point of view.

@artemp
Copy link
Member

artemp commented Aug 26, 2021

should mt be added to the library name libmapnik.[so]/[.dll] when using MAPNIK_THREADSAFE? eg. libmapnik-mt.[so]/[.dll]

MAPNIK_THREADSAFE=YES is a default configuration so just using libmapnik.[so]/[dll] is fine ? `

@mathisloge
Copy link
Collaborator Author

yes MAPNIK_THREADSAFE=YES is default.

for me libmapnik.[so]/[dll] is fine. Just a preference you might have had liked more 👍

So if nothing from your side is standing out, it is ready to merge. I will add pkg-config files but that would be a different PR.

@artemp
Copy link
Member

artemp commented Aug 30, 2021

@mathisloge - ok, merging 🎉

@artemp artemp merged commit 69911ad into mapnik:master Aug 30, 2021
@mathisloge mathisloge deleted the cmake-support branch September 10, 2021 16:22
@zy6p
Copy link

zy6p commented Feb 11, 2022

@mathisloge This pr is great 👍

But when I want to distribute binary files of mapnik library, an error was reported on the new machine. mapnik-index: error while loading shared libraries: libboost_program_options.so.1.74.0: cannot open shared object file: No such file or directory .

The cmake-build mapnik dynamic library depends on specific libraries, such as libboost_program_options.so.1.74.0.

Cmake-build vs scons-build mapnik differences(use ldd command) are here:

# cmake build
root@docker-desktop:/tmp# ldd /usr/local/lib/libmapnik.so
        linux-vdso.so.1 (0x00007fffcf1fd000)
        libboost_filesystem.so.1.71.0 => /lib/x86_64-linux-gnu/libboost_filesystem.so.1.71.0 (0x00007f556ddb7000)
        libboost_regex.so.1.71.0 => /lib/x86_64-linux-gnu/libboost_regex.so.1.71.0 (0x00007f556dcb7000)
        libcairo.so.2 => /lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f556db94000)
        libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f556db5c000)
        libproj.so.15 => /lib/x86_64-linux-gnu/libproj.so.15 (0x00007f556d86d000)
        libtiff.so.5 => /lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f556d7ec000)
        libwebp.so.6 => /lib/x86_64-linux-gnu/libwebp.so.6 (0x00007f556d780000)
        libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f556d5c6000)
        libharfbuzz.so.0 => /lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f556d4c1000)
        libjpeg.so.8 => /lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f556d43c000)
        libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f556d256000)
        libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f556d197000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f556d18f000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f556cfad000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f556ce5e000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f556ce43000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f556ce20000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f556cc2e000)
        libicui18n.so.66 => /lib/x86_64-linux-gnu/libicui18n.so.66 (0x00007f556c92d000)
        libpixman-1.so.0 => /lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f556c886000)
        libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f556c83f000)
        libxcb-shm.so.0 => /lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f556c83a000)
        libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f556c810000)
        libxcb-render.so.0 => /lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f556c801000)
        libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f556c5f5000)
        libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f556c4b8000)
        libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f556c4a3000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f556c487000)
        libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f556c35e000)
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f556c2b5000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f556c28a000)
        libjbig.so.0 => /lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f556c07c000)
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f556bf53000)
        libgraphite2.so.3 => /lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f556bf26000)
        libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f556a465000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f556eac8000)
        libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f556a435000)
        libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f556a42c000)
        libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f556a426000)
        libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f556a41e000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f556a3ab000)
        libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f556a38f000)
# scons build
root@docker-desktop:/tmp# ldd node_modules/mapnik/lib/binding/lib/libmapnik.so
        linux-vdso.so.1 (0x00007ffd4a5a5000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fa542da1000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa542d9b000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa542bb9000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa542a6a000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa542a4f000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa542a2a000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa542838000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa5445bd000)

Clearly, scons-build has less dependencies and is more easily to distribute binary.

@mathisloge
Copy link
Collaborator Author

@zy6p the scons binary you are referencing here has most deps static linked. only libmapnik itself is dynamic.
E.g. libmapnik can't be build without boost-filesystem and this isn't in the scons libmapnik, therefore those deps are all static.

So you can't compare both.

Distribution of dynamic libraries on linux systems is very errorprone due to the exact reasons you mentioned here => versioning of shared libraries and system wide integration.

For a static libmapnik cmake build see #4291. Currently still in dev

@mathisloge
Copy link
Collaborator Author

@zy6p also if you really want to distibute dynamic libraries on linux, make sure all dependencies are installed on the new machine and have the correct versions. If you need other versions, you would need to build mapnik with those versions. e.g. if you wan't to use an local installed boost version, you have to specify BOOST_ROOT at cmake configure time

@zy6p
Copy link

zy6p commented Feb 14, 2022

@mathisloge thanks for your kind help.

It is difficult for me to install the same dependencies on new machines, which have diffenent linux systems. The official node-mapnik is the ideal solution. It will install with pre-build mapnik lib and all dependencies are static linked.

Looking forward to #4291 merge.

leedejun pushed a commit to leedejun/mapnik that referenced this pull request Dec 26, 2023
leedejun pushed a commit to leedejun/mapnik that referenced this pull request Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cmake build support
6 participants