Changes between Initial Version and Version 1 of MapGuideRfc164


Ignore:
Timestamp:
Jan 10, 2018, 10:54:18 AM (6 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc164

    v1 v1  
     1= !MapGuide RFC 164 - CMake build system =
     2
     3This page contains a change request (RFC) for the !MapGuide Open Source project. 
     4More !MapGuide RFCs can be found on the [wiki:MapGuideRfcs RFCs] page.
     5
     6
     7== Status ==
     8 
     9||RFC Template Version||(1.0)||
     10||Submission Date||11 Jan 2018||
     11||Last Modified||||
     12||Author||Jackie Ng||
     13||RFC Status||draft||
     14||Implementation Status||pending||
     15||Proposed Milestone||3.3||
     16||Assigned PSC guide(s)||||
     17||'''Voting History'''||||
     18||+1||||
     19||+0||||
     20||-0||||
     21||-1||||
     22||Abstained||||
     23 
     24== Overview ==
     25
     26This RFC proposes using CMake for building MapGuide on Linux.
     27
     28== Motivation ==
     29
     30MapGuide currently uses autotools to build MapGuide on Linux. Autotools suffers from:
     31
     32 * Slow build times
     33 * Builds are in the source tree, which complicates development as it will taint a subversion working copy with lots of autotools-generated junk files
     34 * Ability to use system-installed libraries is difficult as library detection logic is baked into various difficult to maintain
     35
     36CMake is an alternative build system to autotools. It has the following advantages:
     37
     38 * It is faster (see: Footnotes)
     39 * CMake builds are *out of the source tree*. This makes for a very clean development experience.
     40 * CMake makes it very easy for us to selectively use system-installed libraries over our internal counterparts.
     41 * There is healthy ecosystem of CMake modules available to easily detect certain libraries and for enabling compiler features (eg. AddressSanitizer)
     42 * (In the future): CMake can be our one-true-build-system-to-rule-them-all. It supports Visual Studio project generators, avoiding the need for us to maintain vcxproj/sln files by hand. But the main motivator for windows support is we can then leverage the use of [https://github.com/Microsoft/vcpkg vcpkg] to acquire/build/manage thirdparty C++ libraries on Windows. However, this particular item is not in the scope of this RFC and is merely an indicator of the possibilities a CMake build system will give us.
     43
     44== Proposed Solution ==
     45
     46This RFC is basically a mirror of the equivalent [https://trac.osgeo.org/fdo/wiki/FDORfc21 RFC for FDO]
     47
     48The repository will be overlaid with various `CMakeLists.txt` files that describe how to build the various projects.
     49
     50A minor problem with implementing this solution is that we have certain thirdparty components that do not exist as system-installed libraries or they are available through the package manager but it is difficult to take advantage of them:
     51
     52 * AGG
     53 * CS-Map
     54 * DBXML
     55 * DWF Toolkit
     56 * PHP
     57 * Apache HTTPD
     58 * Tomcat Connector
     59
     60To enable building these thirdparty components and to allow CMake to find them and to maintain the out-of-source-tree quality a CMake build gives us we'll add some helper build scripts to streamline the whole CMake build
     61
     62=== cmake_bootstrap.sh ===
     63
     64This is effectively a CMake-optimized version of the existing `build_oem.sh` that selectively builds the following thirdparty components
     65in a build area separate from the source checkout:
     66
     67 * DBXML
     68 * PHP
     69 * Apache HTTPD
     70 * Tomcat Connector
     71
     72This will install Apache/PHP into the designated install prefix so superuser elevation is generally required when running this script
     73
     74=== cmake_build.sh ===
     75
     76This is the main CMake wrapper build script that uses the build area prepared by `cmake_bootstrap.sh` to easily detect DBXML, Apache HTTPD and PHP
     77to easily set up include directories and link libraries for the various projects that need them
     78
     79=== CMake-ification ===
     80
     81But what about the other thirdparty libraries? This RFC will also CMake-ify the following thirdparty libraries:
     82
     83 * DWF Toolkit
     84 * CS-Map
     85
     86This will cause the above libraries to be built as part of the main `cmake_build.sh` run.
     87
     88Due to CS-Map being an svn external link, we can't modify its contents directly, so the CMake-ification of CS-Map will occur in a sibling `CsMapLibrary` directory in `Oem`.
     89
     90TODO: We should be upstanding OSS citizens and actually get the CS-Map project to adopt building with CMake, but that is not the scope of this RFC.
     91
     92With AGG, we will do what we do currently on Windows: Directly reference the various AGG source files of interest directly into the CMake-ified `Renderers` project.
     93
     94Other thirdparty libraries are available for us via the package manager for the distro versions we intend to target and thus are not built in this build system:
     95
     96 * xerces-c (Our internal DBXML has been modified to work with a system-installed xerces-c)
     97 * geos
     98 * gd/libjpeg/libpng/zlib
     99 * jsoncpp
     100 * cppunit
     101 * ACE
     102
     103=== Building with CMake ===
     104
     105With these changes and build scripts, and assuming FDO and any available system-libraries are installed. The CMake build is simply:
     106
     107{{{
     108svn [co/export] https://svn.osgeo.org/mapguide/trunk/MgDev ~/mapguide_source
     109cd ~/mapguide_source
     110sudo ./cmake_bootstrap.sh --oem_working_dir ~/mapguide_oem_build
     111./cmake_build.sh --oem_working_dir ~/mapguide_oem_build --cmake_build_dir ~/mapguide_build_area
     112cd ~/mapguide_build_area
     113sudo make install
     114}}}
     115
     116In this example, the `~/mapguide_oem_build` and `~/mapguide_build_area` directories are automatically created by the build scripts and `~/mapguide_source` will remain un-tainted as the build will be taking place in `~/mapguide_oem_build` and `~/mapguide_build_area`.
     117
     118With this solution, the development experience is much cleaner as one can then proceed to edit sources under `~/mapguide_source` and be able to rebuild by re-running `make` and `make install` in `~/mapguide_build_area`. When it comes time to commit, there is no concerns about what junk files have been left by the build system as they are all in the un-tracked `~/mapguide_oem_build` and `~/mapguide_build_area` directories.
     119
     120This RFC has been implemented in the [https://trac.osgeo.org/mapguide/browser/sandbox/jng/cmake_v2 cmake_v2 sandbox]. Upon adoption of this RFC, the changes will be merged into trunk.
     121
     122== Implications ==
     123
     124This is an alternative build system for Linux. Existing build systems are not affected.
     125
     126== Test Plan ==
     127
     128Build on Ubuntu 14.04 with selective use of system-installed libraries.
     129
     130Build with existing Autotools to verify those builds still function.
     131
     132== Funding/Resources ==
     133
     134Community
     135
     136== Footnotes ==
     137
     138During the initial sandbox implementation of this RFC, CMake with the Ninja build generator and usage of GNU gold linker (over ld) yielded some very impressive build performance times vs the same build via autotools. However with the advent of the [https://meltdownattack.com/ Meltdown and Spectre vulnerabilities] and the ensuing OS/kernel updates to patch these vulnerabilities, the build performance gains through CMake have been wiped out and is now on par with autotools (pre-meltdown). Autotools (post-meltdown) has worse build performance, so overall a CMake build still performs better against Autotools, but it is a somewhat moot point in a post-meltdown world.