Only use -O1 GCC optimization level for versions 4.7 and above for now.

This commit is contained in:
Wayne Stambaugh 2012-10-15 21:42:50 -04:00
parent 2dc8c27ec2
commit e7925279ab
1 changed files with 33 additions and 12 deletions

View File

@ -16,7 +16,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
# KiCad build options should be added below. # KiCad build options should be added below.
# #
# If you add a new build option, please add it's state to the CopyVersionInfoToClipboard() # If you add a new build option, please add it's state to the CopyVersionInfoToClipboard()
# function in common/basicframe.cpp so that build option settings can be includeed in bug # function in common/basicframe.cpp so that build option settings can be included in bug
# reports. # reports.
# #
@ -103,6 +103,13 @@ endif( USE_PCBNEW_SEXPR_FILE_FORMAT AND NOT USE_PCBNEW_NANOMETRES )
#================================================ #================================================
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
set(KICAD_GCC_RELEASE_BUILD_FLAGS "-O2")
set(KICAD_GCC_RELEASE_DEBUG_FLAGS "")
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Added -Wno-narrowing on 10/7/12 to prevent a huge number of warnings when # Added -Wno-narrowing on 10/7/12 to prevent a huge number of warnings when
# compiling with GCC 4.7. This appears to be caused by and int to unsigned # compiling with GCC 4.7. This appears to be caused by and int to unsigned
# conversion in the Boost polygon library. At some point in the future when # conversion in the Boost polygon library. At some point in the future when
@ -114,24 +121,40 @@ if(CMAKE_COMPILER_IS_GNUCXX)
# the -O2 level with GCC 4.7 (works fine with with GCC 4.6). # the -O2 level with GCC 4.7 (works fine with with GCC 4.6).
# This lower optimization level does not have a significant change on the speed. # This lower optimization level does not have a significant change on the speed.
# #
# As newer versions of GCC and/or Boost are released, this code needs reviewed to
# determine if the problems above have been fixed either in Boost or GCC.
if(GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
set(KICAD_GCC_RELEASE_BUILD_FLAGS "-Wno-narrowing -O1")
set(KICAD_GCC_DEBUG_BUILD_FLAGS "-Wno-narrowing")
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
message(STATUS
"Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_DEBUG_BUILD_FLAGS}\"")
else(CMAKE_BUILD_TYPE STREQUAL Debug)
message(STATUS
"Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_RELEASE_BUILD_FLAGS}\"")
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
if(WIN32) # under Windows/mingw, -fPIC option is enabled by default if(WIN32) # under Windows/mingw, -fPIC option is enabled by default
# Set default flags for Release build. # Set default flags for Release build.
set(CMAKE_C_FLAGS_RELEASE "-Wall -Wno-narrowing -O1 -DNDEBUG") set(CMAKE_C_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-Wall -Wno-narrowing -O1 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
# Set default flags for Debug build. # Set default flags for Debug build.
set(CMAKE_C_FLAGS_DEBUG "-Wall -Wno-narrowing -g3 -ggdb3 -DDEBUG") set(CMAKE_C_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wno-narrowing -g3 -ggdb3 -DDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG")
else(WIN32) else(WIN32)
# Set default flags for Release build. # Set default flags for Release build.
set(CMAKE_C_FLAGS_RELEASE "-Wall -O1 -DNDEBUG -fPIC") set(CMAKE_C_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS}1 -DNDEBUG -fPIC")
set(CMAKE_CXX_FLAGS_RELEASE "-Wall -O1 -DNDEBUG -fPIC") set(CMAKE_CXX_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS}1 -DNDEBUG -fPIC")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
# Set default flags for Debug build. # Set default flags for Debug build.
set(CMAKE_C_FLAGS_DEBUG "-Wall -Wno-narrowing -g3 -ggdb3 -DDEBUG -fPIC") set(CMAKE_C_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wno-narrowing -g3 -ggdb3 -DDEBUG -fPIC") set(CMAKE_CXX_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG -fPIC")
endif(WIN32) endif(WIN32)
endif(CMAKE_COMPILER_IS_GNUCXX) endif(CMAKE_COMPILER_IS_GNUCXX)
@ -162,8 +185,6 @@ endif(KICAD_SCRIPTING_MODULES)
if(KICAD_SCRIPTING_WXPYTHON) if(KICAD_SCRIPTING_WXPYTHON)
add_definitions(-DKICAD_SCRIPTING_WXPYTHON) add_definitions(-DKICAD_SCRIPTING_WXPYTHON)
endif(KICAD_SCRIPTING_WXPYTHON) endif(KICAD_SCRIPTING_WXPYTHON)
if(USE_WX_GRAPHICS_CONTEXT) if(USE_WX_GRAPHICS_CONTEXT)
@ -171,7 +192,7 @@ if(USE_WX_GRAPHICS_CONTEXT)
endif(USE_WX_GRAPHICS_CONTEXT) endif(USE_WX_GRAPHICS_CONTEXT)
# Allow user to override the default settings for adding images to menu items. By default # Allow user to override the default settings for adding images to menu items. By default
# images in menu items are enabled on all plaforms except OSX. This can be over ridden by # images in menu items are enabled on all platforms except OSX. This can be over ridden by
# defining -DUSE_IMAGES_IN_MENUS=ON/OFF to force the preferred behavior. # defining -DUSE_IMAGES_IN_MENUS=ON/OFF to force the preferred behavior.
if(NOT DEFINED USE_IMAGES_IN_MENUS) if(NOT DEFINED USE_IMAGES_IN_MENUS)
if(NOT APPLE) if(NOT APPLE)