From ab021d163e2a33b25b1811dc6f6abd924ec2d529 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Sun, 10 Dec 2017 18:55:03 -0500
Subject: [PATCH] CMakeLists: Derive the source directory grouping from targets
 themselves

Removes the need to store to separate SRC and HEADER variables,
and then construct the target in most cases.
---
 CMakeLists.txt                  |   6 +-
 externals/getopt/CMakeLists.txt |  14 +-
 externals/glad/CMakeLists.txt   |  15 +-
 externals/inih/CMakeLists.txt   |  17 +-
 src/audio_core/CMakeLists.txt   |  61 ++-
 src/citra/CMakeLists.txt        |  25 +-
 src/citra_qt/CMakeLists.txt     | 173 +++----
 src/common/CMakeLists.txt       | 119 +++--
 src/core/CMakeLists.txt         | 805 ++++++++++++++++----------------
 src/input_common/CMakeLists.txt |  33 +-
 src/network/CMakeLists.txt      |  26 +-
 src/tests/CMakeLists.txt        |  35 +-
 src/video_core/CMakeLists.txt   | 151 +++---
 src/web_service/CMakeLists.txt  |  22 +-
 14 files changed, 735 insertions(+), 767 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4375ed54..b7c7c48ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -274,12 +274,14 @@ 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)
+function(create_target_directory_groups target_name)
     # 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_target_property(target_sources "${target_name}" SOURCES)
+
+    foreach(file_name IN LISTS target_sources)
         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}")
diff --git a/externals/getopt/CMakeLists.txt b/externals/getopt/CMakeLists.txt
index c8b745d55..ad7a2b363 100644
--- a/externals/getopt/CMakeLists.txt
+++ b/externals/getopt/CMakeLists.txt
@@ -1,11 +1,9 @@
-set(SRCS
-            getopt.c
-            )
-set(HEADERS
-            getopt.h
-            )
+add_library(getopt
+    getopt.c
+    getopt.h
+)
+
+create_target_directory_groups(getopt)
 
