CMakeLists.txt 7.61 KB
Newer Older
1 2
# Copyright (c) 2006, 2016, Oracle and/or its affiliates.
# Copyright (c) 2012, 2017, MariaDB
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# 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

IF(WIN32)
  SET(localstatedir "C:\\\\mysql\\\\data\\\\")
  SET(ini_file_extension "ini")
ELSE()
  SET(localstatedir "${MYSQL_DATADIR}")
  SET(prefix "${CMAKE_INSTALL_PREFIX}")
23 24
  SET(libexecdir ${INSTALL_SBINDIRABS})
  SET(bindir ${INSTALL_BINDIRABS})
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
  SET(sbindir "${libexecdir}")
  SET(datadir "${MYSQL_DATADIR}")
  SET(CC ${CMAKE_C_COMPILER})
  SET(CXX ${CMAKE_CXX_COMPILER})
  SET(CFLAGS ${CMAKE_C_FLAGS})
  SET(CXXFLAGS ${CMAKE_CXX_FLAGS})
  SET(MYSQLD_USER "mysql")
  SET(ini_file_extension "cnf")
  SET(HOSTNAME "hostname")
ENDIF()

# XXX: shouldn't we just have variables for all this stuff and centralise
# XXX: their configuration in install_layout.cmake?
IF(WIN32)
  SET(inst_location ${INSTALL_DOCREADMEDIR})
ELSE()
  SET(inst_location ${INSTALL_SUPPORTFILESDIR})
ENDIF()

44
IF (NOT WITHOUT_SERVER)
45 46
FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small)
  CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh
47 48 49 50
                 ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @ONLY)
  INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension}
          DESTINATION ${inst_location} COMPONENT IniFiles)
ENDFOREACH()
51
ENDIF()
52

53 54 55 56 57 58 59
IF(WITH_WSREP)
  CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/wsrep.cnf.sh
                 ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension} @ONLY)
  INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension}
          DESTINATION ${inst_location} COMPONENT IniFiles)
ENDIF()

60 61
IF(UNIX)
  SET(prefix ${CMAKE_INSTALL_PREFIX})
62
  FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure wsrep_notify)
63 64
    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${script}.sh 
                   ${CMAKE_CURRENT_BINARY_DIR}/${script} @ONLY )
65 66
    INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script}
      DESTINATION ${inst_location} COMPONENT Server_Scripts)
67
  ENDFOREACH()
68

69 70
  IF(INSTALL_SUPPORTFILESDIR)
    INSTALL(FILES magic DESTINATION ${inst_location} COMPONENT SupportFiles)
71
    INSTALL(DIRECTORY policy DESTINATION ${inst_location} COMPONENT SupportFiles)
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    FIND_PROGRAM(CHECKMODULE checkmodule)
    FIND_PROGRAM(SEMODULE_PACKAGE semodule_package)
    MARK_AS_ADVANCED(CHECKMODULE SEMODULE_PACKAGE)

    # Build pp files in policy/selinux
    IF(CHECKMODULE AND SEMODULE_PACKAGE)
      FOREACH(pol mariadb)
        SET(src ${CMAKE_CURRENT_SOURCE_DIR}/policy/selinux/${pol}.te)
        SET(tmp ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${pol}-pp.dir/${pol}.mod)
        SET(out ${CMAKE_CURRENT_BINARY_DIR}/${pol}.pp)
        ADD_CUSTOM_COMMAND(OUTPUT ${out}
          COMMAND ${CHECKMODULE} -M -m ${src} -o ${tmp}
          COMMAND ${SEMODULE_PACKAGE} -m ${tmp} -o ${out}
        DEPENDS ${src})
        ADD_CUSTOM_TARGET(${pol}-pp ALL DEPENDS ${out})
        INSTALL(FILES ${out} DESTINATION ${inst_location}/policy/selinux COMPONENT SupportFiles)
      ENDFOREACH()
    ENDIF()
90 91
  ENDIF()

92 93 94
  CONFIGURE_FILE(mariadb.pc.in ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc @ONLY)
  INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc DESTINATION ${INSTALL_SHAREDIR}/pkgconfig COMPONENT Development)

95 96
  INSTALL(FILES mysql.m4 DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development)
  
97 98 99 100 101
  SET(bindir ${INSTALL_BINDIRABS})
  SET(sbindir ${INSTALL_SBINDIRABS})
  SET(scriptdir ${INSTALL_SCRIPTDIRABS})
  SET(libexecdir ${INSTALL_SBINDIRABS})
  SET(pkgdatadir ${INSTALL_MYSQLSHAREDIRABS})
