|
| 1 | +Copyright (c) 2003, 2024, Oracle and/or its affiliates. |
| 2 | + |
| 3 | +This program is free software; you can redistribute it and/or modify |
| 4 | +it under the terms of the GNU General Public License, version 2.0, |
| 5 | +as published by the Free Software Foundation. |
| 6 | + |
| 7 | +This program is designed to work with certain software (including |
| 8 | +but not limited to OpenSSL) that is licensed under separate terms, |
| 9 | +as designated in a particular file or component or in included license |
| 10 | +documentation. The authors of MySQL hereby grant you an additional |
| 11 | +permission to link the program and your derivative works with the |
| 12 | +separately licensed software that they have either included with |
| 13 | +the program or referenced in the documentation. |
| 14 | + |
| 15 | +This program is distributed in the hope that it will be useful, |
| 16 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | +GNU General Public License, version 2.0, for more details. |
| 19 | + |
| 20 | +You should have received a copy of the GNU General Public License |
| 21 | +along with this program; if not, write to the Free Software |
| 22 | +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 | + |
| 24 | +Build Instructions for MySQL Server |
| 25 | +=================================== |
| 26 | + |
| 27 | +The recommended way to build MySQL for developers: |
| 28 | + |
| 29 | +cd <some build directory> |
| 30 | +cmake <path to source directory> |
| 31 | +make |
| 32 | + |
| 33 | +This will give you a release (actually RelWithDebInfo) build, |
| 34 | +with compiler options taken from |
| 35 | +../cmake/build_configurations/compiler_options.cmake |
| 36 | + |
| 37 | +Adding -DWITH_DEBUG=1 to the cmake command line gives you a debug build. |
| 38 | + |
| 39 | + |
| 40 | +Building on Windows is slightly different: |
| 41 | +cd <some build directory> |
| 42 | +cmake <path to source directory> -G <generator> |
| 43 | + |
| 44 | +We only support Visual Studio as generator and only 64 bit ("Win64"). |
| 45 | + |
| 46 | +cmake --build . --config Debug |
| 47 | +or |
| 48 | +cmake --build . --config RelWithDebInfo |
| 49 | + |
| 50 | +You can pass options to msbuild, see |
| 51 | +https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2019 |
| 52 | + |
| 53 | +To speed up compilation, building multiple projects in parallel: |
| 54 | +cmake --build . --config Debug -- -m |
| 55 | + |
| 56 | +To have a completely silent build: |
| 57 | +cmake --build . --config Debug -- -v:q |
| 58 | + |
| 59 | +Or combined: |
| 60 | +cmake --build . --config Debug -- -m -v:q |
| 61 | + |
| 62 | + |
| 63 | +If you have special needs, you can disable the defaults by setting |
| 64 | +this cmake variable off: WITH_DEFAULT_COMPILER_OPTIONS |
| 65 | + |
| 66 | +Building MySQL from source requires SSL headers and libraries to be |
| 67 | +available. The default value for the cmake variable WITH_SSL is "system". |
| 68 | +This means that on UNIX systems, you should install the appropriate |
| 69 | +OpenSSL developer package. |
| 70 | + |
| 71 | +For Windows users, please see |
| 72 | + https://wiki.openssl.org/index.php/Binaries |
| 73 | +For Mac users, please see |
| 74 | + http://brewformulas.org/Openssl |
| 75 | + |
| 76 | +You may also build OpenSSL yourself, and do |
| 77 | + cmake -DWITH_SSL=</path/to/custom/openssl> |
| 78 | +in order to build MySQL. |
| 79 | +=== |
| 80 | + |
| 81 | +It is possible to compile with Clang on Windows, which compiles faster |
| 82 | +and also yields faster binaries, but this is experimental and not officially |
| 83 | +supported. To compile, install the most recent version from |
| 84 | +https://github.com/llvm/llvm-project/releases |
| 85 | +(Clang/C2, which is Microsoft's own version of Clang, is not supported) |
| 86 | + |
| 87 | +Ensure that you have ninja and cmake in your path. |
| 88 | +Source the appropriate vcvarsall.bat file which comes with Visual Studio, |
| 89 | +so that Visual Studio executables are in your PATH. |
| 90 | + |
| 91 | +cmake -G Ninja -DFORCE_UNSUPPORTED_COMPILER=1 |
| 92 | + -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" |
| 93 | + -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" |
| 94 | + -DCMAKE_LINKER="C:/Program Files/LLVM/bin/lld-link.exe" |
| 95 | + -DWITH_BOOST=<path to Boost> .. |
| 96 | + |
| 97 | +ninja |
| 98 | + |
| 99 | +This configuration also supports ASAN (-DWITH_ASAN=1), although currently only |
| 100 | +when linking with MSVC's linker (not with LLD). |
| 101 | + |
| 102 | +For running tests with --parallel, you may need to add --build-thread= (500 is |
| 103 | +a reasonable value to try). |
| 104 | + |
| 105 | +=== |
| 106 | + |
| 107 | +Note: You need to tell cmake where to find boost, see ../cmake/boost.cmake |
0 commit comments