summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorVladislav Vaintroub <vvaintroub@mysql.com>2010-01-24 16:23:16 +0100
committerVladislav Vaintroub <vvaintroub@mysql.com>2010-01-24 16:23:16 +0100
commitc827968a2df5ad35e64cea0116abf862776cef26 (patch)
treec43eba4b5b19fd0edbb74db874eadf3a2a91f9c7 /cmake
parent80f57fb2524bfd451c603bce92ad061d85b42aae (diff)
downloadmariadb-git-c827968a2df5ad35e64cea0116abf862776cef26.tar.gz
Handle different installation layouts.
using cmake option INSTALL_LAYOUT=STANDALONE would produce the layout as in tar.gz or zip packages. INSTALL_LAYOUT=UNIX will produce unixish install layout (with mysqld being in sbin subdirectory , libs in lib/mysql etc). This layout is used for RPM packages. Subtle differences in both packages unfortunately lead to the need to recompile MySQL to use with other package type - as otherwise for example default plugins or data directories would be wrong set. There are numerous other variables that allow fine-tuning packaging layout. (INSTALL_BINDIR, INSTALL_LIBDIR , INSTALL_PLUGINDIR etc). This options are different from autotools as they do not expect full paths to directories, but only subdirectory of CMAKE_INSTALL_PREFIX. There are 2 special options that expect full directory paths - MYSQL_DATADIR that defines default MYSQL data directory (autotools equivalent is --localstatedir) - SYSCONFDIR can be added to search my.cnf search path (autotools equivalent is --sysconfdir)
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Makefile.am3
-rw-r--r--cmake/configure.pl7
-rwxr-xr-xcmake/install_layout.cmake128
-rw-r--r--cmake/libutils.cmake2
-rw-r--r--cmake/mysql_add_executable.cmake7
-rw-r--r--cmake/plugin.cmake3
6 files changed, 143 insertions, 7 deletions
diff --git a/cmake/Makefile.am b/cmake/Makefile.am
index d072178d1b9..600cd442f6f 100644
--- a/cmake/Makefile.am
+++ b/cmake/Makefile.am
@@ -21,4 +21,5 @@ EXTRA_DIST = \
merge_archives_unix.cmake.in \
dtrace_prelink.cmake \
versioninfo.rc.in \
- mysql_add_executable.cmake
+ mysql_add_executable.cmake \
+ install_layout.cmake
diff --git a/cmake/configure.pl b/cmake/configure.pl
index 3768b046530..f52435e2cde 100644
--- a/cmake/configure.pl
+++ b/cmake/configure.pl
@@ -11,7 +11,6 @@ my $srcdir = dirname(dirname(abs_path($0)));
foreach my $option (@ARGV)
{
-
if (substr ($option, 0, 2) == "--")
{
$option = substr($option, 2);
@@ -83,6 +82,12 @@ foreach my $option (@ARGV)
$cmakeargs = $cmakeargs." -DWITH_CHARSETS=complex";
next;
}
+ if ($option =~ /localstatedir=/)
+ {
+ $cmakeargs = $cmakeargs." -DMYSQL_DATADIR=".substr($option,14);
+ next;
+ }
+
$option = uc($option);
$option =~ s/-/_/g;
$cmakeargs = $cmakeargs." -D".$option."=1";
diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake
new file mode 100755
index 00000000000..b1a285a0695
--- /dev/null
+++ b/cmake/install_layout.cmake
@@ -0,0 +1,128 @@
+# Copyright (C) 2010 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+# The purpose of this file is to set the default installation layout.
+# Currently, there are 2 different installation layouts ,
+# one is used in tar.gz packages (Windows zip is about the same), another one
+# in RPMs.
+
+# There are currently 2 layouts defines, named STANDALONE (tar.gz layout)
+# and UNIX (rpm layout). To force a directory layout when invoking cmake use
+# -DINSTALL_LAYOUT=[STANDALONE|UNIX].
+# This wil use a predefined layout. There is a possibility to further fine-tune
+# installation directories. Several variables are can be overwritten
+#
+# - INSTALL_BINDIR (directory with client executables and Unix shell scripts)
+# - INSTALL_SBINDIR (directory with mysqld)
+# - INSTALL_LIBDIR (directory with client end embedded libraries)
+# - INSTALL_PLUGINDIR (directory for plugins)
+# - INSTALL_INCLUDEDIR (directory for MySQL headers)
+# - INSTALL_DOCDIR (documentation)
+# - INSTALL_MANDIR (man pages)
+# - INSTALL_SCRIPTDIR (several scripts, rarely used)
+# - INSTALL_MYSQLSHAREDIR (MySQL character sets and localized error messages)
+# - INSTALL_SHAREDIR (location of aclocal/mysql.m4)
+# - INSTALL_SQLBENCHDIR (sql-bench)
+# - INSTALL_MYSQLTESTDIR (mysql-test)
+# - INSTALL_DOCREADMEDIR (readme and similar)
+# - INSTALL_SUPPORTFILESDIR (used only in standalone installer)
+
+# Default installation layout on Unix is UNIX (kent wants it so)
+IF(NOT INSTALL_LAYOUT)
+ IF(WIN32)
+ SET(DEFAULT_INSTALL_LAYOUT "STANDALONE")
+ ELSE()
+ SET(DEFAULT_INSTALL_LAYOUT "UNIX")
+ ENDIF()
+ENDIF()
+
+SET(INSTALL_LAYOUT "${DEFAULT_INSTALL_LAYOUT}"
+CACHE STRING "Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer) or UNIX")
+
+IF(NOT INSTALL_LAYOUT MATCHES "STANDALONE")
+ IF(NOT INSTALL_LAYOUT MATCHES "UNIX")
+ SET(INSTALL_LAYOUT "${DEFAULT_INSTALL_LAYOUT}")
+ ENDIF()
+ENDIF()
+
+IF(UNIX)
+ IF(INSTALL_LAYOUT MATCHES "UNIX")
+ SET(default_prefix "/usr")
+ ELSE()
+ SET(default_prefix "/usr/local/mysql")
+ ENDIF()
+ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ SET(CMAKE_INSTALL_PREFIX ${default_prefix}
+ CACHE PATH "install prefix" FORCE)
+ ENDIF()
+ SET(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc"
+ CACHE PATH "config directory (for my.cnf)")
+ MARK_AS_ADVANCED(SYSCONFDIR)
+ENDIF()
+
+
+
+ # STANDALONE layout
+ SET(INSTALL_BINDIR_STANDALONE "bin")
+ SET(INSTALL_SBINDIR_STANDALONE "bin")
+ SET(INSTALL_LIBDIR_STANDALONE "lib")
+ SET(INSTALL_INCLUDEDIR_STANDALONE "include")
+ SET(INSTALL_PLUGINDIR_STANDALONE "lib/plugin")
+ SET(INSTALL_DOCDIR_STANDALONE "doc")
+ SET(INSTALL_MANDIR_STANDALONE "man")
+ SET(INSTALL_MYSQLSHAREDIR_STANDALONE "share")
+ SET(INSTALL_SHAREDIR_STANDALONE "share")
+ SET(INSTALL_SCRIPTDIR_STANDALONE "scripts")
+ SET(INSTALL_MYSQLTESTDIR_STANDALONE "mysql-test")
+ SET(INSTALL_SQLBENCHROOTDIR_STANDALONE ".")
+ SET(INSTALL_DOCREADMEDIR_STANDALONE ".")
+ SET(INSTALL_SUPPORTFILESDIR_STANDALONE "support-files")
+ SET(INSTALL_MYSQLDATADIR_STANDALONE "data")
+
+ # UNIX layout
+ SET(INSTALL_BINDIR_UNIX "bin")
+ SET(INSTALL_SBINDIR_UNIX "sbin")
+ SET(INSTALL_LIBDIR_UNIX "lib/mysql")
+ SET(INSTALL_PLUGINDIR_UNIX "lib/mysql/plugin")
+ SET(INSTALL_DOCDIR_UNIX "share/mysql/doc/MySQL-server-${MYSQL_NO_DASH_VERSION}")
+ SET(INSTALL_MANDIR_UNIX "share/mysql/man")
+ SET(INSTALL_INCLUDEDIR_UNIX "include/mysql")
+ SET(INSTALL_MYSQLSHAREDIR_UNIX "share/mysql")
+ SET(INSTALL_SHAREDIR_UNIX "share")
+ SET(INSTALL_SCRIPTDIR_UNIX "bin")
+ SET(INSTALL_MYSQLTESTDIR_UNIX "mysql-test")
+ SET(INSTALL_SQLBENCHROOTDIR_UNIX "")
+ SET(INSTALL_DOCREADMEDIR_UNIX "share/mysql/doc/MySQL-server-${MYSQL_NO_DASH_VERSION}")
+ SET(INSTALL_SUPPORTFILESDIR_UNIX "")
+ SET(INSTALL_MYSQLDATADIR_STANDALONE "var")
+
+
+# Clear cached variables if install layout was changed
+IF(OLD_INSTALL_LAYOUT)
+ IF(NOT OLD_INSTALL_LAYOUT STREQUAL INSTALL_LAYOUR)
+ SET(FORCE FORCE)
+ ENDIF()
+ENDIF()
+SET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL "")
+
+# Set INSTALL_FOODIR variables for chosen layout
+# (for example, INSTALL_BINDIR will be defined as
+# ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE layout is chosen)
+FOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN
+ MYSQLTEST SQLBENCHROOT DOCREADME SUPPORTFILES MYSQLDATA)
+ SET(INSTALL_${var}DIR ${INSTALL_${var}DIR_${INSTALL_LAYOUT}}
+ CACHE STRING "${var} installation directory" ${FORCE})
+ MARK_AS_ADVANCED(INSTALL_${var}DIR)
+ENDFOREACH()
diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake
index ff74809d224..677504f89af 100644
--- a/cmake/libutils.cmake
+++ b/cmake/libutils.cmake
@@ -257,7 +257,7 @@ MACRO(MERGE_LIBRARIES)
MESSAGE(FATAL_ERROR "Unknown library type")
ENDIF()
IF(NOT ARG_NOINSTALL)
- MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION lib)
+ MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION "${INSTALL_LIBDIR}")
ENDIF()
ENDMACRO()
diff --git a/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake
index cb0237332c2..2157d03e6d1 100644
--- a/cmake/mysql_add_executable.cmake
+++ b/cmake/mysql_add_executable.cmake
@@ -29,7 +29,7 @@ INCLUDE(cmake_parse_arguments)
FUNCTION (MYSQL_ADD_EXECUTABLE)
# Pass-through arguments for ADD_EXECUTABLE
CMAKE_PARSE_ARGUMENTS(ARG
- "WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL"
+ "WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL;DESTINATION"
""
${ARGN}
)
@@ -41,6 +41,9 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
# tell CPack where to install
IF(NOT ARG_EXCLUDE_FROM_ALL)
- MYSQL_INSTALL_TARGETS(${target} DESTINATION bin)
+ IF(NOT ARG_DESTINATION)
+ SET(ARG_DESTINATION ${INSTALL_BINDIR})
+ ENDIF()
+ MYSQL_INSTALL_TARGETS(${target} DESTINATION ${ARG_DESTINATION})
ENDIF()
ENDFUNCTION() \ No newline at end of file
diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake
index b9169ebb73e..f312cd2d4e8 100644
--- a/cmake/plugin.cmake
+++ b/cmake/plugin.cmake
@@ -162,8 +162,7 @@ MACRO(MYSQL_ADD_PLUGIN)
SET_TARGET_PROPERTIES(${target} PROPERTIES
OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}")
# Install dynamic library
- SET(INSTALL_LOCATION lib/plugin)
- MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_LOCATION})
+ MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR})
ENDIF()
ENDMACRO()