Some more work on CMake on Windows:

- add support for precompiled headers with MSVC
- compile with _FILE_OFFSET_BITS=64 and _LARGEFILE_SOURCE only for our sources, some dependencies seem to have problems with it enabled...
- disable -Wall for MSVC too prevent warning flood
- rename aes_cbc.c and aes_core.c to cpp files since it makes stuff a lot easier and there's really no reason not to do it since they had been compiled as C++ before anyway

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6797 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX 2011-01-09 16:36:19 +00:00
parent e6c87cbe3d
commit 81638396c0
7 changed files with 52 additions and 125 deletions

View File

@ -23,13 +23,42 @@ add_definitions(-DLIBS_DIR="${plugindir}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries/plugins)
# Precompiled header support for MSVC:
# Call this after setting the source list (and don't add the source file used to generate the pch file, this will be done here automatically)
function(enable_precompiled_headers PRECOMPILED_HEADER SOURCE_FILE SOURCE_VARIABLE_NAME)
if(MSVC)
set(files ${${SOURCE_VARIABLE_NAME}})
# Generate precompiled header translation unit
get_filename_component(pch_basename ${PRECOMPILED_HEADER} NAME_WE)
set(pch_abs ${CMAKE_CURRENT_SOURCE_DIR}/${PRECOMPILED_HEADER})
set(pch_unity ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE})
set_source_files_properties(${pch_unity} PROPERTIES COMPILE_FLAGS "/Yc\"${pch_abs}\"")
# Update properties of source files to use the precompiled header.
# Additionally, force the inclusion of the precompiled header at beginning of each source file.
foreach(source_file ${files} )
set_source_files_properties(${source_file} PROPERTIES COMPILE_FLAGS "/Yu\"${pch_abs}\" /FI\"${pch_abs}\"")
endforeach(source_file)
# Finally, update the source file collection to contain the precompiled header translation unit
set(${SOURCE_VARIABLE_NAME} ${pch_unity} ${${SOURCE_VARIABLE_NAME}} PARENT_SCOPE)
endif(MSVC)
endfunction(enable_precompiled_headers)
include(FindSubversion OPTIONAL) # for revision info
if(Subversion_FOUND AND NOT DOLPHIN_WC_REVISION)
Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} DOLPHIN) # defines DOLPHIN_WC_REVISION
endif()
# Various compile flags
add_definitions(-msse2 -Wall)
add_definitions(-msse2)
# Enabling all warnings in MSVC spams too much
if(NOT MSVC)
add_definitions(-Wall)
endif(NOT MSVC)
# gcc uses some optimizations which might break stuff without this flag
add_definitions(-fno-strict-aliasing -fno-exceptions)
@ -61,8 +90,6 @@ if(WIN32)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif(WIN32)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Build type (Release/Debug/RelWithDebInfo/MinSizeRe)" FORCE)
@ -362,6 +389,8 @@ file(WRITE ${PROJECT_BINARY_DIR}/Source/Core/Common/Src/svnrev.h
include_directories("${PROJECT_BINARY_DIR}/Source/Core/Common/Src")
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
########################################
# Start compiling our code
#

View File

@ -1,7 +1,6 @@
# wxAdv28
set(SRCS src/common/accesscmn.cpp
src/common/datavcmn.cpp
src/common/dummy.cpp
src/common/taskbarcmn.cpp
src/generic/aboutdlgg.cpp
src/generic/animateg.cpp
@ -26,6 +25,7 @@ set(SRCS src/common/accesscmn.cpp
src/msw/joystick.cpp
src/msw/sound.cpp
src/msw/taskbar.cpp)
enable_precompiled_headers(include/wx/wxprec.h src/common/dummy.cpp SRCS)
add_library(wxAdv28 STATIC ${SRCS})
@ -35,8 +35,8 @@ set(SRCS src/aui/auibar.cpp
src/aui/dockart.cpp
src/aui/floatpane.cpp
src/aui/framemanager.cpp
src/aui/tabmdi.cpp
src/common/dummy.cpp)
src/aui/tabmdi.cpp)
enable_precompiled_headers(include/wx/wxprec.h src/common/dummy.cpp SRCS)
add_library(wxAui STATIC ${SRCS})
@ -52,7 +52,6 @@ set(SRCS src/common/appbase.cpp
src/common/datetime.cpp
src/common/datstrm.cpp
src/common/dircmn.cpp
src/common/dummy.cpp
src/common/dynarray.cpp
src/common/dynlib.cpp
src/common/dynload.cpp
@ -130,6 +129,7 @@ set(SRCS src/common/appbase.cpp
src/msw/utils.cpp
src/msw/utilsexc.cpp
src/msw/volume.cpp)
enable_precompiled_headers(include/wx/wxprec.h src/common/dummy.cpp SRCS)
add_library(wxBase28 STATIC ${SRCS})
@ -163,7 +163,6 @@ set(SRCS src/common/accesscmn.cpp
src/common/docview.cpp
src/common/dpycmn.cpp
src/common/dseldlg.cpp
src/common/dummy.cpp
src/common/effects.cpp
src/common/event.cpp
src/common/evtloopcmn.cpp
@ -374,8 +373,11 @@ set(SRCS src/common/accesscmn.cpp
src/msw/ole/dropsrc.cpp
src/msw/ole/droptgt.cpp
src/msw/ole/oleutils.cpp
src/msw/ole/uuid.cpp
src/png/png.c
src/msw/ole/uuid.cpp)
enable_precompiled_headers(include/wx/wxprec.h src/common/dummy.cpp SRCS)
# These shouldn't link against the precompiled header
set(SRCS ${SRCS} src/png/png.c
src/png/pngerror.c
src/png/pnggccrd.c
src/png/pngget.c
@ -393,4 +395,6 @@ set(SRCS src/common/accesscmn.cpp
src/png/pngwrite.c
src/png/pngwtran.c
src/png/pngwutil.c)
add_library(wxCore28 STATIC ${SRCS})

View File

@ -30,17 +30,19 @@ set(SRCS Src/ABI.cpp
Src/Version.cpp
Src/x64Analyzer.cpp
Src/x64Emitter.cpp
Src/Crypto/aes_cbc.c
Src/Crypto/aes_core.c
Src/Crypto/aes_cbc.cpp
Src/Crypto/aes_core.cpp
Src/Crypto/bn.cpp
Src/Crypto/ec.cpp
Src/Crypto/md5.cpp
Src/Crypto/sha1.cpp)
if(WIN32)
set(SRCS ${SRCS} Src/ExtendedTrace.cpp Src/stdafx.cpp)
set(SRCS ${SRCS} Src/ExtendedTrace.cpp)
endif(WIN32)
enable_precompiled_headers(Src/stdafx.h Src/stdafx.cpp SRCS)
add_library(common STATIC ${SRCS})
target_link_libraries(common ${CMAKE_DL_LIBS})
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

View File

@ -537,120 +537,12 @@
>
</File>
<File
RelativePath=".\Src\Crypto\aes_cbc.c"
RelativePath=".\Src\Crypto\aes_cbc.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Src\Crypto\aes_core.c"
RelativePath=".\Src\Crypto\aes_core.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|Win32"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
>
<Tool
Name="VCCLCompilerTool"
CompileAs="2"
ForcedIncludeFiles=""
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Src\Crypto\aes_locl.h"

View File

@ -42,8 +42,8 @@ files = [
"Version.cpp",
"x64Emitter.cpp",
"x64Analyzer.cpp",
"Crypto/aes_cbc.c",
"Crypto/aes_core.c",
"Crypto/aes_cbc.cpp",
"Crypto/aes_core.cpp",
"Crypto/bn.cpp",
"Crypto/ec.cpp",
"Crypto/md5.cpp",