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 @@ ...@@ -17,6 +17,16 @@
INCLUDE(CheckIncludeFiles) INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists) 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 SET(FEATURE_SET "community" CACHE STRING
" Selection of features. Options are " Selection of features. Options are
...@@ -78,7 +88,7 @@ IF(FEATURE_SET) ...@@ -78,7 +88,7 @@ IF(FEATURE_SET)
SET(WITH_${eng}_STORAGE_ENGINE OFF CACHE BOOL "") SET(WITH_${eng}_STORAGE_ENGINE OFF CACHE BOOL "")
ELSE() ELSE()
SET(WITH_${eng}_STORAGE_ENGINE ON CACHE BOOL "") SET(WITH_${eng}_STORAGE_ENGINE ON CACHE BOOL "")
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
...@@ -86,7 +96,6 @@ OPTION(ENABLED_LOCAL_INFILE "" ON) ...@@ -86,7 +96,6 @@ OPTION(ENABLED_LOCAL_INFILE "" ON)
SET(WITH_SSL bundled CACHE STRING "") SET(WITH_SSL bundled CACHE STRING "")
SET(WITH_ZLIB bundled CACHE STRING "") SET(WITH_ZLIB bundled CACHE STRING "")
IF(NOT COMPILATION_COMMENT) IF(NOT COMPILATION_COMMENT)
SET(COMPILATION_COMMENT "MySQL Community Server (GPL)") SET(COMPILATION_COMMENT "MySQL Community Server (GPL)")
ENDIF() ENDIF()
...@@ -117,59 +126,62 @@ IF(UNIX) ...@@ -117,59 +126,62 @@ IF(UNIX)
ENDIF() ENDIF()
# Compiler options # Compiler options
IF(UNIX) IF(UNIX)
# Defaults if not set at all
SET(OPT_FLG "-O")
SET(DBG_FLG "-g")
SET(COMMON_CFLAGS "")
SET(COMMON_CXXFLAGS "")
# Default GCC flags # 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) IF(CMAKE_COMPILER_IS_GNUCXX)
SET(OPT_FLG "-O3") SET(COMMON_CXX_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-implicit-templates -felide-constructors -fno-exceptions -fno-rtti")
SET(DBG_FLG "-O") SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}")
SET(COMMON_CFLAGS "-static-libgcc -g -fno-omit-frame-pointer") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
SET(COMMON_CXXFLAGS "${COMMON_CFLAGS} -fno-implicit-templates -felide-constructors -fno-exceptions -fno-rtti")
ENDIF() ENDIF()
# HPUX flags # HPUX flags
IF(CMAKE_SYSTEM_NAME MATCHES "HP-UX") IF(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
IF(CMAKE_C_COMPILER_ID MATCHES "HP") IF(CMAKE_C_COMPILER_ID MATCHES "HP")
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64") IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
SET(OPT_FLG "+O2") SET(COMMON_C_FLAGS "+DSitanium2 -mt -AC99")
SET(DBG_FLG "+O0") SET(COMMON_CXX_FLAGS "+DSitanium2 -mt -Aa")
SET(COMMON_CFLAGS "+DD64 +DSitanium2 -mt -AC99") SET(CMAKE_C_FLAGS_DEBUG "+O0 -g ${COMMON_C_FLAGS}")
SET(COMMON_CXXFLAGS "+DD64 +DSitanium2 -mt -Aa") 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()
ENDIF() ENDIF()
SET(WITH_SSL no) SET(WITH_SSL)
ENDIF() ENDIF()
# Linux flags # Linux flags
IF(CMAKE_SYSTEM_NAME MATCHES "Linux") IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(CMAKE_C_COMPILER_ID MATCHES "Intel") IF(CMAKE_C_COMPILER_ID MATCHES "Intel")
SET(OPT_FLG "-O3 -unroll2 -ip") SET(COMMON_C_FLAGS "-static-intel -static-libgcc -g -mp -restrict")
SET(DBG_FLG "") SET(COMMON_CXX_FLAGS "-static-intel -static-libgcc -g -mp -restrict -fno-implicit-templates -fno-exceptions -fno-rtti")
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)
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64") IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
SET(COMMON_CFLAGS "${COMMON_CFLAGS} -no-ftz -no-prefetch") SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -no-ftz -no-prefetch")
SET(COMMON_CXXFLAGS "${COMMON_CXXFLAGS} -no-ftz -no-prefetch") SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -no-ftz -no-prefetch")
ENDIF() 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()
ENDIF() ENDIF()
# OSX flags # OSX flags
IF(APPLE) IF(APPLE)
SET(OPT_FLG "-Os") SET(COMMON_C_FLAGS "-g -fno-common")
SET(DBG_FLG "-O") SET(COMMON_CXX_FLAGS "-g -fno-common -felide-constructors -fno-implicit-templates -fno-exceptions -fno-rtti")
SET(COMMON_CFLAGS "-g -fno-common") SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}")
SET(COMMON_CXXFLAGS "-g -felide-constructors -fno-common") 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() ENDIF()
# Solaris flags # Solaris flags
...@@ -179,42 +191,49 @@ IF(UNIX) ...@@ -179,42 +191,49 @@ IF(UNIX)
SET(WITH_MYSQLD_LDFLAGS "-lmtmalloc" CACHE STRING "") SET(WITH_MYSQLD_LDFLAGS "-lmtmalloc" CACHE STRING "")
ENDIF() ENDIF()
IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") IF(CMAKE_C_COMPILER_ID MATCHES "SunPro")
SET(DBG_FLG "")
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386") IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
IF(CMAKE_SIZEOF_VOID_P EQUAL 4) SET(COMMON_C_FLAGS "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic")
# Solaris x86 SET(COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic")
SET(OPT_FLG "-xO2") SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
ELSE() SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
# Solaris x86_64 IF(32BIT)
SET(OPT_FLG "-xO3") 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() 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() ELSE()
IF(CMAKE_SIZEOF_VOID_P EQUAL 4) # Assume !x86 is SPARC
# Solaris sparc 32 bit SET(COMMON_C_FLAGS "-g -Xa -xstrconst -mt")
SET(OPT_FLG "-xO3") SET(COMMON_CXX_FLAGS "-g0 -noex -mt")
SET(COMMON_CFLAGS "-g -Xa -xstrconst -mt -xarch=sparc") IF(32BIT)
SET(COMMON_CXXFLAGS "-g0 -noex -mt -xarch=sparc") SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -xarch=sparc")
ELSE() SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -xarch=sparc")
# Solaris sparc 64 bit ENDIF()
SET(OPT_FLG "-xO3") SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
SET(COMMON_CFLAGS "-g -Xa -xstrconst -mt") SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
SET(COMMON_CXXFLAGS "-g0 -noex -mt") SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}")
ENDIF() SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
ENDIF() ENDIF()
ENDIF() ENDIF()
ENDIF() ENDIF()
SET(CMAKE_CXX_FLAGS_RELEASE "${OPT_FLG} ${COMMON_CXXFLAGS}") IF(CMAKE_C_FLAGS_DEBUG)
SET(CMAKE_C_FLAGS_RELEASE "${OPT_FLG} ${COMMON_CFLAGS}") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}"
CACHE STRING "Debug C compile flags")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${OPT_FLG} ${COMMON_CXXFLAGS}") ENDIF()
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${OPT_FLG} ${COMMON_CFLAGS}") IF(CMAKE_CXX_FLAGS_DEBUG)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}"
SET(CMAKE_CXX_FLAGS_DEBUG "${DBG_FLG} ${COMMON_CXXFLAGS}") CACHE STRING "Debug C++ compile flags")
SET(CMAKE_C_FLAGS_DEBUG "${DBG_FLG} ${COMMON_CFLAGS}") 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() 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