From 12ce96e533055b671cab07ad689c0dc3a4c567ee Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 30 Aug 2024 02:57:14 -0400 Subject: [PATCH] chore: Refactor CMakeLists.txt and app.cmake files for better organization --- CMakeLists.txt | 10 ++-- src/CMakeLists.txt | 58 +--------------------- src/app/app.cmake | 3 ++ src/app/core/core.cmake | 32 ++++++++++++ src/app/editor/graphics/graphics_editor.cc | 2 +- src/app/editor/graphics/graphics_editor.h | 2 +- src/app/gfx/gfx.cmake | 10 ++++ src/app/gui/gui.cmake | 9 ++++ src/app/gui/{ => modules}/asset_browser.cc | 0 src/app/gui/{ => modules}/asset_browser.h | 0 10 files changed, 64 insertions(+), 62 deletions(-) create mode 100644 src/app/core/core.cmake create mode 100644 src/app/gfx/gfx.cmake create mode 100644 src/app/gui/gui.cmake rename src/app/gui/{ => modules}/asset_browser.cc (100%) rename src/app/gui/{ => modules}/asset_browser.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ade74ac9..2354e8fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,18 @@ # Yet Another Zelda3 Editor # by scawful cmake_minimum_required(VERSION 3.10) -project(yaze VERSION 0.2.0) +project(yaze VERSION 0.2.0 + DESCRIPTION "Yet Another Zelda3 Editor" + LANGUAGES CXX) # Build Flags set(YAZE_BUILD_APP ON) +set(YAZE_BUILD_LIB ON) set(YAZE_BUILD_EMU ON) set(YAZE_BUILD_Z3ED ON) -set(YAZE_BUILD_PYTHON ON) -set(YAZE_BUILD_CLIB ON) -set(YAZE_INSTALL_CLIB OFF) +set(YAZE_BUILD_PYTHON OFF) set(YAZE_BUILD_TESTS OFF) +set(YAZE_INSTALL_LIB OFF) # libpng features in bitmap.cc add_definitions("-DYAZE_LIB_PNG=1") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a6ae982c..9847e4f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,33 +1,3 @@ -set( - YAZE_APP_CORE_SRC - app/core/common.cc - app/core/controller.cc - app/core/labeling.cc - app/emu/emulator.cc - app/core/message.cc -) - -set( - YAZE_APP_GFX_SRC - app/gfx/bitmap.cc - app/gfx/compression.cc - app/gfx/scad_format.cc - app/gfx/snes_palette.cc - app/gfx/snes_tile.cc - app/gfx/snes_color.cc - app/gfx/tilesheet.cc -) - -set( - YAZE_GUI_SRC - app/gui/asset_browser.cc - app/gui/canvas.cc - app/gui/input.cc - app/gui/style.cc - app/gui/color.cc - app/gui/zeml.cc -) - set( YAZE_APP_EMU_SRC app/emu/audio/apu.cc @@ -44,30 +14,6 @@ set( app/emu/snes.cc ) -if (WIN32 OR MINGW OR UNIX AND NOT APPLE) - list(APPEND YAZE_APP_CORE_SRC - app/core/platform/font_loader.cc - app/core/platform/clipboard.cc - app/core/platform/file_dialog.cc - ) -endif() - -if(APPLE) - list(APPEND YAZE_APP_CORE_SRC - app/core/platform/file_dialog.mm - app/core/platform/app_delegate.mm - app/core/platform/font_loader.mm - app/core/platform/clipboard.mm - app/core/platform/file_path.mm - ) - - find_library(COCOA_LIBRARY Cocoa) - if(NOT COCOA_LIBRARY) - message(FATAL_ERROR "Cocoa not found") - endif() - set(CMAKE_EXE_LINKER_FLAGS "-framework ServiceManagement -framework Foundation -framework Cocoa") -endif() - if (YAZE_BUILD_APP) include(app/app.cmake) endif() @@ -119,7 +65,7 @@ endif() include(test/CMakeLists.txt) -if (YAZE_BUILD_CLIB) +if (YAZE_BUILD_LIB) # Yaze C API add_library( yaze_c SHARED @@ -154,7 +100,7 @@ target_link_libraries( ImGui ) -if (YAZE_INSTALL_CLIB) +if (YAZE_INSTALL_LIB) install(TARGETS yaze_c RUNTIME DESTINATION bin LIBRARY DESTINATION lib diff --git a/src/app/app.cmake b/src/app/app.cmake index 6d3e4d8d..8054143b 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -1,4 +1,7 @@ +include(app/core/core.cmake) include(app/editor/editor.cmake) +include(app/gfx/gfx.cmake) +include(app/gui/gui.cmake) include(app/zelda3/zelda3.cmake) add_executable( diff --git a/src/app/core/core.cmake b/src/app/core/core.cmake new file mode 100644 index 00000000..12477437 --- /dev/null +++ b/src/app/core/core.cmake @@ -0,0 +1,32 @@ +set( + YAZE_APP_CORE_SRC + app/core/common.cc + app/core/controller.cc + app/core/labeling.cc + app/emu/emulator.cc + app/core/message.cc +) + +if (WIN32 OR MINGW OR UNIX AND NOT APPLE) + list(APPEND YAZE_APP_CORE_SRC + app/core/platform/font_loader.cc + app/core/platform/clipboard.cc + app/core/platform/file_dialog.cc + ) +endif() + +if(APPLE) + list(APPEND YAZE_APP_CORE_SRC + app/core/platform/file_dialog.mm + app/core/platform/app_delegate.mm + app/core/platform/font_loader.mm + app/core/platform/clipboard.mm + app/core/platform/file_path.mm + ) + + find_library(COCOA_LIBRARY Cocoa) + if(NOT COCOA_LIBRARY) + message(FATAL_ERROR "Cocoa not found") + endif() + set(CMAKE_EXE_LINKER_FLAGS "-framework ServiceManagement -framework Foundation -framework Cocoa") +endif() \ No newline at end of file diff --git a/src/app/editor/graphics/graphics_editor.cc b/src/app/editor/graphics/graphics_editor.cc index e3187df7..cae95ea0 100644 --- a/src/app/editor/graphics/graphics_editor.cc +++ b/src/app/editor/graphics/graphics_editor.cc @@ -11,7 +11,7 @@ #include "app/gfx/scad_format.h" #include "app/gfx/snes_palette.h" #include "app/gfx/snes_tile.h" -#include "app/gui/asset_browser.h" +#include "app/gui/modules/asset_browser.h" #include "app/gui/canvas.h" #include "app/gui/color.h" #include "app/gui/input.h" diff --git a/src/app/editor/graphics/graphics_editor.h b/src/app/editor/graphics/graphics_editor.h index 85315583..d2c216c0 100644 --- a/src/app/editor/graphics/graphics_editor.h +++ b/src/app/editor/graphics/graphics_editor.h @@ -8,7 +8,7 @@ #include "app/editor/utils/editor.h" #include "app/gfx/bitmap.h" #include "app/gfx/snes_tile.h" -#include "app/gui/asset_browser.h" +#include "app/gui/modules/asset_browser.h" #include "app/gui/canvas.h" #include "app/gui/input.h" #include "app/rom.h" diff --git a/src/app/gfx/gfx.cmake b/src/app/gfx/gfx.cmake new file mode 100644 index 00000000..5ebabdf0 --- /dev/null +++ b/src/app/gfx/gfx.cmake @@ -0,0 +1,10 @@ +set( + YAZE_APP_GFX_SRC + app/gfx/bitmap.cc + app/gfx/compression.cc + app/gfx/scad_format.cc + app/gfx/snes_palette.cc + app/gfx/snes_tile.cc + app/gfx/snes_color.cc + app/gfx/tilesheet.cc +) \ No newline at end of file diff --git a/src/app/gui/gui.cmake b/src/app/gui/gui.cmake new file mode 100644 index 00000000..60481956 --- /dev/null +++ b/src/app/gui/gui.cmake @@ -0,0 +1,9 @@ +set( + YAZE_GUI_SRC + app/gui/modules/asset_browser.cc + app/gui/canvas.cc + app/gui/input.cc + app/gui/style.cc + app/gui/color.cc + app/gui/zeml.cc +) diff --git a/src/app/gui/asset_browser.cc b/src/app/gui/modules/asset_browser.cc similarity index 100% rename from src/app/gui/asset_browser.cc rename to src/app/gui/modules/asset_browser.cc diff --git a/src/app/gui/asset_browser.h b/src/app/gui/modules/asset_browser.h similarity index 100% rename from src/app/gui/asset_browser.h rename to src/app/gui/modules/asset_browser.h