conan: [bug] CMakeToolchain incorrectly sets the CMAKE_OSX_SYSROOT variable
Environment details
- Operating System+version: MacOS Ventura 13.3.1
- Compiler+version: Xcode 14.3
- Conan version: 2.0.5
- Python version: 3.11.3
Steps to reproduce
The generated conan_toolchain.cmake file contains following lines:
# Setting CMAKE_OSX_SYSROOT SDK, when using Xcode generator the name is enough
# but full path is necessary for others
set(CMAKE_OSX_SYSROOT macosx CACHE STRING "" FORCE)
The line does not reflect the note from the comment, and this is problematic for non-Xcode generators, such as Ninja or “Ninja Multi-Config”, as they then can’t build code due to the error “no such sysroot directory: ‘macosx’ [-Wmissing-sysroot]”.
Logs
No response
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (11 by maintainers)
After diving into the conan source code I was able to fix this inside my profile by adding the following to the [conf] section
The comment from earlier in the thread gives a bit more context. https://github.com/conan-io/conan/issues/13925#issuecomment-1596274888
The above change worked for me.
If you’re using conan say in VScode in MacOS.
Find the conan profile file by running this command. $ conan profile detect /Users/mylove/.conan2/profiles/default
Get the Path to the latest installed MacOS SDK: $ xcrun --show-sdk-path /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Add this path in the conan profile file under conf section [conf] tools.apple:sdk_path=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Hello I don’t understand why this ticket is closed ? I have found a working workaround using the comment above, but I believe that conan should be able to figure the path automatically leveraging the
xcruncommand and not require such manual workaround.OK, I found it.
Apparently, our code base had some workaround for CMake 3.5 + Ninja on Mac that caused problems with incorrectly detected sysroot, so the variable
CMAKE_OSX_SYSROOTwas unset. It’s interesting why was then not empty, but set tomacosx, as defined in theconan_toolchain.cmake. The workaround was dated to the year 2016.All in all, thank you for your help. This is not a conan issue - I just need to clean up some workarounds for old cmake versions that are no longer needed in my codebase 😊 .