[CMake] Why CMake automatically uses -isysroot <SDKs> on OS X?

Mojca Miklavec mojca.miklavec.lists at gmail.com
Thu Jun 19 04:20:57 EDT 2014


Hi,

I was struggling with a compilation of a project via CMake. Thu build
kept failing for unknown reasons until I realized that CMake would
automatically compile with

    -isysroot /Developer/SDKs/MacOSX10.6.sdk \
    -mmacosx-version-min=10.6

(or any other sdk, depending on OS version) unless instructed *NOT* to
do so by specifying:

   -DCMAKE_OSX_SYSROOT="/"
   -DCMAKE_OSX_DEPLOYMENT_TARGET=""

I had extra problems due to the fact that software which I was
compiling called CMake itself and so the projects that were being
included and automatically compiled in the process were failing even
if I set those two flags. OK, the fact that these two flags weren't
passed to the "child build" was clearly a bug in that software that
needs to fixed, but still.

Why is the default behavior of CMake to always add -isysroot unless
instructed otherwise?

I'm compiling from command-line, using "cmake -D<flag1> -D<flag2> ..."
generating gnu makefiles, using CMake version 3.0.0 and clang as the
compiler.

The reason why I was struggling was because I had to compile C++11
code on OS X 10.6 and have installed libc++ in /usr/lib, but -isysroot
reported a broken C++ compiler when that library was absent from the
SDK. While that might be a strange reason, there might be other valid
cases when one really expects the default behaviour when not passing
any flags.

Thank you,
    Mojca


More information about the CMake mailing list