diff options
author | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-11-09 12:32:48 +0100 |
---|---|---|
committer | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-11-09 12:32:48 +0100 |
commit | bc76ad8f6be7e75c7f1dccc322638566ee0fc0e7 (patch) | |
tree | ef650a7fd633d354f237aa267a871fce11fe48d3 /BUILD-CMAKE | |
parent | d476bbb0becb27d7d3cb1fc5cc0ac4d401622893 (diff) | |
download | mariadb-git-bc76ad8f6be7e75c7f1dccc322638566ee0fc0e7.tar.gz |
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
Diffstat (limited to 'BUILD-CMAKE')
-rw-r--r-- | BUILD-CMAKE | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/BUILD-CMAKE b/BUILD-CMAKE new file mode 100644 index 00000000000..b5a01d52a5a --- /dev/null +++ b/BUILD-CMAKE @@ -0,0 +1,243 @@ +How to Build MySQL server with CMake + +WHAT YOU NEED +--------------------------------------------------------------- +CMake version 2.6 or later installed on your system. + +HOW TO INSTALL: + +Linux distributions: +shell> sudo apt-get install cmake + +The above works on do Debian/Ubuntu based distributions.On others, command +line needs to be modified to e.g "yum install" on Fedora or "zypper install" +on OpenSUSE. + +OpenSolaris: +shell> pfexec pkgadd install SUNWCMake + +Windows and Mac OSX: +Download and install the latest distribution from +http://www.cmake.org/cmake/resources/software.html.On Windows, download +installer exe file and run it. On Mac, download the .dmg image and open it. + +Other Unixes: +Precompiled packages for other Unix flavors (HPUX, AIX) are available from +http://www.cmake.org/cmake/resources/software.html + +Alternatively, you can build from source, source package is also available on +CMake download page. + + +Compiler Tools +-------------- +You will need a working compiler and make utility on your OS. +On Windows, install Visual Studio (Express editions will work too). +On Mac OSX, install Xcode tools. + + + +BUILD +--------------------------------------------------------------- +Ensure that compiler and cmake are in PATH. +The following description assumes that current working directory +is the source directory. + + +- Generic build on Unix, using "Unix Makefiles" generator + +shell>cmake . +shell>make + +Note: by default, cmake build is less verbose than automake build. Use +"make VERBOSE=1" if you want to see add command lines for each compiled source. + +- Windows, using "Visual Studio 9 2008" generator +shell>cmake . -G "Visual Studio 9 2008" +shell>devenv MySQL.sln /build /relwithdebinfo +(alternatively, open MySQL.sln and build using the IDE) + +- Windows, using "NMake Makefiles" generator +shell>cmake . -G "NMake Makefiles" +shell>nmake + +- Mac OSX build with Xcode +shell>cmake . -G Xcode +shell>xcodebuild -configuration Relwithdebinfo +(alternatively, open MySQL.xcodeproj and build using the IDE) + +Command line build with CMake 2.8 +After creating project with cmake -G as above, issue +cmake . --build +this works with any CMake generator. + +For Visual Studio and Xcode you might want to add an extra +configuration parameter, to avoid building all configurations. + +cmake . --build --config Relwithdebinfo + + +Building "out-of-source" +--------------------------------------------------------------- +Building out-of-source provides additional benefits. For example it allows to +build both Release and Debug configurations using the single source tree.Or +build the same source with different version of the same compiler or with +different compilers. Also you will prevent polluting the source tree with the +objects and binaries produced during the make. + +Here is an example on how to do it (generic Unix), assuming the source tree is +in directory named src and the current working directory is source root. + +shell>mkdir ../build # build directory is called build +shell>cd ../build +shell>cmake ../src + +Note: if a directory was used for in-source build, out-of-source will +not work. To reenable out-of-source build, remove <source-root>/CMakeCache.txt +file. + + +CONFIGURATION PARAMETERS +--------------------------------------------------------------- +The procedure above will build with default configuration. + +Let's you want to change the configuration parameters and have archive +storage engine compiled into the server instead of building it as pluggable +module. + +1)You can provide parameters on the command line, like + +shell> cmake . -DWITH_ARCHIVE_STORAGE_ENGINE=1 + +This can be done during the initial configuration or any time later. + +Note, that parameters are "sticky", that is they are remebered in the CMake +cache (CMakeCache.txt file in the build directory) + +2) Configuration using cmake-gui (Windows, OSX, or Linux with cmake-gui +installed) + +From the build directory, issue +shell> cmake-gui . + +- Check the WITH_INNOBASE_STORAGE_ENGINE checkbox +- Click on "Configure" button +- Click on "Generate" button +- Close cmake-gui +shell> make + +3)Using ccmake (Unix) +ccmake is curses-based GUI application that provides the same functionality +as cmake-gui. It is less user-friendly compared to cmake-gui but works also +on exotic Unixes like HPUX, AIX or Solaris. + +Besides storage engines, probably the most important parameter from a +developer's point of view is WITH_DEBUG (this allows to build server with +dbug tracing library and with debug compile flags). + +After changing the configuration, recompile using +shell> make + + +Listing configuration parameters +--------------------------------------------------------------- +shell> cmake -L + +Gives a brief overview of important configuration parameters (dump to stdout) + +shell> cmake -LH + +Does the same but also provides a short help text for each parameter. + +shell> cmake -LAH + +Dumps all config parameters (including advanced) to the stdout. + +PACKAGING +--------------------------------------------------------------- +-- Binary distribution -- +Packaging in form of tar.gz archives (or .zip on Windows) is also supported +To create a tar.gz package, + +1)If you're using "generic" Unix build with makefiles + +shell> make package +this will create a tar.gz file in the top level build directory. + +2)On Windows, using "NMake Makefiles" generator + +shell> nmake package + +3)On Windows, using "Visual Studio" generator + +shell> devenv mysql.sln /build relwithdebinfo /project package + +Note On Windows, 7Zip or Winzip must be installed and 7z.exe rsp winzip.exe +need to be in the PATH. + + +Another way to build packages is calling cpack executable directly like +shell> cpack -G TGZ --config CPackConfig.cmake +(-G TGZ is for tar.gz generator, there is also -GZIP) + +-- Source distribution -- +"make dist" target is provided. + +ADDITIONAL MAKE TARGETS: "make install" AND "make test" +---------------------------------------------------------------- +install target also provided for Makefile based generators. Installation +directory can be controlled using configure-time parameter +CMAKE_INSTALL_PREFIX (default is /usr/local. It is also possible to install to +non-configured directory, using + +shell> make install DESTDIR="/some/absolute/path" + +"make test" runs unit tests (uses CTest for it) +"make test-force" runs mysql-test-run.pl tests with --test-force parameter + +FOR PROGRAMMERS: WRITING PLATFORM CHECKS +-------------------------------------------------------------- +If you modify MySQL source and want to add a new platform check,please read +http://www.vtk.org/Wiki/CMake_HowToDoPlatformChecks first. In MySQL, most of +the platform tests are implemented in config.cmake and the template header file +is config.h.cmake + +Bigger chunks of functionality, for example non-trivial macros are implemented +in files <src-root>/cmake subdirectory. + +For people with autotools background, it is important to remember CMake does +not provide autoheader functionality. That is, when you add a check + +CHECK_FUNCTION_EXISTS(foo HAVE_FOO) +to config.cmake, then you will also need to add +#cmakedefine HAVE_FOO 1 +to config.h.cmake + +Troubleshooting platform checks +-------------------------------- +If you suspect that a platform check returned wrong result, examine +<build-root>/CMakeFiles/CMakeError.log and +<build-root>/CMakeFiles/CMakeOutput.log +These files they contain compiler command line, and exact error messages. + +Troubleshooting CMake code +---------------------------------- +While there are advanced flags for cmake like -debug-trycompile and --trace, +a simple and efficient way to debug to add +MESSAGE("interesting variable=${some_invariable}") +to the interesting places in CMakeLists.txt + + +Tips: +- When using Makefile generator it is easy to examine which compiler flags are +used to build. For example, compiler flags for mysqld are in +<build-root>/sql/CMakeFiles/mysqld.dir/flags.make and the linker command line +is in <build-root>/sql/CMakeFiles/mysqld.dir/link.txt + +- CMake caches results of platform checks in CMakeCache.txt. It is a nice +feature because tests do not rerun when reconfiguring (e.g when a new test was +added).The downside of caching is that when a platform test was wrong and was +later corrected, the cached result is still used. If you encounter this +situation, which should be a rare occation, you need either to remove the +offending entry from CMakeCache.txt (if test was for HAVE_FOO, remove lines +containing HAVE_FOO from CMakeCache.txt) or just remove the cache file. |