From 2dba592a42535c34d62b73e2003f431ce5d33783 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 23 Dec 2023 12:23:47 -0600 Subject: [PATCH] [nostalgia,olympic] Cleanup CMake --- CMakeLists.txt | 8 ---- src/nostalgia/CMakeLists.txt | 15 ++++++-- src/nostalgia/modules/CMakeLists.txt | 38 +++++++++---------- src/nostalgia/modules/core/CMakeLists.txt | 3 +- src/nostalgia/modules/core/src/CMakeLists.txt | 2 +- .../modules/core/src/gba/CMakeLists.txt | 2 +- src/nostalgia/modules/studiomodules.cpp | 2 - src/olympic/CMakeLists.txt | 15 ++++++++ src/olympic/studio/applib/src/newmenu.cpp | 2 +- src/olympic/studio/applib/src/newmenu.hpp | 2 +- .../studio/applib/src/projectexplorer.cpp | 2 +- .../studio/applib/src/projectexplorer.hpp | 2 +- .../studio/applib/src/projecttreemodel.cpp | 2 +- .../studio/applib/src/projecttreemodel.hpp | 4 +- .../modlib/include/studio/itemmaker.hpp | 16 ++++---- 15 files changed, 64 insertions(+), 51 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ccf86b2..c3553ce1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,18 +11,11 @@ endif() include(deps/buildcore/base.cmake) -set(NOSTALGIA_BUILD_PLAYER ON CACHE BOOL "Build Player") -set(NOSTALGIA_BUILD_STUDIO ON CACHE BOOL "Build Studio") -set(OLYMPIC_BUILD_STUDIO ON CACHE BOOL "Build Studio") set(OX_ENABLE_TRACEHOOK OFF CACHE BOOL "Generate OxTraceHook shared library for uprobes") if(BUILDCORE_TARGET STREQUAL "gba") - set(NOSTALGIA_BUILD_STUDIO OFF) - set(OLYMPIC_BUILD_STUDIO OFF) - set(TURBINE_BUILD_TYPE "GBA") include(deps/gbabuildcore/base.cmake) else() - set(TURBINE_BUILD_TYPE "Native") set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() @@ -49,7 +42,6 @@ add_subdirectory(deps/teagba) if(NOT BUILDCORE_TARGET STREQUAL "gba") include_directories( SYSTEM - deps/glfw/deps deps/glfw/include deps/imgui deps/imgui/backends diff --git a/src/nostalgia/CMakeLists.txt b/src/nostalgia/CMakeLists.txt index a486c942..d644bae6 100644 --- a/src/nostalgia/CMakeLists.txt +++ b/src/nostalgia/CMakeLists.txt @@ -1,6 +1,15 @@ +project(nostalgia CXX) + #project packages +set(NOSTALGIA_BUILD_PLAYER ON CACHE BOOL "Build Player") +set(NOSTALGIA_BUILD_STUDIO ON CACHE BOOL "Build Studio") + +if(BUILDCORE_TARGET STREQUAL "gba") + set(NOSTALGIA_BUILD_STUDIO OFF) +endif() + if(APPLE) set(CMAKE_INSTALL_NAME_DIR "@executable_path/../Library/nostalgia") set(NOSTALGIA_DIST_BIN NostalgiaStudio.app/Contents/MacOS) @@ -17,13 +26,13 @@ endif() add_subdirectory(modules) -if(NOSTALGIA_BUILD_PLAYER) +if(${NOSTALGIA_BUILD_PLAYER}) add_subdirectory(player) endif() -if(TURBINE_BUILD_TYPE STREQUAL "Native") +if(NOT BUILDCORE_TARGET STREQUAL "gba") add_subdirectory(tools) - if(NOSTALGIA_BUILD_STUDIO) + if(${NOSTALGIA_BUILD_STUDIO}) add_subdirectory(studio) endif() endif() diff --git a/src/nostalgia/modules/CMakeLists.txt b/src/nostalgia/modules/CMakeLists.txt index 6b5b7f2a..9c5115d8 100644 --- a/src/nostalgia/modules/CMakeLists.txt +++ b/src/nostalgia/modules/CMakeLists.txt @@ -23,26 +23,24 @@ install( include/nostalgia/modules ) -if(${OLYMPIC_BUILD_STUDIO}) - # Studio - if(TURBINE_BUILD_TYPE STREQUAL "Native") - add_library( - NostalgiaStudioModules STATIC - studiomodules.cpp - ) - target_link_libraries( - NostalgiaStudioModules PUBLIC - StudioAppLib - NostalgiaCore-Studio-ImGui - NostalgiaScene-Studio - ) - install( - FILES - studiomodules.hpp - DESTINATION - include/nostalgia/modules - ) - endif() +# Studio +if(NOSTALGIA_BUILD_STUDIO) + add_library( + NostalgiaStudioModules STATIC + studiomodules.cpp + ) + target_link_libraries( + NostalgiaStudioModules PUBLIC + StudioAppLib + NostalgiaCore-Studio-ImGui + NostalgiaScene-Studio + ) + install( + FILES + studiomodules.hpp + DESTINATION + include/nostalgia/modules + ) endif() add_library(NostalgiaProfile INTERFACE) diff --git a/src/nostalgia/modules/core/CMakeLists.txt b/src/nostalgia/modules/core/CMakeLists.txt index 2d89fadf..f217730e 100644 --- a/src/nostalgia/modules/core/CMakeLists.txt +++ b/src/nostalgia/modules/core/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(src) -if(NOT TURBINE_BUILD_TYPE STREQUAL "GBA") + +if(NOT BUILDCORE_TARGET STREQUAL "gba") add_subdirectory(test) endif() diff --git a/src/nostalgia/modules/core/src/CMakeLists.txt b/src/nostalgia/modules/core/src/CMakeLists.txt index d7d99c4b..0410ad7b 100644 --- a/src/nostalgia/modules/core/src/CMakeLists.txt +++ b/src/nostalgia/modules/core/src/CMakeLists.txt @@ -5,7 +5,7 @@ add_library( ) add_subdirectory(gba) -if(NOT TURBINE_BUILD_TYPE STREQUAL "GBA") +if(NOT BUILDCORE_TARGET STREQUAL "gba") add_subdirectory(opengl) endif() diff --git a/src/nostalgia/modules/core/src/gba/CMakeLists.txt b/src/nostalgia/modules/core/src/gba/CMakeLists.txt index 9aa64dbd..d1552880 100644 --- a/src/nostalgia/modules/core/src/gba/CMakeLists.txt +++ b/src/nostalgia/modules/core/src/gba/CMakeLists.txt @@ -15,7 +15,7 @@ target_link_libraries( Turbine ) -if(TURBINE_BUILD_TYPE STREQUAL "GBA") +if(BUILDCORE_TARGET STREQUAL "gba") set_source_files_properties(gfx.cpp PROPERTIES COMPILE_FLAGS -marm) target_link_libraries(NostalgiaCore PUBLIC NostalgiaCore-GBA) endif() diff --git a/src/nostalgia/modules/studiomodules.cpp b/src/nostalgia/modules/studiomodules.cpp index 2a76f4b1..ab8b2938 100644 --- a/src/nostalgia/modules/studiomodules.cpp +++ b/src/nostalgia/modules/studiomodules.cpp @@ -2,8 +2,6 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include - #include #include diff --git a/src/olympic/CMakeLists.txt b/src/olympic/CMakeLists.txt index 30ae56da..186fcd68 100644 --- a/src/olympic/CMakeLists.txt +++ b/src/olympic/CMakeLists.txt @@ -1,3 +1,18 @@ +if(BUILDCORE_TARGET STREQUAL "gba") + project(Olympic ASM CXX) +else() + project(Olympic CXX) +endif() + +set(OLYMPIC_BUILD_STUDIO ON CACHE BOOL "Build Studio") + +if(BUILDCORE_TARGET STREQUAL "gba") + set(OLYMPIC_BUILD_STUDIO OFF) + set(TURBINE_BUILD_TYPE "GBA") +else() + set(TURBINE_BUILD_TYPE "Native") +endif() + add_subdirectory(applib) add_subdirectory(keel) add_subdirectory(turbine) diff --git a/src/olympic/studio/applib/src/newmenu.cpp b/src/olympic/studio/applib/src/newmenu.cpp index 33dd46b7..8b57dd8d 100644 --- a/src/olympic/studio/applib/src/newmenu.cpp +++ b/src/olympic/studio/applib/src/newmenu.cpp @@ -52,7 +52,7 @@ void NewMenu::draw(turbine::Context &ctx) noexcept { } } -void NewMenu::addItemMaker(ox::UniquePtr im) noexcept { +void NewMenu::addItemMaker(ox::UniquePtr &&im) noexcept { m_types.emplace_back(std::move(im)); std::sort( m_types.begin(), m_types.end(), diff --git a/src/olympic/studio/applib/src/newmenu.hpp b/src/olympic/studio/applib/src/newmenu.hpp index f348b82b..ee30d778 100644 --- a/src/olympic/studio/applib/src/newmenu.hpp +++ b/src/olympic/studio/applib/src/newmenu.hpp @@ -51,7 +51,7 @@ class NewMenu: public studio::Popup { template void addItemType(ox::String name, ox::String parentDir, ox::String fileExt, ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept; - void addItemMaker(ox::UniquePtr im) noexcept; + void addItemMaker(ox::UniquePtr &&im) noexcept; private: void drawNewItemType(turbine::Context &ctx) noexcept; diff --git a/src/olympic/studio/applib/src/projectexplorer.cpp b/src/olympic/studio/applib/src/projectexplorer.cpp index e9da06b8..5e60b041 100644 --- a/src/olympic/studio/applib/src/projectexplorer.cpp +++ b/src/olympic/studio/applib/src/projectexplorer.cpp @@ -44,7 +44,7 @@ void ProjectExplorer::draw(turbine::Context &ctx) noexcept { ImGui::EndChild(); } -void ProjectExplorer::setModel(ox::UPtr model) noexcept { +void ProjectExplorer::setModel(ox::UPtr &&model) noexcept { m_treeModel = std::move(model); } diff --git a/src/olympic/studio/applib/src/projectexplorer.hpp b/src/olympic/studio/applib/src/projectexplorer.hpp index 834684da..18850c99 100644 --- a/src/olympic/studio/applib/src/projectexplorer.hpp +++ b/src/olympic/studio/applib/src/projectexplorer.hpp @@ -21,7 +21,7 @@ class ProjectExplorer: public studio::Widget { void draw(turbine::Context &ctx) noexcept override; - void setModel(ox::UPtr model) noexcept; + void setModel(ox::UPtr &&model) noexcept; ox::Error refreshProjectTreeModel(ox::CRStringView = {}) noexcept; diff --git a/src/olympic/studio/applib/src/projecttreemodel.cpp b/src/olympic/studio/applib/src/projecttreemodel.cpp index e41e9aca..5b848dd2 100644 --- a/src/olympic/studio/applib/src/projecttreemodel.cpp +++ b/src/olympic/studio/applib/src/projecttreemodel.cpp @@ -44,7 +44,7 @@ void ProjectTreeModel::draw(turbine::Context &ctx) const noexcept { } } -void ProjectTreeModel::setChildren(ox::Vector> children) noexcept { +void ProjectTreeModel::setChildren(ox::Vector> children) noexcept { m_children = std::move(children); } diff --git a/src/olympic/studio/applib/src/projecttreemodel.hpp b/src/olympic/studio/applib/src/projecttreemodel.hpp index 042aba81..c86b0e8e 100644 --- a/src/olympic/studio/applib/src/projecttreemodel.hpp +++ b/src/olympic/studio/applib/src/projecttreemodel.hpp @@ -16,7 +16,7 @@ class ProjectTreeModel { class ProjectExplorer &m_explorer; ProjectTreeModel *m_parent = nullptr; ox::String m_name; - ox::Vector> m_children; + ox::Vector> m_children; public: explicit ProjectTreeModel(class ProjectExplorer &explorer, ox::String name, ProjectTreeModel *parent = nullptr) noexcept; @@ -25,7 +25,7 @@ class ProjectTreeModel { void draw(turbine::Context &ctx) const noexcept; - void setChildren(ox::Vector> children) noexcept; + void setChildren(ox::Vector> children) noexcept; private: [[nodiscard]] diff --git a/src/olympic/studio/modlib/include/studio/itemmaker.hpp b/src/olympic/studio/modlib/include/studio/itemmaker.hpp index 299fd8aa..88225247 100644 --- a/src/olympic/studio/modlib/include/studio/itemmaker.hpp +++ b/src/olympic/studio/modlib/include/studio/itemmaker.hpp @@ -30,8 +30,8 @@ class ItemMaker { template class ItemMakerT: public ItemMaker { private: - T const item; - ox::ClawFormat const fmt; + T const m_item; + ox::ClawFormat const m_fmt; public: constexpr ItemMakerT( ox::StringView pDisplayName, @@ -39,7 +39,7 @@ class ItemMakerT: public ItemMaker { ox::StringView fileExt, ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept: ItemMaker(pDisplayName, pParentDir, fileExt), - fmt(pFmt) { + m_fmt(pFmt) { } constexpr ItemMakerT( ox::StringView pDisplayName, @@ -48,8 +48,8 @@ class ItemMakerT: public ItemMaker { T pItem, ox::ClawFormat pFmt) noexcept: ItemMaker(pDisplayName, pParentDir, fileExt), - item(pItem), - fmt(pFmt) { + m_item(pItem), + m_fmt(pFmt) { } constexpr ItemMakerT( ox::StringView pDisplayName, @@ -58,14 +58,14 @@ class ItemMakerT: public ItemMaker { T &&pItem, ox::ClawFormat pFmt) noexcept: ItemMaker(pDisplayName, pParentDir, fileExt), - item(std::move(pItem)), - fmt(pFmt) { + m_item(std::move(pItem)), + m_fmt(pFmt) { } ox::Error write(turbine::Context &ctx, ox::CRStringView pName) const noexcept override { auto const path = ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt); auto sctx = turbine::applicationData(ctx); keel::createUuidMapping(keelCtx(ctx), path, ox::UUID::generate().unwrap()); - return sctx->project->writeObj(path, item, fmt); + return sctx->project->writeObj(path, m_item, m_fmt); } };