Skip to content

Commit

Permalink
Merge pull request #4741 from Orphis/cmake_cleanup
Browse files Browse the repository at this point in the history
CMake cleanup
  • Loading branch information
degasus committed Jan 24, 2017
2 parents 221be63 + 803ea7b commit 63f56cc
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 127 deletions.
30 changes: 0 additions & 30 deletions CMakeLists.txt
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 Expand Up @@ -1006,7 +977,6 @@ if(NOT DISABLE_WX)
set(wxWidgets_FOUND TRUE)
set(wxWidgets_LIBRARIES "wx")
endif(wxWidgets_FOUND)
add_definitions(-DHAVE_WX=1)
endif(NOT DISABLE_WX)

if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|NetBSD")
Expand Down
6 changes: 4 additions & 2 deletions Externals/curl/lib/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LIB_NAME libcurl)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DHAVE_CONFIG_H)
endif()

add_definitions(-DHAVE_CONFIG_H)
include_directories(.)

file(GLOB SRCS *.c vauth/*.c vtls/*.c)
Expand All @@ -11,3 +12,4 @@ add_library(
)

target_link_libraries(curl ${MBEDTLS_LIBRARIES})
target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP)
7 changes: 4 additions & 3 deletions Externals/wxWidgets3/CMakeLists.txt
Expand Up @@ -296,7 +296,7 @@ set(SRCS_GENERIC
"src/generic/infobar.cpp"
"src/generic/laywin.cpp"
"src/generic/listbkg.cpp"
"src/generic/listctrl.cpp"

"src/generic/logg.cpp"
#"src/generic/markuptext.cpp"
#"src/generic/mask.cpp"
Expand Down Expand Up @@ -344,6 +344,7 @@ set(SRCS_GENERICGTK
"src/generic/activityindicator.cpp"
"src/generic/icon.cpp"
"src/generic/imaglist.cpp"
"src/generic/listctrl.cpp"
"src/generic/paletteg.cpp"
"src/generic/preferencesg.cpp")

Expand All @@ -358,7 +359,8 @@ set(SRCS_GENERICOSX
"src/generic/colrdlgg.cpp"
"src/generic/dirdlgg.cpp"
"src/generic/filedlgg.cpp"
"src/generic/fontpickerg.cpp")
"src/generic/fontpickerg.cpp"
"src/generic/listctrl.cpp")

set(SRCS_GTK
"src/aui/tabartgtk.cpp"
Expand Down Expand Up @@ -890,6 +892,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
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
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
1 change: 1 addition & 0 deletions Source/Core/AudioCommon/OpenALStream.cpp
Expand Up @@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <climits>
#include <cstring>
#include <thread>

Expand Down
6 changes: 0 additions & 6 deletions Source/Core/Common/Common.h
Expand Up @@ -37,12 +37,6 @@ extern const std::string scm_distributor_str;
// Memory leak checks
#define CHECK_HEAP_INTEGRITY()

// Since they are always around on Windows
#define HAVE_WX 1
#define HAVE_OPENAL 1

#define HAVE_PORTAUDIO 1

// Debug definitions
#if defined(_DEBUG)
#include <crtdbg.h>
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Common/x64CPUDetect.cpp
Expand Up @@ -12,6 +12,8 @@
#ifndef _WIN32

#ifdef __FreeBSD__
#include <unistd.h>

#include <machine/cpufunc.h>
#include <sys/types.h>
#endif
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/FifoPlayer/FifoDataFile.cpp
Expand Up @@ -3,6 +3,7 @@
// Refer to the license.txt file included.

#include <algorithm>
#include <cstring>
#include <string>

#include "Common/FileUtil.h"
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/JitCommon/JitCache.h
Expand Up @@ -6,6 +6,7 @@

#include <array>
#include <bitset>
#include <cstring>
#include <functional>
#include <map>
#include <memory>
Expand Down
39 changes: 22 additions & 17 deletions Source/Core/DolphinWX/Frame.cpp
Expand Up @@ -10,12 +10,6 @@
#include <string>
#include <utility>
#include <vector>
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
#include <signal.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include <wx/aui/auibook.h>
#include <wx/aui/framemanager.h>
#include <wx/filename.h>
Expand All @@ -31,6 +25,24 @@
#include <wx/thread.h>
#include <wx/toolbar.h>

#include "DolphinWX/Config/ConfigMain.h"
#include "DolphinWX/Debugger/BreakpointDlg.h"
#include "DolphinWX/Debugger/CodeWindow.h"
#include "DolphinWX/Debugger/MemoryCheckDlg.h"
#include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/Globals.h"
#include "DolphinWX/LogWindow.h"
#include "DolphinWX/Main.h"
#include "DolphinWX/TASInputDlg.h"
#include "DolphinWX/WxUtils.h"

#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
#include <signal.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif

#include "AudioCommon/AudioCommon.h"

#include "Common/CommonTypes.h"
Expand All @@ -51,17 +63,6 @@
#include "Core/Movie.h"
#include "Core/State.h"

#include "DolphinWX/Config/ConfigMain.h"
#include "DolphinWX/Debugger/BreakpointDlg.h"
#include "DolphinWX/Debugger/CodeWindow.h"
#include "DolphinWX/Debugger/MemoryCheckDlg.h"
#include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/Globals.h"
#include "DolphinWX/LogWindow.h"
#include "DolphinWX/Main.h"
#include "DolphinWX/TASInputDlg.h"
#include "DolphinWX/WxUtils.h"

#include "InputCommon/GCPadStatus.h"

#include "VideoCommon/OnScreenDisplay.h"
Expand All @@ -70,6 +71,10 @@
#include "VideoCommon/VideoConfig.h"

#if defined(HAVE_X11) && HAVE_X11

#include <gdk/gdkx.h>
#include <gtk/gtk.h>

// X11Utils nastiness that's only used here
namespace X11Utils
{
Expand Down
7 changes: 0 additions & 7 deletions Source/Core/DolphinWX/ISOFile.h
Expand Up @@ -11,10 +11,8 @@

#include "Common/Common.h"

#if defined(HAVE_WX) && HAVE_WX
#include <wx/bitmap.h>
#include <wx/image.h>
#endif

namespace DiscIO
{
Expand Down Expand Up @@ -60,12 +58,9 @@ class GameListItem
u64 GetVolumeSize() const { return m_VolumeSize; }
// 0 is the first disc, 1 is the second disc
u8 GetDiscNumber() const { return m_disc_number; }
#if defined(HAVE_WX) && HAVE_WX
// NOTE: Banner image is at the original resolution, use WxUtils::ScaleImageToBitmap
// to display it
const wxImage& GetBannerImage() const { return m_image; }
#endif

void DoState(PointerWrap& p);

private:
Expand All @@ -90,9 +85,7 @@ class GameListItem
DiscIO::BlobType m_blob_type;
u16 m_Revision;

#if defined(HAVE_WX) && HAVE_WX
wxImage m_image;
#endif
bool m_Valid;
std::vector<u8> m_pImage;
int m_ImageWidth, m_ImageHeight;
Expand Down
9 changes: 5 additions & 4 deletions Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp
Expand Up @@ -14,17 +14,18 @@
#include <wx/stattext.h>
#include <wx/textctrl.h>

#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Core/NetPlayClient.h"
#include "Core/NetPlayServer.h"
#include "DolphinWX/Frame.h"
#include "DolphinWX/Main.h"
#include "DolphinWX/NetPlay/NetPlayLauncher.h"
#include "DolphinWX/NetPlay/NetPlaySetupFrame.h"
#include "DolphinWX/NetPlay/NetWindow.h"
#include "DolphinWX/WxUtils.h"

#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Core/NetPlayClient.h"
#include "Core/NetPlayServer.h"

namespace
{
wxString GetTraversalLabelText(IniFile::Section& section)
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/DolphinWX/NetPlay/PadMapDialog.cpp
Expand Up @@ -7,11 +7,12 @@
#include <wx/sizer.h>
#include <wx/stattext.h>

#include "DolphinWX/NetPlay/PadMapDialog.h"
#include "DolphinWX/WxUtils.h"

#include "Core/NetPlayClient.h"
#include "Core/NetPlayProto.h"
#include "Core/NetPlayServer.h"
#include "DolphinWX/NetPlay/PadMapDialog.h"
#include "DolphinWX/WxUtils.h"

PadMapDialog::PadMapDialog(wxWindow* parent, NetPlayServer* server, NetPlayClient* client)
: wxDialog(parent, wxID_ANY, _("Controller Ports")), m_pad_mapping(server->GetPadMapping()),
Expand Down
4 changes: 0 additions & 4 deletions Source/Core/DolphinWX/X11Utils.cpp
Expand Up @@ -13,13 +13,9 @@

extern char** environ;

#if defined(HAVE_WX) && HAVE_WX
#include <algorithm>
#include <string>

#include "DolphinWX/WxUtils.h"
#endif

namespace X11Utils
{
bool ToggleFullscreen(Display* dpy, Window win)
Expand Down
8 changes: 0 additions & 8 deletions Source/Core/DolphinWX/X11Utils.h
Expand Up @@ -12,12 +12,6 @@
// is terrible, but such is the life with Xlib.
#include <SFML/Network.hpp> // NOLINT

#if defined(HAVE_WX) && HAVE_WX
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <wx/arrstr.h>
#endif

#if defined(HAVE_XRANDR) && HAVE_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
Expand All @@ -33,10 +27,8 @@
namespace X11Utils
{
bool ToggleFullscreen(Display* dpy, Window win);
#if defined(HAVE_WX) && HAVE_WX
Window XWindowFromHandle(void* Handle);
Display* XDisplayFromHandle(void* Handle);
#endif

void InhibitScreensaver(Display* dpy, Window win, bool suspend);

Expand Down
2 changes: 2 additions & 0 deletions Source/VSProps/Base.props
Expand Up @@ -55,6 +55,8 @@
<PreprocessorDefinitions>PSAPI_VERSION=1;_M_X86=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>SFML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>HAVE_OPENAL=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>HAVE_PORTAUDIO=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">_ARCH_64=1;_M_X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<!--
Make sure we include a clean version of windows.h.
Expand Down

0 comments on commit 63f56cc

Please sign in to comment.