This document describes how MySQL was packaged for build2. In particular, this understanding will be useful when upgrading to a new upstream version. The upstream package contains the MySQL server, libmysqlclient library and a number of client/administrative utilities (mysql, mysqlcheck, etc). Currently, we only package libmysqlclient (see libmysqlclient/README-DEV for details). We add the upstream package as a git submodule and symlink the required files and subdirectories into the build2 package subdirectories. Then, when required, we "overlay" the upstream with our own header/source files, placing them into the library/program directories and their downstream/ subdirectories. Note that symlinking upstream submodule subdirectories into a build2 package subdirectory results in creating intermediate build files (.d, .o, etc) inside upstream directory while building the package in source tree. That's why we need to make sure that packages do not share upstream source files via subdirectory symlinks, not to also share the related intermediate files. If several packages need to compile the same upstream source file, then only one of them can symlink it via the parent directory while others must symlink it directly. The upstream package can be configured to contain a specific feature set. We reproduce the union of features configured for the upstream source package in Debian and Fedora distributions. The configuration options defining these sets are specified in the Debian's rules and Fedora's RPM .spec files. Note, however, that at the time of this writing the latest packaged versions are different: 5.7.25 on Debian and 8.0.15 on Fedora. These files can be obtained as follows: $ wget https://download.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/source/tree/Packages/c/community-mysql-8.0.15-1.fc30.src.rpm $ rpm2cpio community-mysql-8.0.15-1.fc30.src.rpm | cpio -civ '*.spec' #$ wget http://deb.debian.org/debian/pool/main/m/mysql-5.7/mysql-5.7_5.7.25-1.debian.tar.xz #$ tar xf mysql-5.7_5.7.25-1.debian.tar.xz debian/rules Instead of using MySQL 5.7.25 Debian's rules for MySQL 8.0.15 we are packaging, let's use upstream/packaging/deb-in/rules.in. That's not ideal but is, probably, better than nothing. Here are the discovered configuration options. Debian: -DWITH_INNODB_MEMCACHED=ON -DWITH_NUMA=ON Fedora: -DWITH_INNODB_MEMCACHED=ON -DENABLED_LOCAL_INFILE=ON Omitting options that are not related to the client library we end up with: -DENABLED_LOCAL_INFILE=ON See the configuration options description at https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html As a side note, on Debian and Fedora libmysqlclient is packaged under the libmysqlclient20 and community-mysql-libs package names respectively. The headers-containing development packages are libmysqlclient-dev and community-mysql-devel. Search for the Debian and Fedora packages at https://packages.debian.org/search and https://apps.fedoraproject.org/packages/. Normally, when packaging a cmake-based project, we try to deduce the source file and compilation/linking option sets analyzing the root and feature/component/platform-specific CMakeLists.txt and .cmake files. In practice, however, that can be uneasy and error prone, so you may also need to refer to cmake-generated configuration files or, as a last resort, to see the actual compiler and linker command lines in the build log. If that's the case, you can configure/build the upstream package on the platform of interest running the following commands in the project root directory. On POSIX: $ mkdir build $ cd build $ cmake -DDOWNLOAD_BOOST=ON -DWITH_BOOST=../boost -DWITHOUT_SERVER=ON \ -DENABLED_LOCAL_INFILE=ON .. $ make VERBOSE=1 >build.log 2>&1 Here we assume that OpenSSL is installed into the system. With MSVC: Run Visual Studio and change the settings: Tools > Options > Projects and Solutions > Build and Run > MSBuild project build output verbosity: Detailed Build libssl from cppget.org, install to C:/openssl and rename *.dll.lib to *.lib to match MySQL's expectations. > set OPENSSL_ROOT_DIR=C:/openssl > set PATH=c:\openssl\bin;%PATH% > mkdir build > cd build > cmake -DDOWNLOAD_BOOST=ON -DWITH_BOOST=../boost -DWITHOUT_SERVER=ON ^ -DENABLED_LOCAL_INFILE=ON .. -G "Visual Studio 15 2017 Win64" ^ >config.log 2>&1 > devenv MySQL.sln /build RelWithDebInfo >build-log 2>&1 With MinGW GCC: MinGW GCC is not mentioned at the "Installing MySQL from Source" page as a supported compiler for Windows and is, presumably, unsupported. Trying to use it fails at the compilation stage: > set OPENSSL_ROOT_DIR=C:/openssl > set PATH=c:\openssl\bin;C:\msys64\mingw64\bin;%PATH% > mkdir build > cd build > cmake -DDOWNLOAD_BOOST=ON -DWITH_BOOST=../boost -DWITHOUT_SERVER=ON ^ -DENABLED_LOCAL_INFILE=ON .. -G "MinGW Makefiles" > mingw32-make When the packaging is complete, build all the project packages in source tree and make sure that all the preprocessor include directives reference the packaged header files, rather than MariaDB or MySQL headers that are installed into the system. It's easy to miss some headers in the package if MariaDB or MySQL development package is installed on the host. We also need to check if the bundled library headers are picked up. To verify the correctness you can build the merged project, concatenate the produced .d files, sort the resulting file removing duplicates and edit the result, leaving only the system headers. Afterwards grep through the remained headers for some patterns: $ cat `find . -type f -name '*.d'` | sort -u >headers $ emacs headers # Edit, leaving system headers only. $ fgrep -e 'mysql' -e 'mariadb' -e 'openssl' -e 'zlib' headers