diff options
author | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2014-10-13 09:52:28 +0200 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2014-10-13 09:52:28 +0200 |
commit | 8b64f825058a2439903e9420552641ca6105d9d6 (patch) | |
tree | 5e4595b95c1636b3a7f3d889de96da08676d4b19 /CMakeLists.txt | |
parent | a3cc647dbdbdeb0f2e9c9ac55ffe062c659d82dc (diff) | |
download | mariadb-git-8b64f825058a2439903e9420552641ca6105d9d6.tar.gz |
Bug#17633291: SET PROPER COMPILE OPTIONS FOR CLANG
Bug#17959689: MAKE GCC AND CLANG GIVE CONSISTENT COMPILATION WARNINGS
Bug#18313717: ENABLE -WERROR IN MAINTANER MODE WHEN COMPILING WITH CLANG
Bug#18510941: REMOVE CMAKE WORKAROUNDS FOR OLDER VERSIONS OF OS X/XCODE
Backport from mysql-5.6 to mysql-5.5
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 92 |
1 files changed, 53 insertions, 39 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f43473f76a5..8ce5f4734c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,10 +27,12 @@ ENDIF() # We use the LOCATION target property (CMP0026) # and get_target_property() for non-existent targets (CMP0045) +# and INSTALL_NAME_DIR (CMP0042) IF(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR CMAKE_VERSION VERSION_GREATER "3.0.0") CMAKE_POLICY(SET CMP0026 OLD) CMAKE_POLICY(SET CMP0045 OLD) + CMAKE_POLICY(SET CMP0042 OLD) ENDIF() MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") @@ -73,11 +75,9 @@ ENDIF() SET(BUILDTYPE_DOCSTRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel") - + IF(WITH_DEBUG) SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE) - SET(MYSQL_MAINTAINER_MODE ON CACHE BOOL - "MySQL maintainer-specific development environment") IF(UNIX AND NOT APPLE) # Compiling with PIC speeds up embedded build, on PIC sensitive systems # Predefine it to ON, in case user chooses to build embedded. @@ -107,6 +107,15 @@ ELSE() ENDIF() PROJECT(${MYSQL_PROJECT_NAME}) +# Maintainer mode is default on only for Linux debug builds using GCC/G++ +IF(CMAKE_BUILD_TYPE MATCHES "Debug" OR WITH_DEBUG) + IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND + CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX) + SET(MYSQL_MAINTAINER_MODE ON CACHE BOOL + "MySQL maintainer-specific development environment") + ENDIF() +ENDIF() + IF(BUILD_CONFIG) INCLUDE( ${CMAKE_SOURCE_DIR}/cmake/build_configurations/${BUILD_CONFIG}.cmake) @@ -130,38 +139,12 @@ FOREACH(_base ENDFOREACH() - # Following autotools tradition, add preprocessor definitions # specified in environment variable CPPFLAGS IF(DEFINED ENV{CPPFLAGS}) ADD_DEFINITIONS($ENV{CPPFLAGS}) ENDIF() -# -# Control aspects of the development environment which are -# specific to MySQL maintainers and developers. -# -INCLUDE(maintainer) - -OPTION(MYSQL_MAINTAINER_MODE - "MySQL maintainer-specific development environment" OFF) - -# Whether the maintainer mode compiler options should be enabled. -IF(MYSQL_MAINTAINER_MODE) - IF(CMAKE_C_COMPILER_ID MATCHES "GNU") - SET_MYSQL_MAINTAINER_GNU_C_OPTIONS() - ENDIF() - IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS() - ENDIF() - IF(CMAKE_C_COMPILER_ID MATCHES "Intel") - SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS() - ENDIF() - IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS() - ENDIF() -ENDIF() - # Add macros INCLUDE(character_sets) INCLUDE(zlib) @@ -192,7 +175,6 @@ OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON) MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED) - include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) # We need some extra FAIL_REGEX patterns @@ -373,13 +355,13 @@ MYSQL_CHECK_READLINE() # not run with the warning options as to not perturb fragile checks # (i.e. do not make warnings into errors). # -IF(MYSQL_MAINTAINER_MODE) - # Set compiler flags required under maintainer mode. - MESSAGE(STATUS "C warning options: ${MY_MAINTAINER_C_WARNINGS}") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}") - MESSAGE(STATUS "C++ warning options: ${MY_MAINTAINER_CXX_WARNINGS}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}") -ENDIF() +# Why doesn't these flags affect the entire build? +# Because things may already have been included with ADD_SUBDIRECTORY +# +OPTION(MYSQL_MAINTAINER_MODE + "MySQL maintainer-specific development environment" OFF) + +INCLUDE(maintainer) IF(NOT WITHOUT_SERVER) SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "") @@ -395,7 +377,6 @@ ADD_SUBDIRECTORY(regex) ADD_SUBDIRECTORY(mysys) ADD_SUBDIRECTORY(libmysql) - IF(WITH_UNIT_TESTS) ENABLE_TESTING() ENDIF() @@ -487,7 +468,6 @@ IF(NOT INSTALL_LAYOUT MATCHES "RPM") ) INSTALL(FILES README DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme) INSTALL(FILES ${CMAKE_BINARY_DIR}/Docs/INFO_SRC ${CMAKE_BINARY_DIR}/Docs/INFO_BIN DESTINATION ${INSTALL_DOCDIR}) - IF(UNIX) INSTALL(FILES Docs/INSTALL-BINARY DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme) ENDIF() @@ -507,3 +487,37 @@ IF(NOT INSTALL_LAYOUT MATCHES "RPM") ENDIF() INCLUDE(CPack) + +# C compiler flags consist of: +# CPPFLAGS Taken from environment, see above. +# ADD_DEFINITIONS In each individual CMakeLists.txt +# CMAKE_C_FLAGS From command line. +# We extend these in maintainer.cmake +# ENV{CFLAGS} From environment, but environment is ignored if +# CMAKE_C_FLAGS is also given on command line +# CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} +# We extend these in compiler_options.cmake +# +# Note that CMakeCache.txt contains cmake builtins for these variables, +# *not* the values that will actually be used: + +IF(CMAKE_GENERATOR MATCHES "Makefiles") + MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") +ENDIF() +GET_PROPERTY(cwd_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS) +MESSAGE(STATUS "COMPILE_DEFINITIONS: ${cwd_definitions}") +MESSAGE(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") +MESSAGE(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") +IF(CMAKE_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Makefiles") + STRING(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKEBT) + MESSAGE(STATUS "CMAKE_C_FLAGS_${CMAKEBT}: ${CMAKE_C_FLAGS_${CMAKEBT}}") + MESSAGE(STATUS "CMAKE_CXX_FLAGS_${CMAKEBT}: ${CMAKE_CXX_FLAGS_${CMAKEBT}}") +ENDIF() +IF(NOT CMAKE_GENERATOR MATCHES "Makefiles") + MESSAGE(STATUS "CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}") + MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") + MESSAGE(STATUS + "CMAKE_C_FLAGS_RELWITHDEBINFO: ${CMAKE_C_FLAGS_RELWITHDEBINFO}") + MESSAGE(STATUS + "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") +ENDIF() |