Improve the compiler flags for the cmake build system. -fPIC only needs to be specified for static libraries that are linked into shared libraries. cmake automatically uses -fPIC for shared libraries. Also ported several other needed compiler flags from the scons build. Set up the debug build, enabled with "-D CMAKE_BUILD_TYPE=Release", to work with wxWidgets debugging.

Note that most users will want to use the release build to get a -O3 optimized build.  This can be enabled by adding "-D CMAKE_BUILD_TYPE=Release".


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6344 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-11-05 02:23:24 +00:00
parent 49a9efb010
commit 2383e2b0f5
6 changed files with 38 additions and 15 deletions

View File

@ -30,24 +30,33 @@ endif()
include(FindPkgConfig REQUIRED) # TODO: Make this optional or even implement our own package detection
# Various compile flags - TODO: Can these be simplified with a more general CMake variable?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g")
# Various compile flags
add_definitions(-msse2 -Wall)
# gcc uses some optimizations which might break stuff without this flag
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
add_definitions(-fno-strict-aliasing)
add_definitions(-DFILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-fvisibility-inlines-hidden VISIBILITY_INLINES_HIDDEN)
if(VISIBILITY_INLINES_HIDDEN)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden)
endif(VISIBILITY_INLINES_HIDDEN)
if(UNIX)
# UNIX needs -fPIC for shared libraries, TODO: Would -fpic be enough as well?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif(UNIX)
CHECK_CXX_COMPILER_FLAG(-fvisibility=hidden VISIBILITY_HIDDEN)
if(VISIBILITY_HIDDEN)
add_definitions(-fvisibility=hidden)
endif(VISIBILITY_HIDDEN)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-D_DEBUG -ggdb)
set(wxWidgets_USE_DEBUG ON CACHE BOOL "Use wxWidgets Debugging")
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE STREQUAL Release)
add_definitions(-fomit-frame-pointer)
endif(CMAKE_BUILD_TYPE STREQUAL Release)
########################################
# Dependency checking
@ -171,7 +180,6 @@ endif(XRANDR_FOUND)
#
include_directories(Source/PluginSpecs)
include_directories(Externals)
include_directories(.) # config.h, TODO: Move to Source? Or just add the corresponding definitions to the compiler flags?
include_directories(Source/Core/AudioCommon/Src)
include_directories(Source/Core/Common/Src)
include_directories(Source/Core/Core/Src)

View File

@ -36,3 +36,6 @@ endif()
add_library(audiocommon STATIC ${SRCS})
target_link_libraries(audiocommon ${LIBS})
if(UNIX)
add_definitions(-fPIC)
endif(UNIX)

View File

@ -40,3 +40,6 @@ if(WIN32)
endif(WIN32)
add_library(common STATIC ${SRCS})
if(UNIX)
add_definitions(-fPIC)
endif(UNIX)

View File

@ -23,3 +23,6 @@ set(SRCS Src/assemble.cpp
Src/Jit/DSPJitMisc.cpp)
add_library(dspcore STATIC ${SRCS})
if(UNIX)
add_definitions(-fPIC)
endif(UNIX)

View File

@ -3,3 +3,6 @@ set(SRCS Src/CodeView.cpp
Src/MemoryView.cpp)
add_library(debugger_ui_util STATIC ${SRCS})
if(UNIX)
add_definitions(-fPIC)
endif(UNIX)

View File

@ -39,3 +39,6 @@ if(OPENCL_FOUND)
endif(OPENCL_FOUND)
add_library(videocommon STATIC ${SRCS})
if(UNIX)
add_definitions(-fPIC)
endif(UNIX)