Compiling GLFW on latest MacOS fails at CodeSign step

On a vanilla M1 Pro running Sonoma 14.3.1 with Xcode 15.2 installed. Did “xcode-select --install” some time ago to be able to use “cc” from the command line to compile C programs using pre-compiled libglfw3.a / glfw3.h which has been working fine for me forever. Recently updated to glfw 3.4, no problems; apps still compile and run great.

Downloaded sources for glfw-3.4 intending to compile it from scratch, following instructions on “Compiling GLFW” page. I’ve got cmake version 3.28.3 installed courtesy of homebrew. First issue:


glfw-3.4 % cmake -S . -B build -G Xcode
– The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.

– Configuring incomplete, errors occurred!


Kind of odd, since I use “cc” from this very shell to make my glfw-based app with no problem. The web suggests the magic incantation:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

which I do with some trepidation, but happy results:


glfw-3.4 % cmake -S . -B build -G Xcode
– The C compiler identification is AppleClang 15.0.0.15000100
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.\xctoolchain/usr/bin/clang - skipped
– Detecting C compile features
– Detecting C compile features - done
– Performing Test CMAKE_HAVE_LIBC_PTHREAD
– Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
– Found Threads: TRUE
– Including Cocoa support
– Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
– Documentation generation requires Doxygen 1.9.8 or later
– Configuring done (6.6s)
– Generating done (0.0s)
– Build files have been written to: /myob/glfw-3.4/build


That’s encouraging (though not sure why “Check for working C compiler” was “skipped”).

Following the “Compiling the library” section, the advice “With Linux, macOS and other forms of Unix, run make” doesn’t work, as there are no makefiles:


glfw-3.4 % cd build
build % make
make: *** No targets specified and no makefile found. Stop.
build % cd …
glfw-3.4 %


Undeterred, I’ll just try the alternate cmake advice, which results in lots of compiling and stuff, but fails at way down at CodeSign:


glfw-3.4 % cmake --build build
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project GLFW.xcodeproj build -target ALL_BUILD -parallelizeTargets -configuration Debug -hideShellScriptEnvironment

User defaults from command line:
HideShellScriptEnvironment = YES
IDEPackageSupportUseBuiltinSCM = YES

ComputeTargetDependencyGraph
note: Building targets in dependency order
note: Target dependency graph (34 targets)
Target ‘ALL_BUILD’ in project ‘GLFW’
➜ Explicit dependency on target ‘glfw’ in project ‘GLFW’

… Lots of happy compiling …

CodeSign /myob/glfw-3.4/build/examples/Debug/windows.app (in target ‘windows’ from project ‘GLFW’)
cd /myob/glfw-3.4

Signing Identity: “-”

/usr/bin/codesign --force --sign - --entitlements /myob/glfw-3.4/build/build/windows.build/Debug/windows.app.xcent --timestamp=none --generate-entitlement-der /myob/glfw-3.4/build/examples/Debug/windows.app
/myob/glfw-3.4/build/examples/Debug/windows.app: resource fork, Finder information, or similar detritus not allowed
Command CodeSign failed with a nonzero exit code

note: Run script build phase ‘Generate CMakeFiles/ALL_BUILD’ will be run during every build because the option to run the script phase “Based on dependency analysis” is unchecked. (in target ‘ALL_BUILD’ from project ‘GLFW’)
note: Run script build phase ‘Generate CMakeFiles/ZERO_CHECK’ will be run during every build because the option to run the script phase “Based on dependency analysis” is unchecked. (in target ‘ZERO_CHECK’ from project ‘GLFW’)
** BUILD FAILED **

The following build commands failed:
CodeSign /myob/glfw-3.4/build/examples/Debug/windows.app (in target ‘windows’ from project ‘GLFW’)
CodeSign /myob/glfw-3.4/build/examples/Debug/wave.app (in target ‘wave’ from project ‘GLFW’)
(2 failures)


Any thoughts on where I went wrong? Or additional magic incantations to make CodeSign happy?

Well, it seems I misunderstood the comment about “-G Xcode”, thinking it meant it was necessary for even command-line MacOS building. Simply leaving off this option made everything happy (macOS-compatible makefiles were generated, and doing a “make” in the build directory built every thing with no complaints). Leaving this all here for any other hapless beginner.