Skip to content

Commit

Permalink
cmake: Remove PCH support
Browse files Browse the repository at this point in the history
Compilers are very picky and don't use PCH when they have been compiled
with different flags. I even got some ICE in MSVC, so removing them for now.

Modules are the solution.
  • Loading branch information
Orphis committed Jan 24, 2017
1 parent f70a1a2 commit fa04c14
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 74 deletions.
29 changes: 0 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ option(USE_SHARED_GTEST "Use shared gtest library if found" OFF)
option(USE_UPNP "Enables UPnP port mapping support" ON)
option(DISABLE_WX "Disable wxWidgets (use Qt or CLI interface)" OFF)
option(ENABLE_QT2 "Enable Qt2 (use the other experimental Qt interface)" OFF)
option(ENABLE_PCH "Use PCH to speed up compilation" ON)
option(ENABLE_LTO "Enables Link Time Optimization" OFF)
option(ENABLE_GENERIC "Enables generic build that should run on any little-endian host" OFF)
option(ENABLE_HEADLESS "Enables running Dolphin as a headless variant" OFF)
Expand Down Expand Up @@ -122,34 +121,6 @@ endif()
# as defined above.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries)

# 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)

# setup CCache
include(CCache)

Expand Down
1 change: 0 additions & 1 deletion Externals/wxWidgets3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,5 @@ add_definitions(-DWXBUILDING)
# wxWidgets warnings are not our problem.
add_definitions(-w)

#enable_precompiled_headers(include/wx/wxprec.h src/common/dummy.cpp SRCS)
add_library(wx STATIC ${PNG_SRCS} ${SRCS})
target_link_libraries(wx ${LIBS})
2 changes: 1 addition & 1 deletion Source/Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ android {
defaultConfig {
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_static", "-DCMAKE_BUILD_TYPE=RelWithDebInfo", "-DENABLE_PCH=OFF" // , "-DENABLE_GENERIC=ON"
arguments "-DANDROID_STL=c++_static", "-DCMAKE_BUILD_TYPE=RelWithDebInfo" // , "-DENABLE_GENERIC=ON"
abiFilters "arm64-v8a" //, "armeabi-v7a", "x86_64", "x86"
}
}
Expand Down
43 changes: 0 additions & 43 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,9 @@ endif()
add_definitions(-D__STDC_LIMIT_MACROS)
add_definitions(-D__STDC_CONSTANT_MACROS)

set(CMAKE_FAKELANG_CREATE_STATIC_LIBRARY "touch <TARGET>")
if(ENABLE_PCH)
# This is actually a .h file, but trick cmake into compiling it as a source file
set(pch_out_filename "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/pch.dir/pch.h")
if (ANDROID)
set(pch_lib_filename "${LIBRARY_OUTPUT_PATH}/libpch.a")
else()
set(pch_lib_filename "${CMAKE_CURRENT_BINARY_DIR}/libpch.a")
endif()
set(pch_src_filename "${CMAKE_CURRENT_SOURCE_DIR}/PCH/pch.h")

if(APPLE)
set(type objective-c++-header)
else()
set(type c++-header)
endif()

set_source_files_properties(
PCH/pch.h PROPERTIES
COMPILE_FLAGS "-x ${type}"
HEADER_FILE_ONLY 0
LANGUAGE CXX)

add_library(pch STATIC PCH/pch.h)

add_custom_command(
TARGET pch
PRE_LINK
COMMAND ln -fs "${pch_out_filename}.o" "${pch_out_filename}.gch"
COMMAND ln -fs "${pch_out_filename}.o" "${pch_out_filename}.pch"
COMMAND cp "${pch_src_filename}" "${pch_out_filename}")

set_target_properties(
pch PROPERTIES
LINKER_LANGUAGE FAKELANG)
endif(ENABLE_PCH)
macro(add_dolphin_library lib srcs libs)
add_library(${lib} STATIC ${srcs})
target_link_libraries(${lib} ${libs})
if(ENABLE_PCH)
add_dependencies(${lib} pch)
set_source_files_properties(
${srcs} PROPERTIES
COMPILE_FLAGS "-include '${pch_out_filename}'"
OBJECT_DEPENDS "${pch_lib_filename}")
endif(ENABLE_PCH)
endmacro(add_dolphin_library)

add_subdirectory(Core)
Expand Down

0 comments on commit fa04c14

Please sign in to comment.