VERY experimental Nintendo Switch 2 emulator
C++
CMake cleanup
Yuri Kunde Schlesner45976da975a2
diff --git a/.travis-deps.sh b/.travis-deps.shindex 84bddb304d..b8e8417b26 100644--- a/.travis-deps.sh+++ b/.travis-deps.sh@@ -8,10 +8,16 @@ if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; thensudo apt-get -qq updatesudo apt-get -qq install g++-4.8 xorg-dev libglu1-mesa-dev libxcursor-devsudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90- git clone https://github.com/glfw/glfw.git- mkdir glfw/build && cd glfw/build- cmake .. && make && sudo make install- cd -+ (+ git clone https://github.com/glfw/glfw.git --branch 3.0.4 --depth 1+ mkdir glfw/build && cd glfw/build+ cmake .. && make -j2 && sudo make install+ )++ sudo apt-get install lib32stdc++6+ sudo mkdir -p /usr/local+ curl http://www.cmake.org/files/v2.8/cmake-2.8.11-Linux-i386.tar.gz \+ | sudo tar -xz -C /usr/local --strip-components=1elif [ "$TRAVIS_OS_NAME" = osx ]; thenbrew tap homebrew/versionsbrew install qt5 glfw3 pkgconfigdiff --git a/CMakeLists.txt b/CMakeLists.txtindex 3461d1555e..e1614cd4a6 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -1,78 +1,131 @@-cmake_minimum_required(VERSION 2.8.7)+# CMake 2.8.11 required for Qt5 settings to be applied automatically on+# dependent libraries.+cmake_minimum_required(VERSION 2.8.11)project(citra)-SET(CXX_COMPILE_FLAGS "-std=c++11")--# silence some spam-add_definitions(-Wno-attributes)+if (NOT MSVC)+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes")+else()+ # Silence deprecation warnings+ add_definitions(/D_CRT_SECURE_NO_WARNINGS)+endif()add_definitions(-DSINGLETHREADED)-add_definitions(${CXX_COMPILE_FLAGS})find_package(PNG)if (PNG_FOUND)add_definitions(-DHAVE_PNG)endif ()-# dependency checking-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/")-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)-include(FindX11 REQUIRED)-find_package(PkgConfig REQUIRED)+# Include bundled CMake modules+list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules")+find_package(OpenGL REQUIRED)-pkg_search_module(GLFW REQUIRED glfw3)+include_directories(${OPENGL_INCLUDE_DIR})++option(ENABLE_GLFW "Enable the GLFW frontend" ON)+if (ENABLE_GLFW)+ if (WIN32)+ # Detect toolchain and platform+ if (MSVC)+ if (CMAKE_SIZEOF_VOID_P EQUAL 8)+ set(TMP_ARCH "x64")+ else()+ set(TMP_ARCH "Win32")+ endif()++ if (MSVC11) # Visual C++ 2012+ set(TMP_TOOLSET "v110")+ elseif (MSVC12) # Visual C++ 2013+ set(TMP_TOOLSET "v120")+ else()+ set(TMP_TOOLSET "UNSUPPORTED")+ message(SEND_ERROR "We don't supply GLFW binaries for your version of MSVC, you might have to provide them yourself.")+ endif()++ set(TMP_TOOLSET "msvc_${TMP_TOOLSET}-${TMP_ARCH}")+ else()+ # Assume mingw+ if (CMAKE_SIZEOF_VOID_P EQUAL 8)+ set(TMP_ARCH "x86_64")+ else()+ set(TMP_ARCH "i686")+ endif()++ set(TMP_TOOLSET "mingw-${TMP_ARCH}")+ endif()++ set(GLFW_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/externals/glfw-3.0.4.bin")+ set(GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers")+ set(GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib-${TMP_TOOLSET}" CACHE PATH "Path to GLFW3 libraries")++ # Clean up after ourselves+ unset(TMP_TOOLSET)+ unset(TMP_ARCH)++ set(GLFW_LIBRARIES glfw3)+ else()+ find_package(X11 REQUIRED)+ find_package(PkgConfig REQUIRED)+ pkg_search_module(GLFW REQUIRED glfw3)+ endif()++ include_directories(${GLFW_INCLUDE_DIRS})+ link_directories(${GLFW_LIBRARY_DIRS})+endif()-# corefoundation is required only on OSXIF (APPLE)+ # CoreFoundation is required only on OSXFIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")ENDIF (APPLE)-#external includes-include_directories(${GLFW_INCLUDE_DIRS})-include_directories(${OPENGL_INCLUDE_DIR})+option(ENABLE_QT "Enable the Qt frontend" ON)+option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF)+if (ENABLE_QT)+ # Set CMAKE_PREFIX_PATH if QTDIR is defined in the environment This allows CMake to+ # automatically find the Qt packages on Windows+ if (DEFINED ENV{QTDIR})+ list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}")+ endif()-# workaround for GLFW linking on OSX-link_directories(${GLFW_LIBRARY_DIRS})--option(DISABLE_QT "Disable Qt GUI" OFF)-option(USE_QT5 "Use Qt5 when available" ON)-if (NOT DISABLE_QT)- if(USE_QT5)- find_package(Qt5Gui)- find_package(Qt5Widgets)- find_package(Qt5OpenGL)- if(NOT Qt5Gui_FOUND OR NOT Qt5Widgets_FOUND OR NOT Qt5OpenGL_FOUND)- message("Qt5 libraries not found! Using Qt4 instead.")- set(USE_QT5 OFF)- endif()+ if (NOT CITRA_FORCE_QT4)+ find_package(Qt5 COMPONENTS Widgets OpenGL)+ set(CITRA_QT_LIBS Qt5::Widgets Qt5::OpenGL)endif()- if(NOT USE_QT5)- include(FindQt4)- find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL)- if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND)- include(${QT_USE_FILE})- include_directories(${QT_INCLUDES})- else()- message("Qt4 libraries not found! Disabling Qt GUI")- set(DISABLE_QT ON)- endif()+ if (CITRA_FORCE_QT4 OR NOT Qt5_FOUND)+ # Try to fallback to Qt4+ find_package(Qt4 REQUIRED COMPONENTS QtGui QtOpenGL)+ set(CITRA_QT_LIBS Qt4::QtGui Qt4::QtOpenGL)endif()endif()+# This function should be passed a list of all files in a target. It will automatically generate+# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the+# one in the filesystem.+function(create_directory_groups)+ # Place any files that aren't in the source list in a separate group so that they don't get in+ # the way.+ source_group("Other Files" REGULAR_EXPRESSION ".")++ foreach(file_name ${ARGV})+ get_filename_component(dir_name "${file_name}" PATH)+ # Group names use '\' as a separator even though the entire rest of CMake uses '/'...+ string(REPLACE "/" "\\" group_name "${dir_name}")+ source_group("${group_name}" FILES "${file_name}")+ endforeach()+endfunction()+# generate git revision informationinclude(GetGitRevisionDescription)get_git_head_revision(GIT_REF_SPEC GIT_REV)git_describe(GIT_DESC --always --long --dirty)git_branch_name(GIT_BRANCH)--# internal includes-include_directories(src)# process subdirectories-if(NOT DISABLE_QT)+if(ENABLE_QT)include_directories(externals/qhexedit)add_subdirectory(externals/qhexedit)endif()diff --git a/externals/qhexedit/CMakeLists.txt b/externals/qhexedit/CMakeLists.txtindex b1f631f959..e7470dfe42 100644--- a/externals/qhexedit/CMakeLists.txt+++ b/externals/qhexedit/CMakeLists.txt@@ -5,14 +5,17 @@ set(SRCScommands.cppqhexedit.cppqhexedit_p.cpp- xbytearray.cpp)+ xbytearray.cpp+ )set(HEADERS+ commands.hqhexedit.h- qhexedit_p.h)+ qhexedit_p.h+ xbytearray.h+ )-add_library(qhexedit STATIC ${SRCS} ${HEADERS})-if(USE_QT5)- target_link_libraries(qhexedit Qt5::Core Qt5::Widgets)-endif()+create_directory_groups(${SRCS} ${HEADERS})+add_library(qhexedit STATIC ${SRCS} ${HEADERS})+target_link_libraries(qhexedit ${CITRA_QT_LIBS})diff --git a/src/CMakeLists.txt b/src/CMakeLists.txtindex e0227dc535..cb09f3cd1d 100644--- a/src/CMakeLists.txt+++ b/src/CMakeLists.txt@@ -1,9 +1,12 @@+# Enable modules to include each other's files+include_directories(.)+add_subdirectory(common)add_subdirectory(core)add_subdirectory(video_core)-add_subdirectory(citra)-add_subdirectory(citra_qt)--if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND AND NOT DISABLE_QT4)- #add_subdirectory(citra_qt)+if (ENABLE_GLFW)+ add_subdirectory(citra)+endif()+if (ENABLE_QT)+ add_subdirectory(citra_qt)endif()diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txtindex bd6c4a1a81..f10f3e603e 100644--- a/src/citra/CMakeLists.txt+++ b/src/citra/CMakeLists.txt@@ -1,6 +1,13 @@-set(SRCS citra.cpp- emu_window/emu_window_glfw.cpp)-set(HEADERS resource.h)+set(SRCS+ emu_window/emu_window_glfw.cpp+ citra.cpp+ )+set(HEADERS+ emu_window/emu_window_glfw.h+ resource.h+ )++create_directory_groups(${SRCS} ${HEADERS})# NOTE: This is a workaround for CMake bug 0006976 (missing X11_xf86vmode_LIB variable)if (NOT X11_xf86vmode_LIB)@@ -8,11 +15,16 @@ if (NOT X11_xf86vmode_LIB)endif()add_executable(citra ${SRCS} ${HEADERS})+target_link_libraries(citra core common video_core)+target_link_libraries(citra ${OPENGL_gl_LIBRARY} ${GLFW_LIBRARIES})if (APPLE)- target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES})-else()- target_link_libraries(citra core common video_core pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB} ${PNG_LIBRARIES})+ target_link_libraries(citra iconv pthread ${COREFOUNDATION_LIBRARY})+elseif (WIN32)+ target_link_libraries(citra winmm)+else() # Unix+ target_link_libraries(citra pthread rt)+ target_link_libraries(citra ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_Xcursor_LIB} ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB})endif()#install(TARGETS citra RUNTIME DESTINATION ${bindir})diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txtindex 055a585a01..426e4ef993 100644--- a/src/citra_qt/CMakeLists.txt+++ b/src/citra_qt/CMakeLists.txt@@ -2,54 +2,61 @@ set(CMAKE_AUTOMOC ON)set(CMAKE_INCLUDE_CURRENT_DIR ON)set(SRCS- bootmanager.cpp+ config/controller_config.cpp+ config/controller_config_util.cppdebugger/callstack.cppdebugger/disassembler.cppdebugger/graphics.cppdebugger/graphics_cmdlists.cppdebugger/ramview.cppdebugger/registers.cpp+ bootmanager.cpphotkeys.cppmain.cpp- config/controller_config.cpp- config/controller_config_util.cpp)+ )set(HEADERS- bootmanager.hxx+ config/controller_config.hxx+ config/controller_config_util.hxxdebugger/callstack.hxxdebugger/disassembler.hxx+ debugger/graphics.hxx+ debugger/graphics_cmdlists.hxxdebugger/ramview.hxxdebugger/registers.hxx+ bootmanager.hxxhotkeys.hxxmain.hxxversion.h- config/controller_config.hxx- config/controller_config_util.hxx)+ )set(UIS+ config/controller_config.uidebugger/callstack.uidebugger/disassembler.uidebugger/registers.uihotkeys.uimain.ui- config/controller_config.ui)+ )++create_directory_groups(${SRCS} ${HEADERS} ${UIS})-if(USE_QT5)+if (Qt5_FOUND)qt5_wrap_ui(UI_HDRS ${UIS})else()qt4_wrap_ui(UI_HDRS ${UIS})endif()add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS})-if(APPLE)- set(ICONV_LIBRARY iconv)-else()- set(RT_LIBRARY rt)-endif()+target_link_libraries(citra-qt core common video_core qhexedit)+target_link_libraries(citra-qt ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS})-target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${PNG_LIBRARIES})-if(USE_QT5)- target_link_libraries(citra-qt Qt5::Gui Qt5::Widgets Qt5::OpenGL)+if (APPLE)+ target_link_libraries(citra-qt iconv ${COREFOUNDATION_LIBRARY})+elseif (WIN32)+ target_link_libraries(citra-qt winmm)+else() # Unix+ target_link_libraries(citra-qt rt)endif()#install(TARGETS citra-qt RUNTIME DESTINATION ${bindir})diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txtindex aae1833939..f8a55c2a7f 100644--- a/src/common/CMakeLists.txt+++ b/src/common/CMakeLists.txt@@ -1,6 +1,8 @@+# Generate cpp with Git revision from templateconfigure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY)-set(SRCS break_points.cpp+set(SRCS+ break_points.cppconsole_listener.cppextended_trace.cppfile_search.cpp@@ -12,23 +14,25 @@ set(SRCS break_points.cppmemory_util.cppmisc.cppmsg_handler.cpp- string_util.cppscm_rev.cpp+ string_util.cppsymbols.cppthread.cpptimer.cpp- utf8.cpp)+ utf8.cpp+ )-set(HEADERS atomic.h+set(HEADERS+ atomic.hatomic_gcc.hatomic_win32.hbit_field.hbreak_points.hchunk_file.h+ common.hcommon_funcs.hcommon_paths.hcommon_types.h- common.hconsole_listener.hcpu_detect.hdebug_interface.h@@ -37,10 +41,11 @@ set(HEADERS atomic.hfifo_queue.hfile_search.hfile_util.h+ fixed_size_queue.hhash.hlinear_disk_cache.h- log_manager.hlog.h+ log_manager.hmath_util.hmem_arena.hmemory_util.h@@ -54,8 +59,12 @@ set(HEADERS atomic.hswap.hsymbols.hthread.h+ thread_queue_list.hthunk.htimer.h- utf8.h)+ utf8.h+ )++create_directory_groups(${SRCS} ${HEADERS})add_library(common STATIC ${SRCS} ${HEADERS})diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex 207f39707c..1f358ec8db 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -1,14 +1,18 @@-set(SRCS core.cpp- core_timing.cpp- loader/elf.cpp- loader/loader.cpp- loader/ncch.cpp- mem_map.cpp- mem_map_funcs.cpp- system.cpp+set(SRCSarm/disassembler/arm_disasm.cpparm/disassembler/load_symbol_map.cpp- file_sys/archive_romfs.cpp+ arm/interpreter/mmu/arm1176jzf_s_mmu.cpp+ arm/interpreter/mmu/cache.cpp+ arm/interpreter/mmu/maverick.cpp+ arm/interpreter/mmu/rb.cpp+ arm/interpreter/mmu/sa_mmu.cpp+ arm/interpreter/mmu/tlb.cpp+ arm/interpreter/mmu/wb.cpp+ arm/interpreter/mmu/xscale_copro.cpp+ arm/interpreter/vfp/vfp.cpp+ arm/interpreter/vfp/vfpdouble.cpp+ arm/interpreter/vfp/vfpinstr.cpp+ arm/interpreter/vfp/vfpsingle.cpparm/interpreter/arm_interpreter.cpparm/interpreter/armcopro.cpparm/interpreter/armemu.cpp@@ -18,22 +22,7 @@ set(SRCS core.cpparm/interpreter/armsupp.cpparm/interpreter/armvirt.cpparm/interpreter/thumbemu.cpp- arm/interpreter/vfp/vfp.cpp- arm/interpreter/vfp/vfpdouble.cpp- arm/interpreter/vfp/vfpinstr.cpp- arm/interpreter/vfp/vfpsingle.cpp- arm/interpreter/mmu/arm1176jzf_s_mmu.cpp- arm/interpreter/mmu/cache.cpp- arm/interpreter/mmu/maverick.cpp- arm/interpreter/mmu/rb.cpp- arm/interpreter/mmu/sa_mmu.cpp- arm/interpreter/mmu/tlb.cpp- arm/interpreter/mmu/wb.cpp- arm/interpreter/mmu/xscale_copro.cpp- hle/hle.cpp- hle/config_mem.cpp- hle/coprocessor.cpp- hle/svc.cpp+ file_sys/archive_romfs.cpphle/kernel/address_arbiter.cpphle/kernel/archive.cpphle/kernel/event.cpp@@ -48,27 +37,26 @@ set(SRCS core.cpphle/service/ndm.cpphle/service/service.cpphle/service/srv.cpp+ hle/config_mem.cpp+ hle/coprocessor.cpp+ hle/hle.cpp+ hle/svc.cpphw/gpu.cpphw/hw.cpp- hw/ndma.cpp)+ hw/ndma.cpp+ loader/elf.cpp+ loader/loader.cpp+ loader/ncch.cpp+ core.cpp+ core_timing.cpp+ mem_map.cpp+ mem_map_funcs.cpp+ system.cpp+ )-set(HEADERS core.h- core_timing.h- loader/elf.h- loader/loader.h- loader/ncch.h- mem_map.h- system.h+set(HEADERSarm/disassembler/arm_disasm.harm/disassembler/load_symbol_map.h- arm/interpreter/arm_interpreter.h- arm/interpreter/arm_regformat.h- arm/interpreter/armcpu.h- arm/interpreter/armdefs.h- arm/interpreter/armemu.h- arm/interpreter/armmmu.h- arm/interpreter/armos.h- arm/interpreter/skyeye_defs.harm/interpreter/mmu/arm1176jzf_s_mmu.harm/interpreter/mmu/cache.harm/interpreter/mmu/rb.h@@ -78,27 +66,48 @@ set(HEADERS core.harm/interpreter/vfp/asm_vfp.harm/interpreter/vfp/vfp.harm/interpreter/vfp/vfp_helper.h+ arm/interpreter/arm_interpreter.h+ arm/interpreter/arm_regformat.h+ arm/interpreter/armcpu.h+ arm/interpreter/armdefs.h+ arm/interpreter/armemu.h+ arm/interpreter/armmmu.h+ arm/interpreter/armos.h+ arm/interpreter/skyeye_defs.h+ arm/arm_interface.hfile_sys/archive.hfile_sys/archive_romfs.h- hle/config_mem.h- hle/coprocessor.h- hle/hle.h- hle/svc.hhle/kernel/address_arbiter.hhle/kernel/archive.h+ hle/kernel/event.hhle/kernel/kernel.hhle/kernel/mutex.hhle/kernel/shared_memory.hhle/kernel/thread.h- hle/function_wrappers.hhle/service/apt.hhle/service/fs.hhle/service/gsp.hhle/service/hid.h+ hle/service/ndm.hhle/service/service.hhle/service/srv.h+ hle/config_mem.h+ hle/coprocessor.h+ hle/function_wrappers.h+ hle/hle.h+ hle/svc.hhw/gpu.hhw/hw.h- hw/ndma.h)+ hw/ndma.h+ loader/elf.h+ loader/loader.h+ loader/ncch.h+ core.h+ core_timing.h+ mem_map.h+ system.h+ )++create_directory_groups(${SRCS} ${HEADERS})add_library(core STATIC ${SRCS} ${HEADERS})diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txtindex 48c5d1424f..13c3f7b228 100644--- a/src/video_core/CMakeLists.txt+++ b/src/video_core/CMakeLists.txt@@ -1,29 +1,42 @@-set(SRCS clipper.cpp+set(SRCS+ renderer_opengl/generated/gl_3_2_core.c+ renderer_opengl/renderer_opengl.cpp+ renderer_opengl/gl_shader_util.cpp+ debug_utils/debug_utils.cpp+ clipper.cppcommand_processor.cppprimitive_assembly.cpprasterizer.cpputils.cppvertex_shader.cppvideo_core.cpp- renderer_opengl/generated/gl_3_2_core.c- renderer_opengl/renderer_opengl.cpp- renderer_opengl/gl_shader_util.cpp- debug_utils/debug_utils.cpp)+ )-set(HEADERS clipper.h+set(HEADERS+ debug_utils/debug_utils.h+ renderer_opengl/generated/gl_3_2_core.h+ renderer_opengl/gl_shader_util.h+ renderer_opengl/gl_shaders.h+ renderer_opengl/renderer_opengl.h+ clipper.hcommand_processor.h+ gpu_debugger.hmath.h+ pica.hprimitive_assembly.hrasterizer.h- utils.h- video_core.hrenderer_base.h+ utils.hvertex_shader.hvideo_core.h- renderer_opengl/generated/gl_3_2_core.h- renderer_opengl/renderer_opengl.h- renderer_opengl/gl_shader_util.h- renderer_opengl/gl_shaders.h- debug_utils/debug_utils.h)+ )++create_directory_groups(${SRCS} ${HEADERS})add_library(video_core STATIC ${SRCS} ${HEADERS})++if (PNG_FOUND)+ target_link_libraries(video_core ${PNG_LIBRARIES})+ include_directories(${PNG_INCLUDE_DIRS})+ add_definitions(${PNG_DEFINITIONS})+endif()