Right now I am having a very difficult time trying to get CMake+LLVM (clang) working proper on macos. Microsoft Visual Studio doesn't seem to support C++ development on macos, XCode seems to want to completely ignore the ~/bin
and /usr/bin
folders when executing custom build commands (I wrote a script to call cmake and make in the proper directories), and VSCode just SKIPS all my breakpoints (and it appears LLVM is completely ignoring the -g
and excluding debug symbols)...
Has anyone been able to get a platform-independent toolset running on macos??? If so how have you been able to do this and what toolset + IDE are you using? If you were able to get XCode of VSCode to work how did you do it?
maybe I'm doing somthing wrong.
Here is my cmakelists.txt: (https://pastebin.com/RymrmUfk)
Here is my build command: (https://pastebin.com/wbdpccZ6)
For the lonely and tourtured souls that have to tread this path:
There is hope: I was able to get a XCode project to run a custom, cross-platform CMake build using a custom build script and custom project settings... APPLE THIS SHOULD BE A DEFAULT TEMPLATE BTW
To begin you need to use canonical paths in any custom build script. You can get the path to your llvm toolset by xcodebuild -find [tool]
and just copying the pathname. Relevant tools here are clang
, clang++
, and lldb
for the compilers and debugger.
Next Step: write somthing in zsh or bash to call cmake and make your project in the build folder. not too hard -- I linked mine to pastebin and that should be good for most projects if you follow cmake standards. You can modify it as needed.
Next click on your project in the sidebar and check your targets: yes xcode probably already has one, and it's stupid - trash it. Make a new, custom target. Go to the info tabs and set the command to your custom command and set the arguments and working directory appropriately.
Now Everything should build nice and sweet. Run it to test. If somthing is wrong with your toolset or build script it should rear its ugly head, but odds are it should work just fine.
Now you're gonna want to debug. Because of our custom target, xcode has conveniently forgotten what to run. Let's tell it by opening up our scheme. To do this you'll need to first add the executable to the project. With the project built "add files..." in the sidebar and add your executable from the build directory directly to your project. Now we can tell xcode to run it: click on product on the menu bar and go to scheme then edit scheme. Jump to the run section on the left hand side and select your executable.
It is done.
Personal note to Apple: This should be easier. This is literally the simplest case for a C++ project and yet it took quite a lot of moving things around to get working.