-create_directory_groups(${SRCS} ${HEADERS})
-add_library(getopt ${SRCS} ${HEADERS})
 target_compile_definitions(getopt PUBLIC STATIC_GETOPT)
 target_include_directories(getopt INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/externals/glad/CMakeLists.txt b/externals/glad/CMakeLists.txt
index 6d35a844b..c43ae475a 100644
--- a/externals/glad/CMakeLists.txt
+++ b/externals/glad/CMakeLists.txt
@@ -1,13 +1,10 @@
-set(SRCS
-            src/glad.c
-            )
-set(HEADERS
-            include/KHR/khrplatform.h
-            include/glad/glad.h
-            )
+add_library(glad STATIC
+    src/glad.c
+    include/KHR/khrplatform.h
+    include/glad/glad.h
+)
 
-create_directory_groups(${SRCS} ${HEADERS})
-add_library(glad STATIC ${SRCS} ${HEADERS})
+create_target_directory_groups(glad)
 target_include_directories(glad PUBLIC "include/")
 
 if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
diff --git a/externals/inih/CMakeLists.txt b/externals/inih/CMakeLists.txt
index cff36a581..2a75852c2 100644
--- a/externals/inih/CMakeLists.txt
+++ b/externals/inih/CMakeLists.txt
@@ -1,12 +1,9 @@
-set(SRCS
-            inih/ini.c
-            inih/cpp/INIReader.cpp
-            )
-set(HEADERS
-            inih/ini.h
-            inih/cpp/INIReader.h
-            )
+add_library(inih
+    inih/ini.c
+    inih/ini.h
+    inih/cpp/INIReader.cpp
+    inih/cpp/INIReader.h
+)
 
-create_directory_groups(${SRCS} ${HEADERS})
-add_library(inih ${SRCS} ${HEADERS})
+create_target_directory_groups(inih)
 target_include_directories(inih INTERFACE .)
diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt
index 0ad86bb7a..2a80ebbfe 100644
--- a/src/audio_core/CMakeLists.txt
+++ b/src/audio_core/CMakeLists.txt
@@ -1,40 +1,33 @@
-set(SRCS
-            audio_core.cpp
-            codec.cpp
-            hle/dsp.cpp
-            hle/filter.cpp
-            hle/mixers.cpp
-            hle/pipe.cpp
-            hle/source.cpp
-            interpolate.cpp
-            sink_details.cpp
-            time_stretch.cpp
-            )
+add_library(audio_core STATIC
+    audio_core.cpp
+    audio_core.h
+    codec.cpp
+    codec.h
+    hle/common.h
+    hle/dsp.cpp
+    hle/dsp.h
+    hle/filter.cpp
+    hle/filter.h
+    hle/mixers.cpp
+    hle/mixers.h
+    hle/pipe.cpp
+    hle/pipe.h
+    hle/source.cpp
+    hle/source.h
+    interpolate.cpp
+    interpolate.h
+    null_sink.h
+    sink.h
+    sink_details.cpp
+    sink_details.h
+    time_stretch.cpp
+    time_stretch.h
 
-set(HEADERS
-            audio_core.h
-            codec.h
-            hle/common.h
-            hle/dsp.h
-            hle/filter.h
-            hle/mixers.h
-            hle/pipe.h
-            hle/source.h
-            interpolate.h
-            null_sink.h
-            sink.h
-            sink_details.h
-            time_stretch.h
-            )
+    $<$<BOOL:SDL2_FOUND>:sdl2_sink.cpp sdl2_sink.h>
+)
 
-if(SDL2_FOUND)
-    set(SRCS ${SRCS} sdl2_sink.cpp)
-    set(HEADERS ${HEADERS} sdl2_sink.h)
-endif()
+create_target_directory_groups(audio_core)
 
-create_directory_groups(${SRCS} ${HEADERS})
-
-add_library(audio_core STATIC ${SRCS} ${HEADERS})
 target_link_libraries(audio_core PUBLIC common core)
 target_link_libraries(audio_core PRIVATE SoundTouch)
 
diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt
index a885f22f8..1fac295f7 100644
--- a/src/citra/CMakeLists.txt
+++ b/src/citra/CMakeLists.txt
@@ -1,21 +1,18 @@
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
 
-set(SRCS
-            emu_window/emu_window_sdl2.cpp
-            citra.cpp
-            config.cpp
-            citra.rc
-            )
-set(HEADERS
-            emu_window/emu_window_sdl2.h
-            config.h
-            default_ini.h
-            resource.h
-            )
+add_executable(citra
+    citra.cpp
+    citra.rc
+    config.cpp
+    config.h
+    default_ini.h
+    emu_window/emu_window_sdl2.cpp
+    emu_window/emu_window_sdl2.h
+    resource.h
+)
 
-create_directory_groups(${SRCS} ${HEADERS})
+create_target_directory_groups(citra)
 
-add_executable(citra ${SRCS} ${HEADERS})
 target_link_libraries(citra PRIVATE common core input_common network)
 target_link_libraries(citra PRIVATE inih glad)
 if (MSVC)
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt
index e4929a0b4..1583e2a1c 100644
--- a/src/citra_qt/CMakeLists.txt
+++ b/src/citra_qt/CMakeLists.txt
@@ -3,107 +3,112 @@ set(CMAKE_AUTORCC ON)
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
 
-set(SRCS
-            configuration/config.cpp
-            configuration/configure_audio.cpp
-            configuration/configure_debug.cpp
-            configuration/configure_dialog.cpp
-            configuration/configure_general.cpp
-            configuration/configure_graphics.cpp
-            configuration/configure_input.cpp
-            configuration/configure_system.cpp
-            configuration/configure_web.cpp
-            debugger/graphics/graphics.cpp
-            debugger/graphics/graphics_breakpoint_observer.cpp
-            debugger/graphics/graphics_breakpoints.cpp
-            debugger/graphics/graphics_cmdlists.cpp
-            debugger/graphics/graphics_surface.cpp
-            debugger/graphics/graphics_tracing.cpp
-            debugger/graphics/graphics_vertex_shader.cpp
-            debugger/profiler.cpp
-            debugger/registers.cpp
-            debugger/wait_tree.cpp
-            updater/updater.cpp
-            util/spinbox.cpp
-            util/util.cpp
-            aboutdialog.cpp
-            bootmanager.cpp
-            game_list.cpp
-            hotkeys.cpp
-            main.cpp
-            ui_settings.cpp
-            citra-qt.rc
-            Info.plist
-            )
-
-set(HEADERS
-            configuration/config.h
-            configuration/configure_audio.h
-            configuration/configure_debug.h
-            configuration/configure_dialog.h
-            configuration/configure_general.h
-            configuration/configure_graphics.h
-            configuration/configure_input.h
-            configuration/configure_system.h
-            configuration/configure_web.h
-            debugger/graphics/graphics.h
-            debugger/graphics/graphics_breakpoint_observer.h
-            debugger/graphics/graphics_breakpoints.h
-            debugger/graphics/graphics_breakpoints_p.h
-            debugger/graphics/graphics_cmdlists.h
-            debugger/graphics/graphics_surface.h
-            debugger/graphics/graphics_tracing.h
-            debugger/graphics/graphics_vertex_shader.h
-            debugger/profiler.h
-            debugger/registers.h
-            debugger/wait_tree.h
-            updater/updater.h
-            updater/updater_p.h
-            util/spinbox.h
-            util/util.h
-            aboutdialog.h
-            bootmanager.h
-            game_list.h
-            game_list_p.h
-            hotkeys.h
-            main.h
-            ui_settings.h
-            )
+add_executable(citra-qt
+    Info.plist
+    aboutdialog.cpp
+    aboutdialog.h
+    bootmanager.cpp
+    bootmanager.h
+    citra-qt.rc
+    configuration/config.cpp
+    configuration/config.h
+    configuration/configure_audio.cpp
+    configuration/configure_audio.h
+    configuration/configure_debug.cpp
+    configuration/configure_debug.h
+    configuration/configure_dialog.cpp
+    configuration/configure_dialog.h
+    configuration/configure_general.cpp
+    configuration/configure_general.h
+    configuration/configure_graphics.cpp
+    configuration/configure_graphics.h
+    configuration/configure_input.cpp
+    configuration/configure_input.h
+    configuration/configure_system.cpp
+    configuration/configure_system.h
+    configuration/configure_web.cpp
+    configuration/configure_web.h
+    debugger/graphics/graphics.cpp
+    debugger/graphics/graphics.h
+    debugger/graphics/graphics_breakpoint_observer.cpp
+    debugger/graphics/graphics_breakpoint_observer.h
+    debugger/graphics/graphics_breakpoints.cpp
+    debugger/graphics/graphics_breakpoints.h
+    debugger/graphics/graphics_breakpoints_p.h
+    debugger/graphics/graphics_cmdlists.cpp
+    debugger/graphics/graphics_cmdlists.h
+    debugger/graphics/graphics_surface.cpp
+    debugger/graphics/graphics_surface.h
+    debugger/graphics/graphics_tracing.cpp
+    debugger/graphics/graphics_tracing.h
+    debugger/graphics/graphics_vertex_shader.cpp
+    debugger/graphics/graphics_vertex_shader.h
+    debugger/profiler.cpp
+    debugger/profiler.h
+    debugger/registers.cpp
+    debugger/registers.h
+    debugger/wait_tree.cpp
+    debugger/wait_tree.h
+    game_list.cpp
+    game_list.h
+    game_list_p.h
+    hotkeys.cpp
+    hotkeys.h
+    main.cpp
+    main.h
+    ui_settings.cpp
+    ui_settings.h
+    updater/updater.cpp
+    updater/updater.h
+    updater/updater_p.h
+    util/spinbox.cpp
+    util/spinbox.h
+    util/util.cpp
+    util/util.h
+)
 
 set(UIS
-            configuration/configure.ui
-            configuration/configure_audio.ui
-            configuration/configure_debug.ui
-            configuration/configure_general.ui
-            configuration/configure_graphics.ui
-            configuration/configure_input.ui
-            configuration/configure_system.ui
-            configuration/configure_web.ui
-            debugger/registers.ui
-            aboutdialog.ui
-            hotkeys.ui
-            main.ui
-            )
+    configuration/configure.ui
+    configuration/configure_audio.ui
+    configuration/configure_debug.ui
+    configuration/configure_general.ui
+    configuration/configure_graphics.ui
+    configuration/configure_input.ui
+    configuration/configure_system.ui
+    configuration/configure_web.ui
+    debugger/registers.ui
+    aboutdialog.ui
+    hotkeys.ui
+    main.ui
+)
 
 file(GLOB_RECURSE ICONS ${CMAKE_SOURCE_DIR}/dist/icons/*)
 file(GLOB_RECURSE THEMES ${CMAKE_SOURCE_DIR}/dist/qt_themes/*)
 
-create_directory_groups(${SRCS} ${HEADERS} ${UIS})
-
 if (Qt5_FOUND)
     qt5_wrap_ui(UI_HDRS ${UIS})
 else()
     qt4_wrap_ui(UI_HDRS ${UIS})
 endif()
 
+target_sources(citra-qt
+    PRIVATE
+        ${ICONS}
+        ${THEMES}
+        ${UI_HDRS}
+        ${UIS}
+)
+
 if (APPLE)
     set(MACOSX_ICON "../../dist/citra.icns")
     set_source_files_properties(${MACOSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
-    add_executable(citra-qt MACOSX_BUNDLE ${SRCS} ${HEADERS} ${UI_HDRS} ${ICONS} ${THEMES} ${MACOSX_ICON})
+    target_sources(citra-qt PRIVATE ${MACOSX_ICON})
+    set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE TRUE)
     set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
-else()
-    add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS} ${ICONS} ${THEMES})
 endif()
+
+create_target_directory_groups(citra-qt)
+
 target_link_libraries(citra-qt PRIVATE audio_core common core input_common network video_core)
 target_link_libraries(citra-qt PRIVATE Boost::boost glad nihstro-headers Qt5::OpenGL Qt5::Widgets)
 target_link_libraries(citra-qt PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 447d7198c..bdec3c43f 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -24,78 +24,73 @@ if ($ENV{CI})
 endif()
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY)
 
-set(SRCS
-            break_points.cpp
-            file_util.cpp
-            hash.cpp
-            logging/filter.cpp
-            logging/text_formatter.cpp
-            logging/backend.cpp
-            memory_util.cpp
-            microprofile.cpp
-            misc.cpp
-            param_package.cpp
-            scm_rev.cpp
-            string_util.cpp
-            telemetry.cpp
-            thread.cpp
-            timer.cpp
-            )
-
-set(HEADERS
-            alignment.h
-            assert.h
-            bit_field.h
-            bit_set.h
-            break_points.h
-            chunk_file.h
-            code_block.h
-            color.h
-            common_funcs.h
-            common_paths.h
-            common_types.h
-            file_util.h
-            hash.h
-            linear_disk_cache.h
-            logging/text_formatter.h
-            logging/filter.h
-            logging/log.h
-            logging/backend.h
-            math_util.h
-            memory_util.h
-            microprofile.h
-            microprofileui.h
-            param_package.h
-            platform.h
-            quaternion.h
-            scm_rev.h
-            scope_exit.h
-            string_util.h
-            swap.h
-            synchronized_wrapper.h
-            telemetry.h
-            thread.h
-            thread_queue_list.h
-            threadsafe_queue.h
-            timer.h
-            vector_math.h
-            )
+add_library(common STATIC
+    alignment.h
+    assert.h
+    bit_field.h
+    bit_set.h
+    break_points.cpp
+    break_points.h
+    chunk_file.h
+    code_block.h
+    color.h
+    common_funcs.h
+    common_paths.h
+    common_types.h
+    file_util.cpp
+    file_util.h
+    hash.cpp
+    hash.h
+    linear_disk_cache.h
+    logging/backend.cpp
+    logging/backend.h
+    logging/filter.cpp
+    logging/filter.h
+    logging/log.h
+    logging/text_formatter.cpp
+    logging/text_formatter.h
+    math_util.h
+    memory_util.cpp
+    memory_util.h
+    microprofile.cpp
+    microprofile.h
+    microprofileui.h
+    misc.cpp
+    param_package.cpp
+    param_package.h
+    platform.h
+    quaternion.h
+    scm_rev.cpp
+    scm_rev.h
+    scope_exit.h
+    string_util.cpp
+    string_util.h
+    swap.h
+    synchronized_wrapper.h
+    telemetry.cpp
+    telemetry.h
+    thread.cpp
+    thread.h
+    thread_queue_list.h
+    threadsafe_queue.h
+    timer.cpp
+    timer.h
+    vector_math.h
+)
 
 if(ARCHITECTURE_x86_64)
-    set(SRCS ${SRCS}
+    target_sources(common
+        PRIVATE
             x64/cpu_detect.cpp
-            )
 
-    set(HEADERS ${HEADERS}
             x64/cpu_detect.h
             x64/xbyak_abi.h
             x64/xbyak_util.h
-            )
+    )
 endif()
 
-create_directory_groups(${SRCS} ${HEADERS})
+create_target_directory_groups(common)
 
-add_library(common STATIC ${SRCS} ${HEADERS})
 target_link_libraries(common PUBLIC Boost::boost microprofile)
 if (ARCHITECTURE_x86_64)
     target_link_libraries(common PRIVATE xbyak)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 92be226cd..b8d22bd1a 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -1,409 +1,406 @@
-set(SRCS
-            arm/dynarmic/arm_dynarmic.cpp
-            arm/dynarmic/arm_dynarmic_cp15.cpp
-            arm/dyncom/arm_dyncom.cpp
-            arm/dyncom/arm_dyncom_dec.cpp
-            arm/dyncom/arm_dyncom_interpreter.cpp
-            arm/dyncom/arm_dyncom_thumb.cpp
-            arm/dyncom/arm_dyncom_trans.cpp
-            arm/skyeye_common/armstate.cpp
-            arm/skyeye_common/armsupp.cpp
-            arm/skyeye_common/vfp/vfp.cpp
-            arm/skyeye_common/vfp/vfpdouble.cpp
-            arm/skyeye_common/vfp/vfpinstr.cpp
-            arm/skyeye_common/vfp/vfpsingle.cpp
-            core.cpp
-            core_timing.cpp
-            file_sys/archive_backend.cpp
-            file_sys/archive_extsavedata.cpp
-            file_sys/archive_ncch.cpp
-            file_sys/archive_other_savedata.cpp
-            file_sys/archive_savedata.cpp
-            file_sys/archive_sdmc.cpp
-            file_sys/archive_sdmcwriteonly.cpp
-            file_sys/archive_selfncch.cpp
-            file_sys/archive_source_sd_savedata.cpp
-            file_sys/archive_systemsavedata.cpp
-            file_sys/cia_container.cpp
-            file_sys/disk_archive.cpp
-            file_sys/ivfc_archive.cpp
-            file_sys/ncch_container.cpp
-            file_sys/path_parser.cpp
-            file_sys/savedata_archive.cpp
-            file_sys/title_metadata.cpp
-            frontend/camera/blank_camera.cpp
-            frontend/camera/factory.cpp
-            frontend/camera/interface.cpp
-            frontend/emu_window.cpp
-            frontend/framebuffer_layout.cpp
-            gdbstub/gdbstub.cpp
-            hle/config_mem.cpp
-            hle/applets/applet.cpp
-            hle/applets/erreula.cpp
-            hle/applets/mii_selector.cpp
-            hle/applets/mint.cpp
-            hle/applets/swkbd.cpp
-            hle/kernel/address_arbiter.cpp
-            hle/kernel/client_port.cpp
-            hle/kernel/client_session.cpp
-            hle/kernel/event.cpp
-            hle/kernel/handle_table.cpp
-            hle/kernel/hle_ipc.cpp
-            hle/kernel/kernel.cpp
-            hle/kernel/memory.cpp
-            hle/kernel/mutex.cpp
-            hle/kernel/process.cpp
-            hle/kernel/resource_limit.cpp
-            hle/kernel/semaphore.cpp
-            hle/kernel/server_port.cpp
-            hle/kernel/server_session.cpp
-            hle/kernel/shared_memory.cpp
-            hle/kernel/svc.cpp
-            hle/kernel/thread.cpp
-            hle/kernel/timer.cpp
-            hle/kernel/vm_manager.cpp
-            hle/kernel/wait_object.cpp
-            hle/kernel/ipc.cpp
-            hle/lock.cpp
-            hle/romfs.cpp
-            hle/service/ac/ac.cpp
-            hle/service/ac/ac_i.cpp
-            hle/service/ac/ac_u.cpp
-            hle/service/act/act.cpp
-            hle/service/act/act_a.cpp
-            hle/service/act/act_u.cpp
-            hle/service/am/am.cpp
-            hle/service/am/am_app.cpp
-            hle/service/am/am_net.cpp
-            hle/service/am/am_sys.cpp
-            hle/service/am/am_u.cpp
-            hle/service/apt/apt.cpp
-            hle/service/apt/apt_a.cpp
-            hle/service/apt/apt_s.cpp
-            hle/service/apt/apt_u.cpp
-            hle/service/apt/bcfnt/bcfnt.cpp
-            hle/service/boss/boss.cpp
-            hle/service/boss/boss_p.cpp
-            hle/service/boss/boss_u.cpp
-            hle/service/cam/cam.cpp
-            hle/service/cam/cam_c.cpp
-            hle/service/cam/cam_q.cpp
-            hle/service/cam/cam_s.cpp
-            hle/service/cam/cam_u.cpp
-            hle/service/cecd/cecd.cpp
-            hle/service/cecd/cecd_ndm.cpp
-            hle/service/cecd/cecd_s.cpp
-            hle/service/cecd/cecd_u.cpp
-            hle/service/cfg/cfg.cpp
-            hle/service/cfg/cfg_i.cpp
-            hle/service/cfg/cfg_nor.cpp
-            hle/service/cfg/cfg_s.cpp
-            hle/service/cfg/cfg_u.cpp
-            hle/service/csnd_snd.cpp
-            hle/service/dlp/dlp.cpp
-            hle/service/dlp/dlp_clnt.cpp
-            hle/service/dlp/dlp_fkcl.cpp
-            hle/service/dlp/dlp_srvr.cpp
-            hle/service/dsp_dsp.cpp
-            hle/service/err_f.cpp
-            hle/service/frd/frd.cpp
-            hle/service/frd/frd_a.cpp
-            hle/service/frd/frd_u.cpp
-            hle/service/fs/archive.cpp
-            hle/service/fs/fs_user.cpp
-            hle/service/gsp_gpu.cpp
-            hle/service/gsp_lcd.cpp
-            hle/service/hid/hid.cpp
-            hle/service/hid/hid_spvr.cpp
-            hle/service/hid/hid_user.cpp
-            hle/service/http_c.cpp
-            hle/service/ir/extra_hid.cpp
-            hle/service/ir/ir.cpp
-            hle/service/ir/ir_rst.cpp
-            hle/service/ir/ir_u.cpp
-            hle/service/ir/ir_user.cpp
-            hle/service/ldr_ro/cro_helper.cpp
-            hle/service/ldr_ro/ldr_ro.cpp
-            hle/service/ldr_ro/memory_synchronizer.cpp
-            hle/service/mic_u.cpp
-            hle/service/mvd/mvd.cpp
-            hle/service/mvd/mvd_std.cpp
-            hle/service/ndm/ndm.cpp
-            hle/service/ndm/ndm_u.cpp
-            hle/service/nfc/nfc.cpp
-            hle/service/nfc/nfc_m.cpp
-            hle/service/nfc/nfc_u.cpp
-            hle/service/news/news.cpp
-            hle/service/news/news_s.cpp
-            hle/service/news/news_u.cpp
-            hle/service/nim/nim.cpp
-            hle/service/nim/nim_aoc.cpp
-            hle/service/nim/nim_s.cpp
-            hle/service/nim/nim_u.cpp
-            hle/service/ns/ns.cpp
-            hle/service/ns/ns_s.cpp
-            hle/service/nwm/nwm.cpp
-            hle/service/nwm/nwm_cec.cpp
-            hle/service/nwm/nwm_ext.cpp
-            hle/service/nwm/nwm_inf.cpp
-            hle/service/nwm/nwm_sap.cpp
-            hle/service/nwm/nwm_soc.cpp
-            hle/service/nwm/nwm_tst.cpp
-            hle/service/nwm/nwm_uds.cpp
-            hle/service/nwm/uds_beacon.cpp
-            hle/service/nwm/uds_connection.cpp
-            hle/service/nwm/uds_data.cpp
-            hle/service/pm_app.cpp
-            hle/service/ptm/ptm.cpp
-            hle/service/ptm/ptm_gets.cpp
-            hle/service/ptm/ptm_play.cpp
-            hle/service/ptm/ptm_sets.cpp
-            hle/service/ptm/ptm_sysm.cpp
-            hle/service/ptm/ptm_u.cpp
-            hle/service/pxi/dev.cpp
-            hle/service/pxi/pxi.cpp
-            hle/service/qtm/qtm.cpp
-            hle/service/qtm/qtm_s.cpp
-            hle/service/qtm/qtm_sp.cpp
-            hle/service/qtm/qtm_u.cpp
-            hle/service/service.cpp
-            hle/service/sm/sm.cpp
-            hle/service/sm/srv.cpp
-            hle/service/soc_u.cpp
-            hle/service/ssl_c.cpp
-            hle/service/y2r_u.cpp
-            hle/shared_page.cpp
-            hw/aes/arithmetic128.cpp
-            hw/aes/ccm.cpp
-            hw/aes/key.cpp
-            hw/gpu.cpp
-            hw/hw.cpp
-            hw/lcd.cpp
-            hw/y2r.cpp
-            loader/3dsx.cpp
-            loader/elf.cpp
-            loader/loader.cpp
-            loader/ncch.cpp
-            loader/smdh.cpp
-            tracer/recorder.cpp
-            memory.cpp
-            perf_stats.cpp
-            settings.cpp
-            telemetry_session.cpp
-            )
+add_library(core STATIC
+    3ds.h
+    arm/arm_interface.h
+    arm/dynarmic/arm_dynarmic.cpp
+    arm/dynarmic/arm_dynarmic.h
+    arm/dynarmic/arm_dynarmic_cp15.cpp
+    arm/dynarmic/arm_dynarmic_cp15.h
+    arm/dyncom/arm_dyncom.cpp
+    arm/dyncom/arm_dyncom.h
+    arm/dyncom/arm_dyncom_dec.cpp
+    arm/dyncom/arm_dyncom_dec.h
+    arm/dyncom/arm_dyncom_interpreter.cpp
+    arm/dyncom/arm_dyncom_interpreter.h
+    arm/dyncom/arm_dyncom_run.h
+    arm/dyncom/arm_dyncom_thumb.cpp
+    arm/dyncom/arm_dyncom_thumb.h
+    arm/dyncom/arm_dyncom_trans.cpp
+    arm/dyncom/arm_dyncom_trans.h
+    arm/skyeye_common/arm_regformat.h
+    arm/skyeye_common/armstate.cpp
+    arm/skyeye_common/armstate.h
+    arm/skyeye_common/armsupp.cpp
+    arm/skyeye_common/armsupp.h
+    arm/skyeye_common/vfp/asm_vfp.h
+    arm/skyeye_common/vfp/vfp.cpp
+    arm/skyeye_common/vfp/vfp.h
+    arm/skyeye_common/vfp/vfp_helper.h
+    arm/skyeye_common/vfp/vfpdouble.cpp
+    arm/skyeye_common/vfp/vfpinstr.cpp
+    arm/skyeye_common/vfp/vfpsingle.cpp
+    core.cpp
+    core.h
+    core_timing.cpp
+    core_timing.h
+    file_sys/archive_backend.cpp
+    file_sys/archive_backend.h
+    file_sys/archive_extsavedata.cpp
+    file_sys/archive_extsavedata.h
+    file_sys/archive_ncch.cpp
+    file_sys/archive_ncch.h
+    file_sys/archive_other_savedata.cpp
+    file_sys/archive_other_savedata.h
+    file_sys/archive_savedata.cpp
+    file_sys/archive_savedata.h
+    file_sys/archive_sdmc.cpp
+    file_sys/archive_sdmc.h
+    file_sys/archive_sdmcwriteonly.cpp
+    file_sys/archive_sdmcwriteonly.h
+    file_sys/archive_selfncch.cpp
+    file_sys/archive_selfncch.h
+    file_sys/archive_source_sd_savedata.cpp
+    file_sys/archive_source_sd_savedata.h
+    file_sys/archive_systemsavedata.cpp
+    file_sys/archive_systemsavedata.h
+    file_sys/cia_container.cpp
+    file_sys/cia_container.h
+    file_sys/directory_backend.h
+    file_sys/disk_archive.cpp
+    file_sys/disk_archive.h
+    file_sys/errors.h
+    file_sys/file_backend.h
+    file_sys/ivfc_archive.cpp
+    file_sys/ivfc_archive.h
+    file_sys/ncch_container.cpp
+    file_sys/ncch_container.h
+    file_sys/path_parser.cpp
+    file_sys/path_parser.h
+    file_sys/savedata_archive.cpp
+    file_sys/savedata_archive.h
+    file_sys/title_metadata.cpp
+    file_sys/title_metadata.h
+    frontend/camera/blank_camera.cpp
+    frontend/camera/blank_camera.h
+    frontend/camera/factory.cpp
+    frontend/camera/factory.h
+    frontend/camera/interface.cpp
+    frontend/camera/interface.h
+    frontend/emu_window.cpp
+    frontend/emu_window.h
+    frontend/framebuffer_layout.cpp
+    frontend/framebuffer_layout.h
+    frontend/input.h
+    gdbstub/gdbstub.cpp
+    gdbstub/gdbstub.h
+    hle/applets/applet.cpp
+    hle/applets/applet.h
+    hle/applets/erreula.cpp
+    hle/applets/erreula.h
+    hle/applets/mii_selector.cpp
+    hle/applets/mii_selector.h
+    hle/applets/mint.cpp
+    hle/applets/mint.h
+    hle/applets/swkbd.cpp
+    hle/applets/swkbd.h
+    hle/config_mem.cpp
+    hle/config_mem.h
+    hle/function_wrappers.h
+    hle/ipc.h
+    hle/ipc_helpers.h
+    hle/kernel/address_arbiter.cpp
+    hle/kernel/address_arbiter.h
+    hle/kernel/client_port.cpp
+    hle/kernel/client_port.h
+    hle/kernel/client_session.cpp
+    hle/kernel/client_session.h
+    hle/kernel/errors.h
+    hle/kernel/event.cpp
+    hle/kernel/event.h
+    hle/kernel/handle_table.cpp
+    hle/kernel/handle_table.h
+    hle/kernel/hle_ipc.cpp
+    hle/kernel/hle_ipc.h
+    hle/kernel/ipc.cpp
+    hle/kernel/ipc.h
+    hle/kernel/kernel.cpp
+    hle/kernel/kernel.h
+    hle/kernel/memory.cpp
+    hle/kernel/memory.h
+    hle/kernel/mutex.cpp
+    hle/kernel/mutex.h
+    hle/kernel/process.cpp
+    hle/kernel/process.h
+    hle/kernel/resource_limit.cpp
+    hle/kernel/resource_limit.h
+    hle/kernel/semaphore.cpp
+    hle/kernel/semaphore.h
+    hle/kernel/server_port.cpp
+    hle/kernel/server_port.h
+    hle/kernel/server_session.cpp
+    hle/kernel/server_session.h
+    hle/kernel/session.h
+    hle/kernel/shared_memory.cpp
+    hle/kernel/shared_memory.h
+    hle/kernel/svc.cpp
+    hle/kernel/svc.h
+    hle/kernel/thread.cpp
+    hle/kernel/thread.h
+    hle/kernel/timer.cpp
+    hle/kernel/timer.h
+    hle/kernel/vm_manager.cpp
+    hle/kernel/vm_manager.h
+    hle/kernel/wait_object.cpp
+    hle/kernel/wait_object.h
+    hle/lock.cpp
+    hle/lock.h
+    hle/result.h
+    hle/romfs.cpp
+    hle/romfs.h
+    hle/service/ac/ac.cpp
+    hle/service/ac/ac.h
+    hle/service/ac/ac_i.cpp
+    hle/service/ac/ac_i.h
+    hle/service/ac/ac_u.cpp
+    hle/service/ac/ac_u.h
+    hle/service/act/act.cpp
+    hle/service/act/act.h
+    hle/service/act/act_a.cpp
+    hle/service/act/act_a.h
+    hle/service/act/act_u.cpp
+    hle/service/act/act_u.h
+    hle/service/am/am.cpp
+    hle/service/am/am.h
+    hle/service/am/am_app.cpp
+    hle/service/am/am_app.h
+    hle/service/am/am_net.cpp
+    hle/service/am/am_net.h
+    hle/service/am/am_sys.cpp
+    hle/service/am/am_sys.h
+    hle/service/am/am_u.cpp
+    hle/service/am/am_u.h
+    hle/service/apt/apt.cpp
+    hle/service/apt/apt.h
+    hle/service/apt/apt_a.cpp
+    hle/service/apt/apt_a.h
+    hle/service/apt/apt_s.cpp
+    hle/service/apt/apt_s.h
+    hle/service/apt/apt_u.cpp
+    hle/service/apt/apt_u.h
+    hle/service/apt/bcfnt/bcfnt.cpp
+    hle/service/apt/bcfnt/bcfnt.h
+    hle/service/boss/boss.cpp
+    hle/service/boss/boss.h
+    hle/service/boss/boss_p.cpp
+    hle/service/boss/boss_p.h
+    hle/service/boss/boss_u.cpp
+    hle/service/boss/boss_u.h
+    hle/service/cam/cam.cpp
+    hle/service/cam/cam.h
+    hle/service/cam/cam_c.cpp
+    hle/service/cam/cam_c.h
+    hle/service/cam/cam_q.cpp
+    hle/service/cam/cam_q.h
+    hle/service/cam/cam_s.cpp
+    hle/service/cam/cam_s.h
+    hle/service/cam/cam_u.cpp
+    hle/service/cam/cam_u.h
+    hle/service/cecd/cecd.cpp
+    hle/service/cecd/cecd.h
+    hle/service/cecd/cecd_ndm.cpp
+    hle/service/cecd/cecd_ndm.h
+    hle/service/cecd/cecd_s.cpp
+    hle/service/cecd/cecd_s.h
+    hle/service/cecd/cecd_u.cpp
+    hle/service/cecd/cecd_u.h
+    hle/service/cfg/cfg.cpp
+    hle/service/cfg/cfg.h
+    hle/service/cfg/cfg_i.cpp
+    hle/service/cfg/cfg_i.h
+    hle/service/cfg/cfg_nor.cpp
+    hle/service/cfg/cfg_nor.h
+    hle/service/cfg/cfg_s.cpp
+    hle/service/cfg/cfg_s.h
+    hle/service/cfg/cfg_u.cpp
+    hle/service/cfg/cfg_u.h
+    hle/service/csnd_snd.cpp
+    hle/service/csnd_snd.h
+    hle/service/dlp/dlp.cpp
+    hle/service/dlp/dlp.h
+    hle/service/dlp/dlp_clnt.cpp
+    hle/service/dlp/dlp_clnt.h
+    hle/service/dlp/dlp_fkcl.cpp
+    hle/service/dlp/dlp_fkcl.h
+    hle/service/dlp/dlp_srvr.cpp
+    hle/service/dlp/dlp_srvr.h
+    hle/service/dsp_dsp.cpp
+    hle/service/dsp_dsp.h
+    hle/service/err_f.cpp
+    hle/service/err_f.h
+    hle/service/frd/frd.cpp
+    hle/service/frd/frd.h
+    hle/service/frd/frd_a.cpp
+    hle/service/frd/frd_a.h
+    hle/service/frd/frd_u.cpp
+    hle/service/frd/frd_u.h
+    hle/service/fs/archive.cpp
+    hle/service/fs/archive.h
+    hle/service/fs/fs_user.cpp
+    hle/service/fs/fs_user.h
+    hle/service/gsp_gpu.cpp
+    hle/service/gsp_gpu.h
+    hle/service/gsp_lcd.cpp
+    hle/service/gsp_lcd.h
+    hle/service/hid/hid.cpp
+    hle/service/hid/hid.h
+    hle/service/hid/hid_spvr.cpp
+    hle/service/hid/hid_spvr.h
+    hle/service/hid/hid_user.cpp
+    hle/service/hid/hid_user.h
+    hle/service/http_c.cpp
+    hle/service/http_c.h
+    hle/service/ir/extra_hid.cpp
+    hle/service/ir/extra_hid.h
+    hle/service/ir/ir.cpp
+    hle/service/ir/ir.h
+    hle/service/ir/ir_rst.cpp
+    hle/service/ir/ir_rst.h
+    hle/service/ir/ir_u.cpp
+    hle/service/ir/ir_u.h
+    hle/service/ir/ir_user.cpp
+    hle/service/ir/ir_user.h
+    hle/service/ldr_ro/cro_helper.cpp
+    hle/service/ldr_ro/cro_helper.h
+    hle/service/ldr_ro/ldr_ro.cpp
+    hle/service/ldr_ro/ldr_ro.h
+    hle/service/ldr_ro/memory_synchronizer.cpp
+    hle/service/ldr_ro/memory_synchronizer.h
+    hle/service/mic_u.cpp
+    hle/service/mic_u.h
+    hle/service/mvd/mvd.cpp
+    hle/service/mvd/mvd.h
+    hle/service/mvd/mvd_std.cpp
+    hle/service/mvd/mvd_std.h
+    hle/service/ndm/ndm.cpp
+    hle/service/ndm/ndm.h
+    hle/service/ndm/ndm_u.cpp
+    hle/service/ndm/ndm_u.h
+    hle/service/news/news.cpp
+    hle/service/news/news.h
+    hle/service/news/news_s.cpp
+    hle/service/news/news_s.h
+    hle/service/news/news_u.cpp
+    hle/service/news/news_u.h
+    hle/service/nfc/nfc.cpp
+    hle/service/nfc/nfc.h
+    hle/service/nfc/nfc_m.cpp
+    hle/service/nfc/nfc_m.h
+    hle/service/nfc/nfc_u.cpp
+    hle/service/nfc/nfc_u.h
+    hle/service/nim/nim.cpp
+    hle/service/nim/nim.h
+    hle/service/nim/nim_aoc.cpp
+    hle/service/nim/nim_aoc.h
+    hle/service/nim/nim_s.cpp
+    hle/service/nim/nim_s.h
+    hle/service/nim/nim_u.cpp
+    hle/service/nim/nim_u.h
+    hle/service/ns/ns.cpp
+    hle/service/ns/ns.h
+    hle/service/ns/ns_s.cpp
+    hle/service/ns/ns_s.h
+    hle/service/nwm/nwm.cpp
+    hle/service/nwm/nwm.h
+    hle/service/nwm/nwm_cec.cpp
+    hle/service/nwm/nwm_cec.h
+    hle/service/nwm/nwm_ext.cpp
+    hle/service/nwm/nwm_ext.h
+    hle/service/nwm/nwm_inf.cpp
+    hle/service/nwm/nwm_inf.h
+    hle/service/nwm/nwm_sap.cpp
+    hle/service/nwm/nwm_sap.h
+    hle/service/nwm/nwm_soc.cpp
+    hle/service/nwm/nwm_soc.h
+    hle/service/nwm/nwm_tst.cpp
+    hle/service/nwm/nwm_tst.h
+    hle/service/nwm/nwm_uds.cpp
+    hle/service/nwm/nwm_uds.h
+    hle/service/nwm/uds_beacon.cpp
+    hle/service/nwm/uds_beacon.h
+    hle/service/nwm/uds_connection.cpp
+    hle/service/nwm/uds_connection.h
+    hle/service/nwm/uds_data.cpp
+    hle/service/nwm/uds_data.h
+    hle/service/pm_app.cpp
+    hle/service/pm_app.h
+    hle/service/ptm/ptm.cpp
+    hle/service/ptm/ptm.h
+    hle/service/ptm/ptm_gets.cpp
+    hle/service/ptm/ptm_gets.h
+    hle/service/ptm/ptm_play.cpp
+    hle/service/ptm/ptm_play.h
+    hle/service/ptm/ptm_sets.cpp
+    hle/service/ptm/ptm_sets.h
+    hle/service/ptm/ptm_sysm.cpp
+    hle/service/ptm/ptm_sysm.h
+    hle/service/ptm/ptm_u.cpp
+    hle/service/ptm/ptm_u.h
+    hle/service/pxi/dev.cpp
+    hle/service/pxi/dev.h
+    hle/service/pxi/pxi.cpp
+    hle/service/pxi/pxi.h
+    hle/service/qtm/qtm.cpp
+    hle/service/qtm/qtm.h
+    hle/service/qtm/qtm_s.cpp
+    hle/service/qtm/qtm_s.h
+    hle/service/qtm/qtm_sp.cpp
+    hle/service/qtm/qtm_sp.h
+    hle/service/qtm/qtm_u.cpp
+    hle/service/qtm/qtm_u.h
+    hle/service/service.cpp
+    hle/service/service.h
+    hle/service/sm/sm.cpp
+    hle/service/sm/sm.h
+    hle/service/sm/srv.cpp
+    hle/service/sm/srv.h
+    hle/service/soc_u.cpp
+    hle/service/soc_u.h
+    hle/service/ssl_c.cpp
+    hle/service/ssl_c.h
+    hle/service/y2r_u.cpp
+    hle/service/y2r_u.h
+    hle/shared_page.cpp
+    hle/shared_page.h
+    hw/aes/arithmetic128.cpp
+    hw/aes/arithmetic128.h
+    hw/aes/ccm.cpp
+    hw/aes/ccm.h
+    hw/aes/key.cpp
+    hw/aes/key.h
+    hw/gpu.cpp
+    hw/gpu.h
+    hw/hw.cpp
+    hw/hw.h
+    hw/lcd.cpp
+    hw/lcd.h
+    hw/y2r.cpp
+    hw/y2r.h
+    loader/3dsx.cpp
+    loader/3dsx.h
+    loader/elf.cpp
+    loader/elf.h
+    loader/loader.cpp
+    loader/loader.h
+    loader/ncch.cpp
+    loader/ncch.h
+    loader/smdh.cpp
+    loader/smdh.h
+    memory.cpp
+    memory.h
+    memory_setup.h
+    mmio.h
+    perf_stats.cpp
+    perf_stats.h
+    settings.cpp
+    settings.h
+    telemetry_session.cpp
+    telemetry_session.h
+    tracer/citrace.h
+    tracer/recorder.cpp
+    tracer/recorder.h
+)
 
-set(HEADERS
-            3ds.h
-            arm/arm_interface.h
-            arm/dynarmic/arm_dynarmic.h
-            arm/dynarmic/arm_dynarmic_cp15.h
-            arm/dyncom/arm_dyncom.h
-            arm/dyncom/arm_dyncom_dec.h
-            arm/dyncom/arm_dyncom_interpreter.h
-            arm/dyncom/arm_dyncom_run.h
-            arm/dyncom/arm_dyncom_thumb.h
-            arm/dyncom/arm_dyncom_trans.h
-            arm/skyeye_common/arm_regformat.h
-            arm/skyeye_common/armstate.h
-            arm/skyeye_common/armsupp.h
-            arm/skyeye_common/vfp/asm_vfp.h
-            arm/skyeye_common/vfp/vfp.h
-            arm/skyeye_common/vfp/vfp_helper.h
-            core.h
-            core_timing.h
-            file_sys/archive_backend.h
-            file_sys/archive_extsavedata.h
-            file_sys/archive_ncch.h
-            file_sys/archive_other_savedata.h
-            file_sys/archive_savedata.h
-            file_sys/archive_sdmc.h
-            file_sys/archive_sdmcwriteonly.h
-            file_sys/archive_selfncch.h
-            file_sys/archive_source_sd_savedata.h
-            file_sys/archive_systemsavedata.h
-            file_sys/cia_container.h
-            file_sys/directory_backend.h
-            file_sys/disk_archive.h
-            file_sys/errors.h
-            file_sys/file_backend.h
-            file_sys/ivfc_archive.h
-            file_sys/ncch_container.h
-            file_sys/path_parser.h
-            file_sys/savedata_archive.h
-            file_sys/title_metadata.h
-            frontend/camera/blank_camera.h
-            frontend/camera/factory.h
-            frontend/camera/interface.h
-            frontend/emu_window.h
-            frontend/framebuffer_layout.h
-            frontend/input.h
-            gdbstub/gdbstub.h
-            hle/config_mem.h
-            hle/function_wrappers.h
-            hle/ipc.h
-            hle/ipc_helpers.h
-            hle/applets/applet.h
-            hle/applets/erreula.h
-            hle/applets/mii_selector.h
-            hle/applets/mint.h
-            hle/applets/swkbd.h
-            hle/kernel/address_arbiter.h
-            hle/kernel/client_port.h
-            hle/kernel/client_session.h
-            hle/kernel/errors.h
-            hle/kernel/event.h
-            hle/kernel/handle_table.h
-            hle/kernel/hle_ipc.h
-            hle/kernel/ipc.h
-            hle/kernel/kernel.h
-            hle/kernel/memory.h
-            hle/kernel/mutex.h
-            hle/kernel/process.h
-            hle/kernel/resource_limit.h
-            hle/kernel/semaphore.h
-            hle/kernel/server_port.h
-            hle/kernel/server_session.h
-            hle/kernel/session.h
-            hle/kernel/shared_memory.h
-            hle/kernel/svc.h
-            hle/kernel/thread.h
-            hle/kernel/timer.h
-            hle/kernel/vm_manager.h
-            hle/kernel/wait_object.h
-            hle/lock.h
-            hle/result.h
-            hle/romfs.h
-            hle/service/ac/ac.h
-            hle/service/ac/ac_i.h
-            hle/service/ac/ac_u.h
-            hle/service/act/act.h
-            hle/service/act/act_a.h
-            hle/service/act/act_u.h
-            hle/service/am/am.h
-            hle/service/am/am_app.h
-            hle/service/am/am_net.h
-            hle/service/am/am_sys.h
-            hle/service/am/am_u.h
-            hle/service/apt/apt.h
-            hle/service/apt/apt_a.h
-            hle/service/apt/apt_s.h
-            hle/service/apt/apt_u.h
-            hle/service/apt/bcfnt/bcfnt.h
-            hle/service/boss/boss.h
-            hle/service/boss/boss_p.h
-            hle/service/boss/boss_u.h
-            hle/service/cam/cam.h
-            hle/service/cam/cam_c.h
-            hle/service/cam/cam_q.h
-            hle/service/cam/cam_s.h
-            hle/service/cam/cam_u.h
-            hle/service/cecd/cecd.h
-            hle/service/cecd/cecd_ndm.h
-            hle/service/cecd/cecd_s.h
-            hle/service/cecd/cecd_u.h
-            hle/service/cfg/cfg.h
-            hle/service/cfg/cfg_i.h
-            hle/service/cfg/cfg_nor.h
-            hle/service/cfg/cfg_s.h
-            hle/service/cfg/cfg_u.h
-            hle/service/csnd_snd.h
-            hle/service/dlp/dlp.h
-            hle/service/dlp/dlp_clnt.h
-            hle/service/dlp/dlp_fkcl.h
-            hle/service/dlp/dlp_srvr.h
-            hle/service/dsp_dsp.h
-            hle/service/err_f.h
-            hle/service/frd/frd.h
-            hle/service/frd/frd_a.h
-            hle/service/frd/frd_u.h
-            hle/service/fs/archive.h
-            hle/service/fs/fs_user.h
-            hle/service/gsp_gpu.h
-            hle/service/gsp_lcd.h
-            hle/service/hid/hid.h
-            hle/service/hid/hid_spvr.h
-            hle/service/hid/hid_user.h
-            hle/service/http_c.h
-            hle/service/ir/extra_hid.h
-            hle/service/ir/ir.h
-            hle/service/ir/ir_rst.h
-            hle/service/ir/ir_u.h
-            hle/service/ir/ir_user.h
-            hle/service/ldr_ro/cro_helper.h
-            hle/service/ldr_ro/ldr_ro.h
-            hle/service/ldr_ro/memory_synchronizer.h
-            hle/service/mic_u.h
-            hle/service/mvd/mvd.h
-            hle/service/mvd/mvd_std.h
-            hle/service/ndm/ndm.h
-            hle/service/ndm/ndm_u.h
-            hle/service/nfc/nfc.h
-            hle/service/nfc/nfc_m.h
-            hle/service/nfc/nfc_u.h
-            hle/service/news/news.h
-            hle/service/news/news_s.h
-            hle/service/news/news_u.h
-            hle/service/nim/nim.h
-            hle/service/nim/nim_aoc.h
-            hle/service/nim/nim_s.h
-            hle/service/nim/nim_u.h
-            hle/service/ns/ns.h
-            hle/service/ns/ns_s.h
-            hle/service/nwm/nwm.h
-            hle/service/nwm/nwm_cec.h
-            hle/service/nwm/nwm_ext.h
-            hle/service/nwm/nwm_inf.h
-            hle/service/nwm/nwm_sap.h
-            hle/service/nwm/nwm_soc.h
-            hle/service/nwm/nwm_tst.h
-            hle/service/nwm/nwm_uds.h
-            hle/service/nwm/uds_beacon.h
-            hle/service/nwm/uds_connection.h
-            hle/service/nwm/uds_data.h
-            hle/service/pm_app.h
-            hle/service/ptm/ptm.h
-            hle/service/ptm/ptm_gets.h
-            hle/service/ptm/ptm_play.h
-            hle/service/ptm/ptm_sets.h
-            hle/service/ptm/ptm_sysm.h
-            hle/service/ptm/ptm_u.h
-            hle/service/pxi/dev.h
-            hle/service/pxi/pxi.h
-            hle/service/qtm/qtm.h
-            hle/service/qtm/qtm_s.h
-            hle/service/qtm/qtm_sp.h
-            hle/service/qtm/qtm_u.h
-            hle/service/service.h
-            hle/service/sm/sm.h
-            hle/service/sm/srv.h
-            hle/service/soc_u.h
-            hle/service/ssl_c.h
-            hle/service/y2r_u.h
-            hle/shared_page.h
-            hw/aes/arithmetic128.h
-            hw/aes/ccm.h
-            hw/aes/key.h
-            hw/gpu.h
-            hw/hw.h
-            hw/lcd.h
-            hw/y2r.h
-            loader/3dsx.h
-            loader/elf.h
-            loader/loader.h
-            loader/ncch.h
-            loader/smdh.h
-            tracer/recorder.h
-            tracer/citrace.h
-            memory.h
-            memory_setup.h
-            mmio.h
-            perf_stats.h
-            settings.h
-            telemetry_session.h
-            )
+create_target_directory_groups(core)
 
-create_directory_groups(${SRCS} ${HEADERS})
-add_library(core STATIC ${SRCS} ${HEADERS})
 target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
 target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp dynarmic fmt)
 if (ENABLE_WEB_SERVICE)
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt
index 92792a702..a19768326 100644
--- a/src/input_common/CMakeLists.txt
+++ b/src/input_common/CMakeLists.txt
@@ -1,25 +1,26 @@
-set(SRCS
-            analog_from_button.cpp
-            keyboard.cpp
-            main.cpp
-            motion_emu.cpp
-            )
+add_library(input_common STATIC
+    analog_from_button.cpp
+    analog_from_button.h
+    keyboard.cpp
+    keyboard.h
+    main.cpp
+    main.h
+    motion_emu.cpp
+    motion_emu.h
 
-set(HEADERS
-            analog_from_button.h
-            keyboard.h
-            main.h
-            motion_emu.h
-            )
+    $<$<BOOL:SDL2_FOUND>:sdl/sdl.cpp sdl/sdl.h>
+)
 
 if(SDL2_FOUND)
-    set(SRCS ${SRCS} sdl/sdl.cpp)
-    set(HEADERS ${HEADERS} sdl/sdl.h)
+    target_sources(input_common
+        PRIVATE
+            sdl/sdl.cpp
+            sdl/sdl.h
+    )
 endif()
 
-create_directory_groups(${SRCS} ${HEADERS})
+create_target_directory_groups(input_common)
 
-add_library(input_common STATIC ${SRCS} ${HEADERS})
 target_link_libraries(input_common PUBLIC core PRIVATE common)
 
 if(SDL2_FOUND)
diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt
index ac9d028da..f72da9439 100644
--- a/src/network/CMakeLists.txt
+++ b/src/network/CMakeLists.txt
@@ -1,18 +1,14 @@
-set(SRCS
-            network.cpp
-            packet.cpp
-            room.cpp
-            room_member.cpp
-            )
+add_library(network STATIC
+    network.cpp
+    network.h
+    packet.cpp
+    packet.h
+    room.cpp
+    room.h
+    room_member.cpp
+    room_member.h
+)
 
-set(HEADERS
-            network.h
-            packet.h
-            room.h
-            room_member.h
-            )
+create_target_directory_groups(network)
 
-create_directory_groups(${SRCS} ${HEADERS})
-
-add_library(network STATIC ${SRCS} ${HEADERS})
 target_link_libraries(network PRIVATE common enet)
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index d257a1f32..1e0580825 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -1,28 +1,25 @@
-set(SRCS
-            common/param_package.cpp
-            core/arm/arm_test_common.cpp
-            core/arm/dyncom/arm_dyncom_vfp_tests.cpp
-            core/core_timing.cpp
-            core/file_sys/path_parser.cpp
-            core/hle/kernel/hle_ipc.cpp
-            core/memory/memory.cpp
-            glad.cpp
-            tests.cpp
-            )
-
-set(HEADERS
-            core/arm/arm_test_common.h
-            )
+add_executable(tests
+    common/param_package.cpp
+    core/arm/arm_test_common.cpp
+    core/arm/arm_test_common.h
+    core/arm/dyncom/arm_dyncom_vfp_tests.cpp
+    core/core_timing.cpp
+    core/file_sys/path_parser.cpp
+    core/hle/kernel/hle_ipc.cpp
+    core/memory/memory.cpp
+    glad.cpp
+    tests.cpp
+)
 
 if (ARCHITECTURE_x86_64)
-    set(SRCS ${SRCS}
+    target_sources(tests
+        PRIVATE
             video_core/shader/shader_jit_x64_compiler.cpp
-            )
+    )
 endif()
 
-create_directory_groups(${SRCS} ${HEADERS})
+create_target_directory_groups(tests)
 
-add_executable(tests ${SRCS} ${HEADERS})
 target_link_libraries(tests PRIVATE common core video_core)
 target_link_libraries(tests PRIVATE glad) # To support linker work-around
 target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} catch-single-include nihstro-headers Threads::Threads)
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index d492e5188..041d15a7f 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -1,88 +1,85 @@
-set(SRCS
-            command_processor.cpp
-            debug_utils/debug_utils.cpp
-            geometry_pipeline.cpp
-            pica.cpp
-            primitive_assembly.cpp
-            regs.cpp
-            renderer_base.cpp
-            renderer_opengl/gl_rasterizer.cpp
-            renderer_opengl/gl_rasterizer_cache.cpp
-            renderer_opengl/gl_shader_gen.cpp
-            renderer_opengl/gl_shader_util.cpp
-            renderer_opengl/gl_state.cpp
-            renderer_opengl/renderer_opengl.cpp
-            shader/shader.cpp
-            shader/shader_interpreter.cpp
-            swrasterizer/clipper.cpp
-            swrasterizer/framebuffer.cpp
-            swrasterizer/lighting.cpp
-            swrasterizer/proctex.cpp
-            swrasterizer/rasterizer.cpp
-            swrasterizer/swrasterizer.cpp
-            swrasterizer/texturing.cpp
-            texture/etc1.cpp
-            texture/texture_decode.cpp
-            vertex_loader.cpp
-            video_core.cpp
-            )
-
-set(HEADERS
-            command_processor.h
-            debug_utils/debug_utils.h
-            geometry_pipeline.h
-            gpu_debugger.h
-            pica.h
-            pica_state.h
-            pica_types.h
-            primitive_assembly.h
-            rasterizer_interface.h
-            regs.h
-            regs_framebuffer.h
-            regs_lighting.h
-            regs_pipeline.h
-            regs_rasterizer.h
-            regs_shader.h
-            regs_texturing.h
-            renderer_base.h
-            renderer_opengl/gl_rasterizer.h
-            renderer_opengl/gl_rasterizer_cache.h
-            renderer_opengl/gl_resource_manager.h
-            renderer_opengl/gl_shader_gen.h
-            renderer_opengl/gl_shader_util.h
-            renderer_opengl/gl_state.h
-            renderer_opengl/pica_to_gl.h
-            renderer_opengl/renderer_opengl.h
-            shader/debug_data.h
-            shader/shader.h
-            shader/shader_interpreter.h
-            swrasterizer/clipper.h
-            swrasterizer/framebuffer.h
-            swrasterizer/lighting.h
-            swrasterizer/proctex.h
-            swrasterizer/rasterizer.h
-            swrasterizer/swrasterizer.h
-            swrasterizer/texturing.h
-            texture/etc1.h
-            texture/texture_decode.h
-            utils.h
-            vertex_loader.h
-            video_core.h
-            )
+add_library(video_core STATIC
+    command_processor.cpp
+    command_processor.h
+    debug_utils/debug_utils.cpp
+    debug_utils/debug_utils.h
+    geometry_pipeline.cpp
+    geometry_pipeline.h
+    gpu_debugger.h
+    pica.cpp
+    pica.h
+    pica_state.h
+    pica_types.h
+    primitive_assembly.cpp
+    primitive_assembly.h
+    rasterizer_interface.h
+    regs.cpp
+    regs.h
+    regs_framebuffer.h
+    regs_lighting.h
+    regs_pipeline.h
+    regs_rasterizer.h
+    regs_shader.h
+    regs_texturing.h
+    renderer_base.cpp
+    renderer_base.h
+    renderer_opengl/gl_rasterizer.cpp
+    renderer_opengl/gl_rasterizer.h
+    renderer_opengl/gl_rasterizer_cache.cpp
+    renderer_opengl/gl_rasterizer_cache.h
+    renderer_opengl/gl_resource_manager.h
+    renderer_opengl/gl_shader_gen.cpp
+    renderer_opengl/gl_shader_gen.h
+    renderer_opengl/gl_shader_util.cpp
+    renderer_opengl/gl_shader_util.h
+    renderer_opengl/gl_state.cpp
+    renderer_opengl/gl_state.h
+    renderer_opengl/pica_to_gl.h
+    renderer_opengl/renderer_opengl.cpp
+    renderer_opengl/renderer_opengl.h
+    shader/debug_data.h
+    shader/shader.cpp
+    shader/shader.h
+    shader/shader_interpreter.cpp
+    shader/shader_interpreter.h
+    swrasterizer/clipper.cpp
+    swrasterizer/clipper.h
+    swrasterizer/framebuffer.cpp
+    swrasterizer/framebuffer.h
+    swrasterizer/lighting.cpp
+    swrasterizer/lighting.h
+    swrasterizer/proctex.cpp
+    swrasterizer/proctex.h
+    swrasterizer/rasterizer.cpp
+    swrasterizer/rasterizer.h
+    swrasterizer/swrasterizer.cpp
+    swrasterizer/swrasterizer.h
+    swrasterizer/texturing.cpp
+    swrasterizer/texturing.h
+    texture/etc1.cpp
+    texture/etc1.h
+    texture/texture_decode.cpp
+    texture/texture_decode.h
+    utils.h
+    vertex_loader.cpp
+    vertex_loader.h
+    video_core.cpp
+    video_core.h
+)
 
 if(ARCHITECTURE_x86_64)
-    set(SRCS ${SRCS}
+    target_sources(video_core
+        PRIVATE
             shader/shader_jit_x64.cpp
-            shader/shader_jit_x64_compiler.cpp)
+            shader/shader_jit_x64_compiler.cpp
 
-    set(HEADERS ${HEADERS}
             shader/shader_jit_x64.h
-            shader/shader_jit_x64_compiler.h)
+            shader/shader_jit_x64_compiler.h
+    )
 endif()
 
-create_directory_groups(${SRCS} ${HEADERS})
+create_target_directory_groups(video_core)
 
-add_library(video_core STATIC ${SRCS} ${HEADERS})
 target_link_libraries(video_core PUBLIC common core)
 target_link_libraries(video_core PRIVATE glad nihstro-headers)
 
diff --git a/src/web_service/CMakeLists.txt b/src/web_service/CMakeLists.txt
index c93811892..b6de2632b 100644
--- a/src/web_service/CMakeLists.txt
+++ b/src/web_service/CMakeLists.txt
@@ -1,16 +1,12 @@
-set(SRCS
-            telemetry_json.cpp
-            verify_login.cpp
-            web_backend.cpp
-            )
+add_library(web_service STATIC
+    telemetry_json.cpp
+    telemetry_json.h
+    verify_login.cpp
+    verify_login.h
+    web_backend.cpp
+    web_backend.h
+)
 
-set(HEADERS
-            telemetry_json.h
-            verify_login.h
-            web_backend.h
-            )
+create_target_directory_groups(web_service)
 
-create_directory_groups(${SRCS} ${HEADERS})
-
-add_library(web_service STATIC ${SRCS} ${HEADERS})
 target_link_libraries(web_service PUBLIC common cpr json-headers)