chore(cmake): enhance test support linkage and file dialog functionality

- Improved the CMake configuration to conditionally link the yaze_test_support library for the yaze target when tests are enabled, providing clearer feedback on linkage status.
- Updated the file dialog implementation to include specific filters for ROM files and all files, enhancing user experience during file selection.
- Added status messages to inform users about the linkage of test support and potential issues if the target is not found.

Benefits:
- Enhanced clarity and maintainability of the CMake configuration.
- Improved user interaction with file dialogs through better filtering options.
This commit is contained in:
scawful
2025-10-11 13:29:24 -04:00
parent 88a4f29fe8
commit e523ce94da
3 changed files with 16 additions and 12 deletions

View File

@@ -44,6 +44,11 @@ target_link_libraries(yaze PRIVATE
# Link test support if tests are enabled (yaze_editor needs TestManager)
if(YAZE_BUILD_TESTS AND TARGET yaze_test_support)
target_link_libraries(yaze PRIVATE yaze_test_support)
message(STATUS "✓ yaze executable linked to yaze_test_support")
else()
if(YAZE_BUILD_TESTS)
message(WARNING "yaze needs yaze_test_support but TARGET yaze_test_support not found")
endif()
endif()
# Platform-specific settings

View File

@@ -11,7 +11,8 @@ namespace util {
std::string FileDialogWrapper::ShowOpenFileDialog() {
nfdchar_t* outPath = nullptr;
nfdresult_t result = NFD_OpenDialog(nullptr, nullptr, &outPath);
nfdfilteritem_t filterItem[2] = {{"ROM Files", "sfc,smc"}, {"All Files", "*"}};
nfdresult_t result = NFD_OpenDialog(&outPath, filterItem, 2, nullptr);
if (result == NFD_OKAY) {
std::string path(outPath);
@@ -24,7 +25,7 @@ std::string FileDialogWrapper::ShowOpenFileDialog() {
std::string FileDialogWrapper::ShowOpenFolderDialog() {
nfdchar_t* outPath = nullptr;
nfdresult_t result = NFD_PickFolder(nullptr, &outPath);
nfdresult_t result = NFD_PickFolder(&outPath, nullptr);
if (result == NFD_OKAY) {
std::string path(outPath);
@@ -41,11 +42,11 @@ std::string FileDialogWrapper::ShowSaveFileDialog(const std::string& default_nam
nfdfilteritem_t filterItem[1] = {{default_extension.empty() ? "All Files" : default_extension.c_str(),
default_extension.empty() ? "*" : default_extension.c_str()}};
nfdresult_t result = NFD_SaveDialog(default_extension.empty() ? nullptr : filterItem,
nfdresult_t result = NFD_SaveDialog(&outPath,
default_extension.empty() ? nullptr : filterItem,
default_extension.empty() ? 0 : 1,
nullptr,
default_name.c_str(),
&outPath);
default_name.c_str());
if (result == NFD_OKAY) {
std::string path(outPath);

View File

@@ -51,11 +51,9 @@ else()
message(STATUS "○ z3ed test suites disabled (yaze_agent not built)")
endif()
# Link yaze_editor back to yaze_test_support (for TestManager usage in editor_manager.cc)
# Use PRIVATE linkage to avoid propagating test dependencies to editor consumers
if(TARGET yaze_editor)
target_link_libraries(yaze_editor PRIVATE yaze_test_support)
message(STATUS "✓ yaze_editor linked to yaze_test_support for TestManager access")
endif()
message(STATUS "✓ yaze_test_support library configured")
message(STATUS "✓ yaze_test_support library configured")
# Note: yaze_editor needs yaze_test_support for TestManager, but we can't link it here
# because this happens BEFORE yaze and yaze_emu are configured.
# Instead, each executable (yaze, yaze_emu) must explicitly link yaze_test_support
# in their respective .cmake files (app.cmake, emu.cmake).