102 103
  SET(sysconfdir ${INSTALL_SYSCONFDIR})
  SET(sysconf2dir ${INSTALL_SYSCONF2DIR})
104 105
  CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql.server.sh 
                 ${CMAKE_CURRENT_BINARY_DIR}/mysql.server @ONLY)
106 107 108 109 110 111 112 113 114 115
  INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
    DESTINATION ${inst_location} COMPONENT SupportFiles)

  IF(HAVE_SYSTEMD)
    CONFIGURE_FILE(mariadb.service.in
                   ${CMAKE_CURRENT_BINARY_DIR}/mariadb.service @ONLY)
    INSTALL(FILES use_galera_new_cluster.conf
            ${CMAKE_CURRENT_BINARY_DIR}/mariadb.service
            DESTINATION ${inst_location}/systemd COMPONENT SupportFiles)

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
    IF(INSTALL_SYSTEMD_SYSUSERSDIR)
      CONFIGURE_FILE(sysusers.conf.in
              ${CMAKE_CURRENT_BINARY_DIR}/sysusers.conf @ONLY)
      INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/sysusers.conf
              DESTINATION ${INSTALL_SYSTEMD_SYSUSERSDIR} COMPONENT Server)
    ENDIF()

    IF(INSTALL_SYSTEMD_TMPFILESDIR)
      get_filename_component(MYSQL_UNIX_DIR ${MYSQL_UNIX_ADDR} DIRECTORY)
      CONFIGURE_FILE(tmpfiles.conf.in
              ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf @ONLY)
      INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf
              DESTINATION ${INSTALL_SYSTEMD_TMPFILESDIR} COMPONENT Server)
    ENDIF()

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
    # @ in directory name broken between CMake version 2.8.12.2 and 3.3
    # http://public.kitware.com/Bug/view.php?id=14782
    IF(NOT CMAKE_VERSION VERSION_LESS 3.3.0 OR NOT RPM)
      CONFIGURE_FILE(mariadb@.service.in
                     ${CMAKE_CURRENT_BINARY_DIR}/mariadb@.service @ONLY)
      INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb@.service
              DESTINATION ${inst_location}/systemd COMPONENT SupportFiles)
    ENDIF()

    IF(INSTALL_SYSTEMD_UNITDIR)
      INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.service
              DESTINATION ${INSTALL_SYSTEMD_UNITDIR} COMPONENT Server)

      # http://public.kitware.com/Bug/view.php?id=14782
      IF(NOT CMAKE_VERSION VERSION_LESS 3.3.0 OR NOT RPM)
        INSTALL(FILES use_galera_new_cluster.conf
                DESTINATION
                "${INSTALL_SYSTEMD_UNITDIR}/mariadb@bootstrap.service.d"
                COMPONENT Server)
        INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb@.service
                DESTINATION ${INSTALL_SYSTEMD_UNITDIR} COMPONENT Server)
      ENDIF()

    ENDIF()
  ENDIF()
156 157 158 159

  IF (INSTALL_SYSCONFDIR)
    INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d
            RENAME mysql COMPONENT SupportFiles)
160
    INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
161
            DESTINATION  ${INSTALL_SYSCONFDIR}/init.d
162
            RENAME mysql COMPONENT SupportFiles)
163 164 165 166 167 168 169 170 171 172 173

    INSTALL(FILES rpm/my.cnf DESTINATION ${INSTALL_SYSCONFDIR}
            COMPONENT Common)

    IF (INSTALL_SYSCONF2DIR)
      INSTALL(FILES rpm/client.cnf DESTINATION ${INSTALL_SYSCONF2DIR}
              COMPONENT SharedLibraries)
      INSTALL(FILES rpm/mysql-clients.cnf DESTINATION ${INSTALL_SYSCONF2DIR}
              COMPONENT Client)
      INSTALL(FILES rpm/server.cnf DESTINATION ${INSTALL_SYSCONF2DIR}
              COMPONENT IniFiles)
174 175
      INSTALL(FILES rpm/enable_encryption.preset DESTINATION ${INSTALL_SYSCONF2DIR}
              COMPONENT IniFiles)
176 177 178 179 180 181 182 183 184 185
    ENDIF()

    # This is for SuSE:
    INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink
                   ${INSTALL_SYSCONFDIR}/init.d/mysql
                   ${INSTALL_SBINDIR}/rcmysql
                   WORKING_DIRECTORY \$ENV{DESTDIR}${prefix})"
                   COMPONENT SupportFiles)
  ENDIF(INSTALL_SYSCONFDIR)
ENDIF()