hhyyrylainen / GodotPckTool

Standalone tool for extracting and creating Godot .pck files
MIT License
383 stars 31 forks source link

Add support for macOS #16

Open aaronfranke opened 2 years ago

aaronfranke commented 2 years ago

When I try to compile GodotPckTool using make on macOS, I get this output:

% make
cd build && cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/aaronfranke/workspace/GodotPckTool/build
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C build
Consolidate compiler generated dependencies of target pck
[ 16%] Building CXX object src/CMakeFiles/pck.dir/PckTool.cpp.o
[ 33%] Building CXX object src/CMakeFiles/pck.dir/FileFilter.cpp.o
[ 50%] Linking CXX static library libpck.a
[ 66%] Built target pck
[ 83%] Building CXX object src/CMakeFiles/godotpcktool.dir/main.cpp.o
[100%] Linking CXX executable godotpcktool
clang: error: invalid linker name in argument '-fuse-ld=gold'
clang: error: unsupported option '-static-libgcc'
make[3]: *** [src/godotpcktool] Error 1
make[2]: *** [src/CMakeFiles/godotpcktool.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [compile] Error 2

I'm not familiar with CMake, so I'm not sure how to add support for macOS. But I would greatly appreciate it, it would be useful to have when trying to debug a Mac build of my Godot project.

hhyyrylainen commented 2 years ago

Getting things compiling should be relatively easy by detecting apple platform in cmake and then not using the Linux specific flags. Just saying if someone wants to give this a go, as I have currently no need myself to get this working on mac.

april commented 2 years ago

You can use -fuse-ld=ld and drop the two static arguments and it builds fine for me on macOS.

--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,7 +20,7 @@ add_executable(godotpcktool main.cpp)
 target_link_libraries(godotpcktool PRIVATE pck)

 # Static standard lib
-target_link_libraries(godotpcktool PRIVATE -static-libgcc -static-libstdc++)
+target_link_libraries(godotpcktool PRIVATE)

 # Fully static executable
 if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
@@ -28,7 +28,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
 endif()

 if(NOT WIN32)
-  set_target_properties(godotpcktool PROPERTIES LINK_FLAGS_RELEASE "-s -fuse-ld=gold")
+  set_target_properties(godotpcktool PROPERTIES LINK_FLAGS_RELEASE "-s -fuse-ld=ld")
 else()
   set_target_properties(godotpcktool PROPERTIES LINK_FLAGS_RELEASE "-s")
 endif()