Camomile icon indicating copy to clipboard operation
Camomile copied to clipboard

Can't compile on OS X 12.4

Open dr-kd opened this issue 1 year ago • 3 comments

Here's the error log after following the build instructions:

$ cmake ..
CMake Error at /usr/local/Cellar/cmake/3.23.2/share/cmake/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/Library/Developer/CommandLineTools/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/kd/Desktop/dev/Camomile/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make -f Makefile cmTC_ba6fc/fast && /Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/cmTC_ba6fc.dir/build.make CMakeFiles/cmTC_ba6fc.dir/build
    Building C object CMakeFiles/cmTC_ba6fc.dir/testCCompiler.c.o
    /Library/Developer/CommandLineTools/usr/bin/cc   -arch  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=10.9 -MD -MT CMakeFiles/cmTC_ba6fc.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_ba6fc.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_ba6fc.dir/testCCompiler.c.o -c /Users/kd/Desktop/dev/Camomile/build/CMakeFiles/CMakeTmp/testCCompiler.c
    clang: error: invalid arch name '-arch -isysroot'
    clang: warning: /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk: 'linker' input unused [-Wunused-command-line-argument]
    make[1]: *** [CMakeFiles/cmTC_ba6fc.dir/testCCompiler.c.o] Error 1
    make: *** [cmTC_ba6fc/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:8 (project)

xcode version is:

$ xcode-select -v
xcode-select version 2395.

dr-kd avatar Aug 01 '22 14:08 dr-kd

Clearly, when CMake was generating the command to compile the test program, it put an empty string as the value for the -arch option.

This is a wild guess: could you make this change to the top of CMakeLists.txt and try again?

 cmake_minimum_required(VERSION 3.12)
 
 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
-set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)" CACHE STRING "" FORCE)
+set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD}" CACHE STRING "" FORCE)

That is, change the round brackets to curly brackets around ARCHS_STANDARD.

hyperpenelope avatar Aug 04 '22 11:08 hyperpenelope

Applying that patch caused a successful build. Thank you very much.

In lieu of a pull request, here's the actual diff - I'll leave it to someone who knows better to do the mechanics of it:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a57ef15..0a5b3af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.12)
 
 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
-set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)" CACHE STRING "" FORCE)
+set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD}" CACHE STRING "" FORCE)
 set(JUCE_ENABLE_MODULE_SOURCE_GROUPS ON CACHE BOOL "" FORCE)
 set_property(GLOBAL PROPERTY USE_FOLDERS YES)
 

dr-kd avatar Aug 06 '22 16:08 dr-kd

@singingfish Good news. I am curious what ARCHS_STANDARD actually is. If you have time, could you add the line

message("ARCHS_STANDARD='${ARCHS_STANDARD}'")

near the top of CMakeLists.txt and run cmake .. in your build directory? You don't have to recompile (i.e. you don't have to run cmake --build .) This should print out its value; I am wondering if it is populated on OSX.

Anyway, I'll do a PR for this soon.

hyperpenelope avatar Aug 09 '22 15:08 hyperpenelope