Skip to content

Commit

Permalink
macos fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoryGraborenko committed Oct 3, 2024
1 parent ab7d46c commit 829d3b6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Examples/Empty_WebGPU_Jumbo/ProjectSettings.cmake
Examples/Empty_WebGPU_QT_Jumbo/ProjectSettings.cmake
ProjectSettings.cmake
UserSettings.cmake
7 changes: 5 additions & 2 deletions CMake/Jumbo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ if (APPLE)
target_link_libraries(${PROJECT_NAME}
${SDL2_LIBRARY}
SDL2_image::SDL2_image
"-framework Foundation"
"-framework IOKit"
"-framework Metal"
"-framework QuartzCore"
"-framework IOSurface"
)
Expand Down Expand Up @@ -201,9 +204,9 @@ file(GLOB_RECURSE GeneratedList *.cxx *.hxx)

# all files from neshny
if (WEBGPU)
file(GLOB NeshnyList ${NESHNY_DIR}/Src/*.* ${NESHNY_DIR}/Src/WebGPU/*.* ${NESHNY_DIR}/Src/UnitTests/*.cpp ${NESHNY_DIR}/Src/Shaders/*.wgsl)
file(GLOB NeshnyList ${NESHNY_DIR}/Src/*.h ${NESHNY_DIR}/Src/*.cpp ${NESHNY_DIR}/Src/WebGPU/*.* ${NESHNY_DIR}/Src/UnitTests/*.cpp ${NESHNY_DIR}/Src/Shaders/*.wgsl)
else()
file(GLOB NeshnyList ${NESHNY_DIR}/Src/*.* ${NESHNY_DIR}/Src/OpenGL/*.* ${NESHNY_DIR}/Src/UnitTests/*.cpp ${NESHNY_DIR}/Src/Shaders/*.*)
file(GLOB NeshnyList ${NESHNY_DIR}/Src/*.h ${NESHNY_DIR}/Src/*.cpp ${NESHNY_DIR}/Src/OpenGL/*.* ${NESHNY_DIR}/Src/UnitTests/*.cpp ${NESHNY_DIR}/Src/Shaders/*.*)
endif()

list(APPEND FullList ${HeaderList} ${SourceList} ${ShaderList})
Expand Down
4 changes: 4 additions & 0 deletions Examples/Empty_WebGPU_Jumbo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ using namespace Neshny;

int main(int, char**) {

#ifdef __APPLE__
std::filesystem::current_path(GetMacOSExecutableDir());
#endif

Core::Singleton().SetResourceDirs(g_ShaderBaseDirs);
#if !defined _DEBUG || defined __EMSCRIPTEN__
Core::Singleton().SetEmbeddedFiles(g_EmbeddedFiles);
Expand Down
16 changes: 16 additions & 0 deletions Src/NeshnyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,20 @@ void ImGuiTextColoredUnformatted(std::string str, ImVec4 text_col) {
ImGui::PopStyleColor();
}

#ifdef __APPLE__
////////////////////////////////////////////////////////////////////////////////
std::string GetMacOSExecutableDir() {
char path[1024];
uint32_t size = sizeof(path);
if (_NSGetExecutablePath(path, &size) != 0)
return "";
std::string result(path, size);
auto end_slash = result.find_last_of('/');
if (end_slash == std::string::npos) {
return result;
}
return std::string(path, end_slash);
}
#endif

} // namespace Neshny
6 changes: 6 additions & 0 deletions Src/NeshnyUtils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#ifdef __APPLE__
#include <mach-o/dyld.h>
#endif
namespace Neshny {

#define STRING2(x) #x
Expand Down Expand Up @@ -61,6 +64,9 @@ std::string JoinStrings(const std::list<std::string>& list, std::string_view ins
bool StringContains(std::string_view str, std::string_view search, bool case_insensitive = false);
std::string SrcStr(const std::source_location location = std::source_location::current());
void ImGuiTextColoredUnformatted(std::string str, ImVec4 text_col);
#ifdef __APPLE__
std::string GetMacOSExecutableDir();
#endif

////////////////////////////////////////////////////////////////////////////////
template <class T>
Expand Down

0 comments on commit 829d3b6

Please sign in to comment.