Commit c14e0840 authored by Jonathan Perkin's avatar Jonathan Perkin

kent's recent changes to this file resulted in flag loss due to

the way cmake parses, in particular CMAKE_SIZEOF_VOID_P was
uninitialized during the first parse, and the bad values were
cached.

Pull in SIZEOF_VOIDP macro from package_name.cmake, define some
useful variables, and clean up the file a bit with explicit
definitions, to hopefully avoid this problem in the future.
parent 271fcfaf
......@@ -17,6 +17,16 @@
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckTypeSize)
# XXX package_name.cmake uses this too, move it somewhere global
CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP)
IF(SIZEOF_VOIDP EQUAL 4)
SET(32BIT 1)
ENDIF()
IF(SIZEOF_VOIDP EQUAL 8)
SET(64BIT 1)
ENDIF()
SET(FEATURE_SET "community" CACHE STRING
" Selection of features. Options are
......@@ -78,7 +88,7 @@ IF(FEATURE_SET)
SET(WITH_${eng}_STORAGE_ENGINE OFF CACHE BOOL "")
ELSE()
SET(WITH_${eng}_STORAGE_ENGINE ON CACHE BOOL "")
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
......@@ -86,7 +96,6 @@ OPTION(ENABLED_LOCAL_INFILE "" ON)
SET(WITH_SSL bundled CACHE STRING "")
SET(WITH_ZLIB bundled CACHE STRING "")
IF(NOT COMPILATION_COMMENT)
SET(COMPILATION_COMMENT "MySQL Community Server (GPL)")
ENDIF()
......@@ -117,59 +126,62 @@ IF(UNIX)
ENDIF()
# Compiler options
IF(UNIX)
# Defaults if not set at all
SET(OPT_FLG "-O")
SET(DBG_FLG "-g")
SET(COMMON_CFLAGS "")
SET(COMMON_CXXFLAGS "")
IF(UNIX)
# Default GCC flags
IF(CMAKE_COMPILER_IS_GNUC)
SET(COMMON_C_FLAGS "-g -static-libgcc -fno-omit-frame-pointer")
SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}")
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(OPT_FLG "-O3")
SET(DBG_FLG "-O")
SET(COMMON_CFLAGS "-static-libgcc -g -fno-omit-frame-pointer")
SET(COMMON_CXXFLAGS "${COMMON_CFLAGS} -fno-implicit-templates -felide-constructors -fno-exceptions -fno-rtti")
SET(COMMON_CXX_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-implicit-templates -felide-constructors -fno-exceptions -fno-rtti")
SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
ENDIF()
# HPUX flags
IF(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
IF(CMAKE_C_COMPILER_ID MATCHES "HP")
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
SET(OPT_FLG "+O2")
SET(DBG_FLG "+O0")
SET(COMMON_CFLAGS "+DD64 +DSitanium2 -mt -AC99")
SET(COMMON_CXXFLAGS "+DD64 +DSitanium2 -mt -Aa")
SET(COMMON_C_FLAGS "+DSitanium2 -mt -AC99")
SET(COMMON_CXX_FLAGS "+DSitanium2 -mt -Aa")
SET(CMAKE_C_FLAGS_DEBUG "+O0 -g ${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "+O0 -g ${COMMON_CXX_FLAGS}")
# We have seen compiler bugs with optimisation and -g, so disabled for now
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_CXX_FLAGS}")
ENDIF()
ENDIF()
SET(WITH_SSL no)
SET(WITH_SSL)
ENDIF()
# Linux flags
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(CMAKE_C_COMPILER_ID MATCHES "Intel")
SET(OPT_FLG "-O3 -unroll2 -ip")
SET(DBG_FLG "")
SET(COMMON_CFLAGS "-static-intel -static-libgcc -g -mp -restrict")
SET(COMMON_CXXFLAGS "${COMMON_CFLAGS} -fno-implicit-templates -fno-exceptions -fno-rtti")
SET(WITH_SSL no)
SET(COMMON_C_FLAGS "-static-intel -static-libgcc -g -mp -restrict")
SET(COMMON_CXX_FLAGS "-static-intel -static-libgcc -g -mp -restrict -fno-implicit-templates -fno-exceptions -fno-rtti")
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
SET(COMMON_CFLAGS "${COMMON_CFLAGS} -no-ftz -no-prefetch")
SET(COMMON_CXXFLAGS "${COMMON_CXXFLAGS} -no-ftz -no-prefetch")
SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -no-ftz -no-prefetch")
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -no-ftz -no-prefetch")
ENDIF()
SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_CXX_FLAGS}")
SET(WITH_SSL no)
ENDIF()
ENDIF()
# OSX flags
IF(APPLE)
SET(OPT_FLG "-Os")
SET(DBG_FLG "-O")
SET(COMMON_CFLAGS "-g -fno-common")
SET(COMMON_CXXFLAGS "-g -felide-constructors -fno-common")
SET(COMMON_C_FLAGS "-g -fno-common")
SET(COMMON_CXX_FLAGS "-g -fno-common -felide-constructors -fno-implicit-templates -fno-exceptions -fno-rtti")
SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os ${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os ${COMMON_CXX_FLAGS}")
ENDIF()
# Solaris flags
......@@ -179,42 +191,49 @@ IF(UNIX)
SET(WITH_MYSQLD_LDFLAGS "-lmtmalloc" CACHE STRING "")
ENDIF()
IF(CMAKE_C_COMPILER_ID MATCHES "SunPro")
SET(DBG_FLG "")
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
# Solaris x86
SET(OPT_FLG "-xO2")
ELSE()
# Solaris x86_64
SET(OPT_FLG "-xO3")
SET(COMMON_C_FLAGS "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic")
SET(COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic")
SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
IF(32BIT)
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_CXX_FLAGS}")
ELSEIF(64BIT)
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
ENDIF()
SET(COMMON_CFLAGS
"-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic")
SET(COMMON_CXXFLAGS
"-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic")
ELSE()
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
# Solaris sparc 32 bit
SET(OPT_FLG "-xO3")
SET(COMMON_CFLAGS "-g -Xa -xstrconst -mt -xarch=sparc")
SET(COMMON_CXXFLAGS "-g0 -noex -mt -xarch=sparc")
ELSE()
# Solaris sparc 64 bit
SET(OPT_FLG "-xO3")
SET(COMMON_CFLAGS "-g -Xa -xstrconst -mt")
SET(COMMON_CXXFLAGS "-g0 -noex -mt")
ENDIF()
# Assume !x86 is SPARC
SET(COMMON_C_FLAGS "-g -Xa -xstrconst -mt")
SET(COMMON_CXX_FLAGS "-g0 -noex -mt")
IF(32BIT)
SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -xarch=sparc")
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -xarch=sparc")
ENDIF()
SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
ENDIF()
ENDIF()
ENDIF()
SET(CMAKE_CXX_FLAGS_RELEASE "${OPT_FLG} ${COMMON_CXXFLAGS}")
SET(CMAKE_C_FLAGS_RELEASE "${OPT_FLG} ${COMMON_CFLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${OPT_FLG} ${COMMON_CXXFLAGS}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${OPT_FLG} ${COMMON_CFLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "${DBG_FLG} ${COMMON_CXXFLAGS}")
SET(CMAKE_C_FLAGS_DEBUG "${DBG_FLG} ${COMMON_CFLAGS}")
IF(CMAKE_C_FLAGS_DEBUG)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}"
CACHE STRING "Debug C compile flags")
ENDIF()
IF(CMAKE_CXX_FLAGS_DEBUG)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}"
CACHE STRING "Debug C++ compile flags")
ENDIF()
IF(CMAKE_C_FLAGS_RELWITHDEBINFO)
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}"
CACHE STRING "RelWithDebInfo C compile flags")
ENDIF()
IF(CMAKE_CXX_FLAGS_RELWITHDEBINFO)
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
CACHE STRING "RelWithDebInfo C++ compile flags")
ENDIF()
ENDIF()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment