leetal / ios-cmake

A CMake toolchain file for iOS/iPadOS, visionOS, macOS, watchOS & tvOS C/C++/Obj-C++ development
BSD 3-Clause "New" or "Revised" License
1.91k stars 450 forks source link

[question] reason for using "BOTH" as default for CMAKE_FIND_ROOT_PATH_MODE_*? #134

Open Znerole opened 2 years ago

Znerole commented 2 years ago

Hey! I'm just curious, why the defaults for the different CMAKE_FIND_ROOT_PATH_MODE_* switches had been changed to BOTH in this (old) change: https://github.com/leetal/ios-cmake/commit/96e13cf067500f51121df9c0e8a1e843da8c0966

Last week I was quite confused, because my iOS cross compilation pulled in a MacOS library installed via brew on my host machine. In comparison, the Android toolchain sets everything to ONLY per default, which makes more sense to me.

I guess BOTH was chosen to better support MacOS and/or Catalyst as a target platform? Could the default value depend on what kind of target we are building for?

Anyway, I'm explicitly setting these values now in my build, which fixes my problem as expected, but I'm still scratching my head over why I would want to use BOTH in the first place when cross compiling. Is it a thing to install iOS libraries globally on the host? (Disclaimer: I'm not a Mac user).

leetal commented 2 years ago

Yes, using BOTH was indeed a fix to better handle dependencies for macOS, but also since older versions of CMake did have some issues with finding dependencies for simulators etc. Will look into updating or changing the current behaviour since versions older than CMake 3.12 is ancient by now.