diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 134 |
1 files changed, 51 insertions, 83 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b274f80b773..d86004daa9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,10 @@ ELSE() ENDIF() PROJECT(${MYSQL_PROJECT_NAME}) +SET(CPACK_PACKAGE_NAME "MariaDB") +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MariaDB: a very fast and robust SQL database server") +SET(CPACK_PACKAGE_URL "http://mariadb.org") + IF(BUILD_CONFIG) INCLUDE( ${CMAKE_SOURCE_DIR}/cmake/build_configurations/${BUILD_CONFIG}.cmake) @@ -117,7 +121,6 @@ IF(DEFINED ENV{CPPFLAGS}) ENDIF() SET(MYSQL_MAINTAINER_MODE "AUTO" CACHE STRING "MySQL maintainer-specific development environment. Options are: ON OFF AUTO.") -MARK_AS_ADVANCED(MYSQL_MAINTAINER_MODE) # Packaging IF (NOT CPACK_GENERATOR) @@ -135,6 +138,7 @@ INCLUDE(cpack_rpm) INCLUDE(cpack_deb) # Add macros +INCLUDE(wsrep) INCLUDE(character_sets) INCLUDE(cpu_info) INCLUDE(zlib) @@ -157,81 +161,29 @@ IF(DISABLE_SHARED) ENDIF() OPTION(ENABLED_PROFILING "Enable profiling" ON) OPTION(CYBOZU "" OFF) -OPTION(BACKUP_TEST "" OFF) -OPTION(WITHOUT_SERVER OFF) +OPTION(WITHOUT_SERVER "Build only the client library and clients" OFF) IF(UNIX) OPTION(WITH_VALGRIND "Valgrind instrumentation" OFF) ENDIF() OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON) -MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED) +MARK_AS_ADVANCED(CYBOZU) OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system libraries. Only set it you never plan to distribute the resulting binaries" OFF) -include(CheckCSourceCompiles) -include(CheckCXXSourceCompiles) -# We need some extra FAIL_REGEX patterns -# Note that CHECK_C_SOURCE_COMPILES is a misnomer, it will also link. -MACRO (MY_CHECK_C_COMPILER_FLAG FLAG RESULT) - SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") - CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT} - FAIL_REGEX "argument unused during compilation" - FAIL_REGEX "unsupported .*option" - FAIL_REGEX "unknown .*option" - FAIL_REGEX "unrecognized .*option" - FAIL_REGEX "ignoring unknown option" - FAIL_REGEX "[Ww]arning: [Oo]ption" - ) - SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") -ENDMACRO() - -MACRO (MY_CHECK_CXX_COMPILER_FLAG FLAG RESULT) - SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") - CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT} - FAIL_REGEX "argument unused during compilation" - FAIL_REGEX "unsupported .*option" - FAIL_REGEX "unknown .*option" - FAIL_REGEX "unrecognized .*option" - FAIL_REGEX "ignoring unknown option" - FAIL_REGEX "[Ww]arning: [Oo]ption" - ) - SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") -ENDMACRO() +INCLUDE(check_compiler_flag) OPTION(WITH_ASAN "Enable address sanitizer" OFF) IF (WITH_ASAN) # gcc 4.8.1 and new versions of clang - MY_CHECK_C_COMPILER_FLAG("-fsanitize=address" HAVE_C_FSANITIZE) - MY_CHECK_CXX_COMPILER_FLAG("-fsanitize=address" HAVE_CXX_FSANITIZE) - + MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=address -O1 -Wno-error -fPIC" + DEBUG RELWITHDEBINFO) IF(HAVE_C_FSANITIZE AND HAVE_CXX_FSANITIZE) - # We switch on basic optimization also for debug builds. - # With optimization we may get some warnings, so we switch off -Werror - SET(CMAKE_C_FLAGS_DEBUG - "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -O1 -Wno-error -fPIC") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO - "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fsanitize=address -fPIC") - SET(CMAKE_CXX_FLAGS_DEBUG - "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -O1 -Wno-error -fPIC") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO - "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fsanitize=address -fPIC") SET(WITH_ASAN_OK 1) ELSE() # older versions of clang - MY_CHECK_C_COMPILER_FLAG("-faddress-sanitizer" HAVE_C_FADDRESS) - MY_CHECK_CXX_COMPILER_FLAG("-faddress-sanitizer" HAVE_CXX_FFADDRESS) - - IF(HAVE_C_FADDRESS AND HAVE_CXX_FFADDRESS) - # We switch on basic optimization also for debug builds. - SET(CMAKE_C_FLAGS_DEBUG - "${CMAKE_C_FLAGS_DEBUG} -faddress-sanitizer -O1 -fPIC") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO - "${CMAKE_C_FLAGS_RELWITHDEBINFO} -faddress-sanitizer -fPIC") - SET(CMAKE_CXX_FLAGS_DEBUG - "${CMAKE_CXX_FLAGS_DEBUG} -faddress-sanitizer -O1 -fPIC") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO - "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -faddress-sanitizer -fPIC") + MY_CHECK_AND_SET_COMPILER_FLAG("-faddress-sanitizer -O1 -fPIC" + DEBUG RELWITHDEBINFO) + IF(HAVE_C_FADDRESS AND HAVE_CXX_FADDRESS) SET(WITH_ASAN_OK 1) ENDIF() ENDIF() @@ -241,6 +193,21 @@ IF (WITH_ASAN) ENDIF() ENDIF() +# enable security hardening features, like most distributions do +# in our benchmarks that costs about ~1% of performance, depending on the load +IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "4.6") + SET(security_default OFF) +ELSE() + SET(security_default ON) +ENDIF() +OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ${security_default}) +IF(SECURITY_HARDENED) + # security-enhancing flags + MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC") + MY_CHECK_AND_SET_COMPILER_FLAG("-Wl,-z,relro,-z,now") + MY_CHECK_AND_SET_COMPILER_FLAG("-fstack-protector --param=ssp-buffer-size=4") + MY_CHECK_AND_SET_COMPILER_FLAG("-D_FORTIFY_SOURCE=2" RELEASE RELWITHDEBINFO) +ENDIF() OPTION(ENABLE_DEBUG_SYNC "Enable debug sync (debug builds only)" ON) IF(ENABLE_DEBUG_SYNC) @@ -249,25 +216,24 @@ IF(ENABLE_DEBUG_SYNC) ENDIF() OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF) -IF (ENABLE_GCOV AND NOT WIN32 AND NOT APPLE) - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage") - SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov") +IF (ENABLE_GCOV) + MY_CHECK_AND_SET_COMPILER_FLAG("-fprofile-arcs -ftest-coverage -lgcov" DEBUG) ENDIF() -MY_CHECK_C_COMPILER_FLAG(-ggdb3 HAVE_GGDB3) -IF(HAVE_GGDB3) - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3") - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb3") -ENDIF(HAVE_GGDB3) +MY_CHECK_AND_SET_COMPILER_FLAG(-ggdb3 DEBUG) OPTION(ENABLED_LOCAL_INFILE "If we should should enable LOAD DATA LOCAL by default" ${IF_WIN}) -MARK_AS_ADVANCED(ENABLED_LOCAL_INFILE) OPTION(WITH_FAST_MUTEXES "Compile with fast mutexes" OFF) MARK_AS_ADVANCED(WITH_FAST_MUTEXES) +OPTION(WITH_INNODB_DISALLOW_WRITES "InnoDB freeze writes patch from Google" ${WITH_WSREP}) +IF (WITH_INNODB_DISALLOW_WRITES) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_INNODB_DISALLOW_WRITES") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_INNODB_DISALLOW_WRITES") +ENDIF() + # Set DBUG_OFF and other optional release-only flags for non-debug project types FOREACH(BUILD_TYPE RELEASE RELWITHDEBINFO MINSIZEREL) FOREACH(LANG C CXX) @@ -404,9 +370,7 @@ ADD_SUBDIRECTORY(libmysql) ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(extra) ADD_SUBDIRECTORY(libservices) -ADD_SUBDIRECTORY(scripts) ADD_SUBDIRECTORY(sql/share) -ADD_SUBDIRECTORY(support-files) IF(NOT WITHOUT_SERVER) ADD_SUBDIRECTORY(tests) @@ -417,14 +381,13 @@ IF(NOT WITHOUT_SERVER) ADD_SUBDIRECTORY(libmysqld/examples) ENDIF(WITH_EMBEDDED_SERVER) + IF(WITH_WSREP) + ADD_SUBDIRECTORY(wsrep) + ENDIF() + ADD_SUBDIRECTORY(mysql-test) ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess) ADD_SUBDIRECTORY(sql-bench) - - IF(EXISTS ${CMAKE_SOURCE_DIR}/internal/CMakeLists.txt) - ADD_SUBDIRECTORY(internal) - ENDIF() - ADD_SUBDIRECTORY(packaging/rpm-oel) ENDIF() IF(UNIX) @@ -440,6 +403,11 @@ IF(WIN32) ENDIF() ADD_SUBDIRECTORY(packaging/solaris) + +INCLUDE(for_clients) +ADD_SUBDIRECTORY(scripts) +ADD_SUBDIRECTORY(support-files) + IF(NOT CMAKE_CROSSCOMPILING) SET(EXPORTED comp_err comp_sql factorial) IF(NOT WITHOUT_SERVER) @@ -462,8 +430,8 @@ CONFIGURE_FILE( IF(DEB) CONFIGURE_FILE( - ${CMAKE_SOURCE_DIR}/debian/mariadb-server-10.0.files.in - ${CMAKE_SOURCE_DIR}/debian/mariadb-server-10.0.files) + ${CMAKE_SOURCE_DIR}/debian/mariadb-server-10.1.files.in + ${CMAKE_SOURCE_DIR}/debian/mariadb-server-10.1.files) ENDIF(DEB) # Handle the "INFO_*" files. @@ -482,15 +450,15 @@ ADD_CUSTOM_TARGET(INFO_BIN ALL WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) -INSTALL_DOCUMENTATION(README CREDITS COPYING COPYING.LESSER EXCEPTIONS-CLIENT - COMPONENT Readme) - +INSTALL_DOCUMENTATION(README CREDITS COPYING COPYING.LESSER COPYING.thirdparty + EXCEPTIONS-CLIENT COMPONENT Readme) # MDEV-6526 these files are not installed anymore #INSTALL_DOCUMENTATION(${CMAKE_BINARY_DIR}/Docs/INFO_SRC # ${CMAKE_BINARY_DIR}/Docs/INFO_BIN) IF(UNIX) INSTALL_DOCUMENTATION(Docs/INSTALL-BINARY COMPONENT Readme) + INSTALL_DOCUMENTATION(Docs/INSTALL-BINARY Docs/README-wsrep COMPONENT Readme) ENDIF() INCLUDE(CPack) |