mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
WL#5161: Implement Mats' suggestion of moving OS specific CMake code to OS specific files, instead of
polluting code with IF(CMAKE_SYSTEM_NAME MATCHES...), first on Windows. cmake/libutils.cmake: Fix the case in MERGE_LIBRARIES, where there is no dependency on OS libraries. cmake/os/Windows.cmake: Move windows specific code to cmake/os/Windows.cmake configure.cmake: Move some Windows code to cmake/os/Windows.cmake
This commit is contained in:
@ -61,6 +61,25 @@ ENDIF()
|
|||||||
|
|
||||||
PROJECT(MySQL)
|
PROJECT(MySQL)
|
||||||
|
|
||||||
|
# Include the platform-specific file. To allow exceptions, this code
|
||||||
|
# looks for files in order of how specific they are. If there is, for
|
||||||
|
# example, a generic Linux.cmake and a version-specific
|
||||||
|
# Linux-2.6.28-11-generic, it will pick Linux-2.6.28-11-generic and
|
||||||
|
# include it. It is then up to the file writer to include the generic
|
||||||
|
# version if necessary.
|
||||||
|
FOREACH(_base
|
||||||
|
${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}-${CMAKE_SYSTEM_PROCESSOR}
|
||||||
|
${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}
|
||||||
|
${CMAKE_SYSTEM_NAME})
|
||||||
|
SET(_file ${CMAKE_SOURCE_DIR}/cmake/os/${_base}.cmake)
|
||||||
|
IF(EXISTS ${_file})
|
||||||
|
INCLUDE(${_file})
|
||||||
|
BREAK()
|
||||||
|
ENDIF()
|
||||||
|
ENDFOREACH()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Following autotools tradition, add preprocessor definitions
|
# Following autotools tradition, add preprocessor definitions
|
||||||
# specified in environment variable CPPFLAGS
|
# specified in environment variable CPPFLAGS
|
||||||
IF(DEFINED ENV{CPPFLAGS})
|
IF(DEFINED ENV{CPPFLAGS})
|
||||||
@ -71,12 +90,6 @@ IF(CYGWIN)
|
|||||||
SET(WIN32 0)
|
SET(WIN32 0)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(WIN32)
|
|
||||||
SET(IF_WIN 0)
|
|
||||||
ELSE()
|
|
||||||
SET(IF_WIN 1)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# Add macros
|
# Add macros
|
||||||
INCLUDE(character_sets)
|
INCLUDE(character_sets)
|
||||||
INCLUDE(zlib)
|
INCLUDE(zlib)
|
||||||
@ -163,8 +176,6 @@ IF(WITH_DEBUG OR WITH_DEBUG_FULL AND NOT WIN32)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Set commonly used variables
|
# Set commonly used variables
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(DEFAULT_MYSQL_HOME "C:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}" )
|
SET(DEFAULT_MYSQL_HOME "C:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}" )
|
||||||
@ -184,12 +195,6 @@ IF(SYSCONFDIR)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
# Optionally read user configuration, generated by configure.js.
|
|
||||||
# This is left for backward compatibility reasons only.
|
|
||||||
IF(WIN32)
|
|
||||||
INCLUDE(win/configure.data OPTIONAL)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# Run platform tests
|
# Run platform tests
|
||||||
INCLUDE(configure.cmake)
|
INCLUDE(configure.cmake)
|
||||||
|
|
||||||
|
@ -22,4 +22,6 @@ EXTRA_DIST = \
|
|||||||
dtrace_prelink.cmake \
|
dtrace_prelink.cmake \
|
||||||
versioninfo.rc.in \
|
versioninfo.rc.in \
|
||||||
mysql_add_executable.cmake \
|
mysql_add_executable.cmake \
|
||||||
install_layout.cmake
|
install_layout.cmake \
|
||||||
|
build_configurations/mysql_release.cmake \
|
||||||
|
os/Windows.cmake
|
||||||
|
@ -155,8 +155,10 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
LIST(REMOVE_DUPLICATES OSLIBS)
|
IF(OSLIBS)
|
||||||
TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS})
|
LIST(REMOVE_DUPLICATES OSLIBS)
|
||||||
|
TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# Make the generated dummy source file depended on all static input
|
# Make the generated dummy source file depended on all static input
|
||||||
# libs. If input lib changes,the source file is touched
|
# libs. If input lib changes,the source file is touched
|
||||||
|
183
cmake/os/Windows.cmake
Normal file
183
cmake/os/Windows.cmake
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
# Copyright (C) 2009 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
|
||||||
|
|
||||||
|
# This file includes Windows specific hacks, mostly around compiler flags
|
||||||
|
|
||||||
|
INCLUDE (CheckCSourceCompiles)
|
||||||
|
INCLUDE (CheckCXXSourceCompiles)
|
||||||
|
INCLUDE (CheckStructHasMember)
|
||||||
|
INCLUDE (CheckLibraryExists)
|
||||||
|
INCLUDE (CheckFunctionExists)
|
||||||
|
INCLUDE (CheckCCompilerFlag)
|
||||||
|
INCLUDE (CheckCSourceRuns)
|
||||||
|
INCLUDE (CheckSymbolExists)
|
||||||
|
INCLUDE (CheckTypeSize)
|
||||||
|
|
||||||
|
# Optionally read user configuration, generated by configure.js.
|
||||||
|
# This is left for backward compatibility reasons only.
|
||||||
|
INCLUDE(win/configure.data OPTIONAL)
|
||||||
|
|
||||||
|
# OS display name (version_compile_os etc).
|
||||||
|
# Used by the test suite to ignore bugs on some platforms,
|
||||||
|
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||||
|
SET(SYSTEM_TYPE "Win64")
|
||||||
|
ELSE()
|
||||||
|
SET(SYSTEM_TYPE "Win32")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
# Intel compiler is almost Visual C++
|
||||||
|
# (same compile flags etc). Set MSVC flag
|
||||||
|
IF(CMAKE_C_COMPILER MATCHES "icl")
|
||||||
|
SET(MSVC TRUE)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE")
|
||||||
|
ADD_DEFINITIONS("-D_WIN32_WINNT=0x0501")
|
||||||
|
# Speed up build process excluding unused header files
|
||||||
|
ADD_DEFINITIONS("-DWIN32_LEAN_AND_MEAN")
|
||||||
|
|
||||||
|
# Adjust compiler and linker flags
|
||||||
|
IF(MINGW AND CMAKE_SIZEOF_VOIDP EQUAL 4)
|
||||||
|
# mininal architecture flags, i486 enables GCC atomics
|
||||||
|
ADD_DEFINITIONS(-march=i486)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF(MSVC)
|
||||||
|
# Enable debug info also in Release build, and create PDB to be able to analyze
|
||||||
|
# crashes
|
||||||
|
FOREACH(lang C CXX)
|
||||||
|
SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Zi")
|
||||||
|
ENDFOREACH()
|
||||||
|
FOREACH(type EXE SHARED MODULE)
|
||||||
|
SET(CMAKE_{type}_LINKER_FLAGS_RELEASE "${CMAKE_${type}_LINKER_FLAGS_RELEASE} /debug")
|
||||||
|
ENDFOREACH()
|
||||||
|
|
||||||
|
# Force static runtime libraries, and remove support for exception handling
|
||||||
|
FOREACH(flag
|
||||||
|
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||||
|
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT
|
||||||
|
CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||||
|
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT)
|
||||||
|
STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}")
|
||||||
|
STRING(REPLACE "/EHsc" "" "${flag}" "${${flag}}")
|
||||||
|
ENDFOREACH()
|
||||||
|
|
||||||
|
# Fix CMake's predefined huge stack size
|
||||||
|
FOREACH(type EXE SHARED MODULE)
|
||||||
|
STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}")
|
||||||
|
ENDFOREACH()
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DPTHREAD_STACK_MIN=1048576)
|
||||||
|
# Mark 32 bit executables large address aware so they can
|
||||||
|
# use > 2GB address space
|
||||||
|
IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
|
||||||
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
# Speed up multiprocessor build
|
||||||
|
IF (MSVC_VERSION GREATER 1400)
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
#TODO: update the code and remove the disabled warnings
|
||||||
|
IF (MSVC_VERSION GREATER 1310)
|
||||||
|
ADD_DEFINITIONS(/wd4800 /wd4805)
|
||||||
|
ADD_DEFINITIONS(/wd4996)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
SET (PLATFORM X86)
|
||||||
|
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||||
|
# _WIN64 is defined by the compiler itself.
|
||||||
|
# Yet, we define it here again to work around a bug with Intellisense
|
||||||
|
# described here: http://tinyurl.com/2cb428.
|
||||||
|
# Syntax highlighting is important for proper debugger functionality.
|
||||||
|
ADD_DEFINITIONS("-D_WIN64")
|
||||||
|
SET (PLATFORM X64)
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
# Always link with socket library
|
||||||
|
LINK_LIBRARIES(ws2_32)
|
||||||
|
# ..also for tests
|
||||||
|
SET(CMAKE_REQUIRED_LIBRARIES ws2_32)
|
||||||
|
|
||||||
|
# System checks
|
||||||
|
SET(SIGNAL_WITH_VIO_CLOSE 1) # Something that runtime team needs
|
||||||
|
|
||||||
|
# IPv6 constants appeared in Vista SDK first. We need to define them in any case if they are
|
||||||
|
# not in headers, to handle dual mode sockets correctly.
|
||||||
|
CHECK_SYMBOL_EXISTS(IPPROTO_IPV6 "winsock2.h" HAVE_IPPROTO_IPV6)
|
||||||
|
IF(NOT HAVE_IPPROTO_IPV6)
|
||||||
|
SET(HAVE_IPPROTO_IPV6 41)
|
||||||
|
ENDIF()
|
||||||
|
CHECK_SYMBOL_EXISTS(IPV6_V6ONLY "winsock2.h;ws2ipdef.h" HAVE_IPV6_V6ONLY)
|
||||||
|
IF(NOT HAVE_IPV6_V6ONLY)
|
||||||
|
SET(IPV6_V6ONLY 27)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
# Some standard functions exist there under different
|
||||||
|
# names (e.g popen is _popen or strok_r is _strtok_s)
|
||||||
|
# If a replacement function exists, HAVE_FUNCTION is
|
||||||
|
# defined to 1. CMake variable <function_name> will also
|
||||||
|
# be defined to the replacement name.
|
||||||
|
# So for example, CHECK_FUNCTION_REPLACEMENT(popen _popen)
|
||||||
|
# will define HAVE_POPEN to 1 and set variable named popen
|
||||||
|
# to _popen. If the header template, one needs to have
|
||||||
|
# cmakedefine popen @popen@ which will expand to
|
||||||
|
# define popen _popen after CONFIGURE_FILE
|
||||||
|
|
||||||
|
MACRO(CHECK_FUNCTION_REPLACEMENT function replacement)
|
||||||
|
STRING(TOUPPER ${function} function_upper)
|
||||||
|
CHECK_FUNCTION_EXISTS(${function} HAVE_${function_upper})
|
||||||
|
IF(NOT HAVE_${function_upper})
|
||||||
|
CHECK_FUNCTION_EXISTS(${replacement} HAVE_${replacement})
|
||||||
|
IF(HAVE_${replacement})
|
||||||
|
SET(HAVE_${function_upper} 1 )
|
||||||
|
SET(${function} ${replacement})
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
ENDMACRO()
|
||||||
|
MACRO(CHECK_SYMBOL_REPLACEMENT symbol replacement header)
|
||||||
|
STRING(TOUPPER ${symbol} symbol_upper)
|
||||||
|
CHECK_SYMBOL_EXISTS(${symbol} ${header} HAVE_${symbol_upper})
|
||||||
|
IF(NOT HAVE_${symbol_upper})
|
||||||
|
CHECK_SYMBOL_EXISTS(${replacement} ${header} HAVE_${replacement})
|
||||||
|
IF(HAVE_${replacement})
|
||||||
|
SET(HAVE_${symbol_upper} 1)
|
||||||
|
SET(${symbol} ${replacement})
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
ENDMACRO()
|
||||||
|
|
||||||
|
CHECK_SYMBOL_REPLACEMENT(S_IROTH _S_IREAD sys/stat.h)
|
||||||
|
CHECK_SYMBOL_REPLACEMENT(S_IFIFO _S_IFIFO sys/stat.h)
|
||||||
|
CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h)
|
||||||
|
CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h)
|
||||||
|
CHECK_SYMBOL_REPLACEMENT(isnan _isnan float.h)
|
||||||
|
CHECK_SYMBOL_REPLACEMENT(finite _finite float.h)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(popen _popen)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(pclose _pclose)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(access _access)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(strcasecmp _stricmp)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(strncasecmp _strnicmp)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(snprintf _snprintf)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(strtok_r strtok_s)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(strtoll _strtoi64)
|
||||||
|
CHECK_FUNCTION_REPLACEMENT(strtoull _strtoui64)
|
||||||
|
CHECK_TYPE_SIZE(ssize_t SIZE_OF_SSIZE_T)
|
||||||
|
IF(NOT HAVE_SIZE_OF_SSIZE_T)
|
||||||
|
SET(ssize_t SSIZE_T)
|
||||||
|
ENDIF()
|
196
configure.cmake
196
configure.cmake
@ -46,6 +46,7 @@ ENDIF()
|
|||||||
|
|
||||||
#
|
#
|
||||||
# Tests for OS
|
# Tests for OS
|
||||||
|
#
|
||||||
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
SET(TARGET_OS_LINUX 1)
|
SET(TARGET_OS_LINUX 1)
|
||||||
SET(HAVE_NPTL 1)
|
SET(HAVE_NPTL 1)
|
||||||
@ -54,17 +55,8 @@ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
|||||||
SET(TARGET_OS_SOLARIS 1)
|
SET(TARGET_OS_SOLARIS 1)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
# System type affects version_compile_os variable
|
||||||
# OS display name (version_compile_os etc).
|
IF(NOT SYSTEM_TYPE)
|
||||||
# Used by the test suite to ignore bugs on some platforms,
|
|
||||||
# typically on Windows.
|
|
||||||
IF(WIN32)
|
|
||||||
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
|
||||||
SET(SYSTEM_TYPE "Win64")
|
|
||||||
ELSE()
|
|
||||||
SET(SYSTEM_TYPE "Win32")
|
|
||||||
ENDIF()
|
|
||||||
ELSE()
|
|
||||||
IF(PLATFORM)
|
IF(PLATFORM)
|
||||||
SET(SYSTEM_TYPE ${PLATFORM})
|
SET(SYSTEM_TYPE ${PLATFORM})
|
||||||
ELSE()
|
ELSE()
|
||||||
@ -73,12 +65,6 @@ ELSE()
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
# Intel compiler is almost Visual C++
|
|
||||||
# (same compile flags etc). Set MSVC flag
|
|
||||||
IF(WIN32 AND CMAKE_C_COMPILER MATCHES "icl")
|
|
||||||
SET(MSVC TRUE)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
SET(CMAKE_CXX_FLAGS
|
SET(CMAKE_CXX_FLAGS
|
||||||
"${CMAKE_CXX_FLAGS} -fno-implicit-templates -fno-exceptions -fno-rtti")
|
"${CMAKE_CXX_FLAGS} -fno-implicit-templates -fno-exceptions -fno-rtti")
|
||||||
@ -89,10 +75,6 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
|
|||||||
SET(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION TRUE)
|
SET(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION TRUE)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
IF(MINGW AND CMAKE_SIZEOF_VOIDP EQUAL 4)
|
|
||||||
# mininal architecture flags, i486 enables GCC atomics
|
|
||||||
ADD_DEFINITIONS(-march=i486)
|
|
||||||
ENDIF()
|
|
||||||
IF(APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET)
|
IF(APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||||
# Workaround linker problems on OSX 10.4
|
# Workaround linker problems on OSX 10.4
|
||||||
IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.5")
|
IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.5")
|
||||||
@ -116,16 +98,6 @@ IF(CMAKE_SYSTEM_NAME MATCHES "AIX" OR CMAKE_SYSTEM_NAME MATCHES "OS400")
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IF(MSVC)
|
|
||||||
# Enable debug info also in Release build, and create PDB to be able to analyze
|
|
||||||
# crashes
|
|
||||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
|
|
||||||
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi")
|
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /debug")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(CMAKE_GENERATOR MATCHES "Visual Studio 7")
|
IF(CMAKE_GENERATOR MATCHES "Visual Studio 7")
|
||||||
# VS2003 has a bug that prevents linking mysqld with module definition file
|
# VS2003 has a bug that prevents linking mysqld with module definition file
|
||||||
# (/DEF option for linker). Linker would incorrectly complain about multiply
|
# (/DEF option for linker). Linker would incorrectly complain about multiply
|
||||||
@ -181,69 +153,6 @@ IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
|||||||
ADD_DEFINITIONS(-DHAVE_RWLOCK_T)
|
ADD_DEFINITIONS(-DHAVE_RWLOCK_T)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Disable warnings in Visual Studio 8 and above
|
|
||||||
IF(MSVC AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7")
|
|
||||||
#TODO: update the code and remove the disabled warnings
|
|
||||||
ADD_DEFINITIONS(/wd4800 /wd4805)
|
|
||||||
ADD_DEFINITIONS(/wd4996)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
|
|
||||||
# Settings for Visual Studio 7 and above.
|
|
||||||
IF(MSVC)
|
|
||||||
# replace /MDd with /MTd
|
|
||||||
STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
|
|
||||||
STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
|
|
||||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
|
||||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT ${CMAKE_C_FLAGS_DEBUG_INIT})
|
|
||||||
|
|
||||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
|
||||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
|
|
||||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
|
||||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
|
|
||||||
|
|
||||||
# generate map files, set stack size (see bug#20815)
|
|
||||||
SET(thread_stack_size 1048576)
|
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:${thread_stack_size}")
|
|
||||||
ADD_DEFINITIONS(-DPTHREAD_STACK_MIN=${thread_stack_size})
|
|
||||||
|
|
||||||
# remove support for Exception handling
|
|
||||||
STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
||||||
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
||||||
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
|
|
||||||
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
|
|
||||||
|
|
||||||
# Mark 32 bit executables large address aware so they can
|
|
||||||
# use > 2GB address space
|
|
||||||
IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
|
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
|
|
||||||
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 4)
|
|
||||||
ENDIF(MSVC)
|
|
||||||
|
|
||||||
IF(WIN32)
|
|
||||||
ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE")
|
|
||||||
ADD_DEFINITIONS("-D_WIN32_WINNT=0x0501")
|
|
||||||
# Speed up build process excluding unused header files
|
|
||||||
ADD_DEFINITIONS("-DWIN32_LEAN_AND_MEAN")
|
|
||||||
IF (MSVC_VERSION GREATER 1400)
|
|
||||||
# Speed up multiprocessor build
|
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# default to x86 platform. We'll check for X64 in a bit
|
|
||||||
SET (PLATFORM X86)
|
|
||||||
IF(MSVC AND CMAKE_SIZEOF_VOID_P MATCHES 8)
|
|
||||||
# _WIN64 is defined by the compiler itself.
|
|
||||||
# Yet, we define it here again to work around a bug with Intellisense
|
|
||||||
# described here: http://tinyurl.com/2cb428.
|
|
||||||
# Syntax highlighting is important for proper debugger functionality.
|
|
||||||
ADD_DEFINITIONS("-D_WIN64")
|
|
||||||
SET (PLATFORM X64)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Figure out what engines to build and how (statically or dynamically),
|
# Figure out what engines to build and how (statically or dynamically),
|
||||||
# add preprocessor defines for storage engines.
|
# add preprocessor defines for storage engines.
|
||||||
@ -252,15 +161,6 @@ IF(WITHOUT_DYNAMIC_PLUGINS)
|
|||||||
ENDIF(WITHOUT_DYNAMIC_PLUGINS)
|
ENDIF(WITHOUT_DYNAMIC_PLUGINS)
|
||||||
|
|
||||||
|
|
||||||
# Perform machine tests on posix platforms only
|
|
||||||
IF(WIN32)
|
|
||||||
SET(SYSTEM_LIBS ws2_32)
|
|
||||||
SET(CMAKE_REQUIRED_INCLUDES "winsock2.h;ws2tcpip.h")
|
|
||||||
SET(CMAKE_REQUIRED_DEFINITONS "-D_WIN32_WINNT=0x0501")
|
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32)
|
|
||||||
LINK_LIBRARIES(ws2_32)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# Searches function in libraries
|
# Searches function in libraries
|
||||||
# if function is found, sets output parameter result to the name of the library
|
# if function is found, sets output parameter result to the name of the library
|
||||||
# if function is found in libc, result will be empty
|
# if function is found in libc, result will be empty
|
||||||
@ -345,43 +245,12 @@ IF(CMAKE_OSX_SYSROOT)
|
|||||||
SET(ENV{MACOSX_DEPLOYMENT_TARGET} ${OSX_DEPLOYMENT_TARGET})
|
SET(ENV{MACOSX_DEPLOYMENT_TARGET} ${OSX_DEPLOYMENT_TARGET})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# This macro is used only on Windows at the moment
|
|
||||||
# Some standard functions exist there under different
|
|
||||||
# names (e.g popen is _popen or strok_r is _strtok_s)
|
|
||||||
# If a replacement function exists, HAVE_FUNCTION is
|
|
||||||
# defined to 1. CMake variable <function_name> will also
|
|
||||||
# be defined to the replacement name.
|
|
||||||
# So for example, CHECK_FUNCTION_REPLACEMENT(popen _popen)
|
|
||||||
# will define HAVE_POPEN to 1 and set variable named popen
|
|
||||||
# to _popen. If the header template, one needs to have
|
|
||||||
# cmakedefine popen @popen@ which will expand to
|
|
||||||
# define popen _popen after CONFIGURE_FILE
|
|
||||||
|
|
||||||
MACRO(CHECK_FUNCTION_REPLACEMENT function replacement)
|
|
||||||
STRING(TOUPPER ${function} function_upper)
|
|
||||||
CHECK_FUNCTION_EXISTS(${function} HAVE_${function_upper})
|
|
||||||
IF(NOT HAVE_${function_upper})
|
|
||||||
CHECK_FUNCTION_EXISTS(${replacement} HAVE_${replacement})
|
|
||||||
IF(HAVE_${replacement})
|
|
||||||
SET(HAVE_${function_upper} 1 )
|
|
||||||
SET(${function} ${replacement})
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
MACRO(CHECK_SYMBOL_REPLACEMENT symbol replacement header)
|
|
||||||
STRING(TOUPPER ${symbol} symbol_upper)
|
|
||||||
CHECK_SYMBOL_EXISTS(${symbol} ${header} HAVE_${symbol_upper})
|
|
||||||
IF(NOT HAVE_${symbol_upper})
|
|
||||||
CHECK_SYMBOL_EXISTS(${replacement} ${header} HAVE_${replacement})
|
|
||||||
IF(HAVE_${replacement})
|
|
||||||
SET(HAVE_${symbol_upper} 1)
|
|
||||||
SET(${symbol} ${replacement})
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
|
|
||||||
|
# System check macros that do nothing on Windows.
|
||||||
|
# Very often, it is known that some function is not available
|
||||||
|
# on Windows. In such cases it makes sense to use these macros
|
||||||
|
# as build with Visual Studio is considerably faster if irrelevant
|
||||||
|
# checks are omitted.
|
||||||
MACRO(CHECK_INCLUDE_FILES_UNIX INCLUDES VAR)
|
MACRO(CHECK_INCLUDE_FILES_UNIX INCLUDES VAR)
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
CHECK_INCLUDE_FILES ("${INCLUDES}" ${VAR})
|
CHECK_INCLUDE_FILES ("${INCLUDES}" ${VAR})
|
||||||
@ -1333,52 +1202,3 @@ CHECK_STRUCT_HAS_MEMBER("struct dirent" d_ino "dirent.h" STRUCT_DIRENT_HAS_D_IN
|
|||||||
CHECK_STRUCT_HAS_MEMBER("struct dirent" d_namlen "dirent.h" STRUCT_DIRENT_HAS_D_NAMLEN)
|
CHECK_STRUCT_HAS_MEMBER("struct dirent" d_namlen "dirent.h" STRUCT_DIRENT_HAS_D_NAMLEN)
|
||||||
SET(SPRINTF_RETURNS_INT 1)
|
SET(SPRINTF_RETURNS_INT 1)
|
||||||
|
|
||||||
IF(WIN32)
|
|
||||||
SET(SIGNAL_WITH_VIO_CLOSE 1)
|
|
||||||
CHECK_SYMBOL_REPLACEMENT(S_IROTH _S_IREAD sys/stat.h)
|
|
||||||
CHECK_SYMBOL_REPLACEMENT(S_IFIFO _S_IFIFO sys/stat.h)
|
|
||||||
CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h)
|
|
||||||
CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h)
|
|
||||||
CHECK_SYMBOL_REPLACEMENT(isnan _isnan float.h)
|
|
||||||
CHECK_SYMBOL_REPLACEMENT(finite _finite float.h)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(popen _popen)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(pclose _pclose)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(access _access)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(strcasecmp _stricmp)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(strncasecmp _strnicmp)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(snprintf _snprintf)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(strtok_r strtok_s)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(strtoll _strtoi64)
|
|
||||||
CHECK_FUNCTION_REPLACEMENT(strtoull _strtoui64)
|
|
||||||
CHECK_TYPE_SIZE(ssize_t SIZE_OF_SSIZE_T)
|
|
||||||
IF(NOT SIZE_OF_SSIZE_T)
|
|
||||||
SET(ssize_t SSIZE_T)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
|
|
||||||
# IPv6 definition (appeared in Vista SDK first)
|
|
||||||
CHECK_C_SOURCE_COMPILES("
|
|
||||||
#include <winsock2.h>
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return IPPROTO_IPV6;
|
|
||||||
}"
|
|
||||||
HAVE_IPPROTO_IPV6)
|
|
||||||
|
|
||||||
CHECK_C_SOURCE_COMPILES("
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2ipdef.h>
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return IPV6_V6ONLY;
|
|
||||||
}"
|
|
||||||
HAVE_IPV6_V6ONLY)
|
|
||||||
|
|
||||||
IF(NOT HAVE_IPPROTO_IPV6)
|
|
||||||
SET(HAVE_IPPROTO_IPV6 41)
|
|
||||||
ENDIF()
|
|
||||||
IF(NOT HAVE_IPV6_V6ONLY)
|
|
||||||
SET(IPV6_V6ONLY 27)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
ENDIF(WIN32)
|
|
||||||
|
Reference in New Issue
Block a user