floooh / sokol-tools

Command line tools for use with sokol headers
MIT License
219 stars 54 forks source link

xcodebuild: error: 'sokol-tools.xcodeproj' does not exist. #100

Closed nosakou closed 1 year ago

nosakou commented 1 year ago

Hello sokol-tools team. I am trying to build sokol-tools through a README file of your project and getting an error as follows:

sokol-tools % ./fips build             
=== building: osx-xcode-release
cmake --build . --parallel 18 --config Release -- 
2023-08-01 19:44:33.767 xcodebuild[21193:111470] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project sokol-tools.xcodeproj build -target ALL_BUILD -parallelizeTargets -configuration Release -jobs 18 -hideShellScriptEnvironment

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

2023-08-01 19:44:33.787 xcodebuild[21193:111470] Writing error result bundle to /var/folders/j_/r7p6c4bj0w151s671pwkgscw0000gn/T/ResultBundle_2023-01-08_19-44-0033.xcresult
xcodebuild: error: 'sokol-tools.xcodeproj' does not exist.
[ERROR] Failed to build config 'osx-xcode-release' of project 'sokol-tools'

The steps are as per README as I mentioned above for MacOS using osx-xcode-release:

image

Tools I have installed:

MacOS version Ventura 13.5 (22G74)

Have looked through the closed issues and did not found a relevant one. Could you help to solve the problem, please?

floooh commented 1 year ago

...hmm somehow the cmake generation step is missing, it should look like this:

sokol-tools ➤ ./fips build
=== building: osx-xcode-debug
=== generating: osx-xcode-debug
config file: /Users/floh/projects/fips/configs/osx-xcode-debug.yml
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk"
  FIPS_AUTO_IMPORT="ON"
  FIPS_CONFIG="osx-xcode-debug"
  FIPS_LOCAL_BUILD="OFF"
...

Can you run ./fips clean all followed by ./fips gen and post the output here?

(e.g. it might be that a previous attempt at generating the project files has failed, the build directory has been left in an incomplete state)

nosakou commented 1 year ago

Yeah, sure:

./fips gen
=== generating: osx-xcode-release
config file: /Users/yulianosakova/PycharmProjects/wanna-utils/wanna_utils/envmap_processing/renderer/tools/fips/configs/osx-xcode-release.yml
Preset CMake variables:

  CMAKE_BUILD_TYPE="Release"
  CMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk"
  FIPS_AUTO_IMPORT="ON"
  FIPS_CONFIG="osx-xcode-release"
  FIPS_LOCAL_BUILD="OFF"

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:6 (project):
  No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:6 (project):
  No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
[ERROR] failed to generate build files for config 'osx-xcode-release'
[ERROR] 1 out of 1 configs failed!
nosakou commented 1 year ago

Actually I resolved it by adding to sokol-tools/CMakeLists.txt a couple of environment variables:

set(CMAKE_C_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc")
set(CMAKE_CXX_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++")

The destination of the both files I found with: xcrun --find cxx xcrun --find cc

floooh commented 1 year ago

That should not be needed, can you check if the Xcode command line tools are installed?

Either run xcode-select --install on the command line or check in Xcode => Setting => Locations, there's a dropdown called Command Line Tools - both should put the Apple clang toolchain into the path (e.g. you should be able to run clang --version in the terminal.

nosakou commented 1 year ago
xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updates

and

clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
nosakou commented 1 year ago

Without setting the variables to the CMakeLists.txt I am having the same build error as mentioned above.

floooh commented 1 year ago

...that is super weird, the output of xcode-select and clang looks correct...

I wonder if cmake is actually trying to run cc and c++ to detect the compiler.

Can you try cc --version and c++ version on the terminal?

...and also, AFAIK cmake looks at the environment variables CC and CXX, maybe those are overriden? (e.g. try echo $CC and echo $CXX, those should be empty.

(PS: while at it, also check whether the CPATH, CFLAGS and CXXFLAGS environment variables are set, I've come across quite a few Mac users who had set those because sometimes that's recommended by homebrew and then had trouble building projects)

nosakou commented 1 year ago
cc --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

and

c++ --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

echo commands for the both $CXX and $CC are empty. So the CXXFLAGS, CPATH, CFLAGS are. If it is makes sence I have 2,3 GHz 8-Core Intel Core i9 processor though AFAIK M1 users do not have this problem with build as I do. But I am not sure if the processor architecture is the reason here.

floooh commented 1 year ago

I'm out of ideas tbh, it shouldn't be an ARM vs Intel thing, but let me check on my Intel Mac (I don't have uptodate macOS and Xcode on there though).

PS: nvm, I need to setup Github access first again, somehow my ssh key was deleted or is expired.

floooh commented 1 year ago

...so in general it works on my Intel Mac, the compiler is detected:

sokol-tools ➤ ./fips gen
=== generating: osx-xcode-debug
config file: /Users/floh/projects/fips/configs/osx-xcode-debug.yml
cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Debug -DFIPS_CONFIG=osx-xcode-debug -DFIPS_LOCAL_BUILD=OFF -DFIPS_USE_CCACHE=OFF -DFIPS_AUTO_IMPORT=ON -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -B/Users/floh/projects/fips-build/sokol-tools/osx-xcode-debug -H/Users/floh/projects/sokol-tools
-- The C compiler identification is AppleClang 12.0.5.12050022-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- 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
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMAKE_BUILD_TYPE: Debug
FIPS_ROOT_DIR: /Users/floh/projects/fips
FIPS_PROJECT_DIR: /Users/floh/projects/sokol-tools
FIPS_BUILD_DIR: /Users/floh/projects/fips-build
FIPS_DEPLOY_DIR: /Users/floh/projects/fips-deploy
FIPS_PROJECT_NAME: sokol-tools
FIPS_AUTO_IMPORT: ON
FIPS_CONFIG: osx-xcode-debug
FIPS_PROJECT_BUILD_DIR: /Users/floh/projects/fips-build/sokol-tools/osx-xcode-debug
FIPS_PROJECT_DEPLOY_DIR: /Users/floh/projects/fips-deploy/sokol-tools/osx-xcode-debug
Host system: OSX
CMAKE_CXX_COMPILER_ID: AppleClang
Detected C++ Compiler: Clang (FIPS_CLANG)
FIPS_PLATFORM: OSX
FIPS_PLATFORM_NAME: osx
-- Found Python: /usr/local/Frameworks/Python.framework/Versions/3.9/bin/python3.9 (found version "3.9.12") found components: Interpreter
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/floh/projects/fips-build/sokol-tools/osx-xcode-debug
1 configs generated

...I'm on fairly old versions though:

clang version output:

Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

...maybe it's cmake? What does cmake --version say? I have 3.23.1 on the Intel Mac.

nosakou commented 1 year ago

This is the cmake version:

cmake --version                                                                                                
cmake version 3.23.2
floooh commented 1 year ago

Also looks good. Sorry now I'm really out of ideas..

nosakou commented 1 year ago

That's OK, at least I found a workaround :-)