[osg-users] [build] OSG Build Error on Mac OSX with XCode 7 and CMake 3.4 (or greater)

Ravi Mathur ravidavi at utexas.edu
Sun Jul 17 23:17:26 PDT 2016


Hi all,

I'm surprised nobody has seen this yet, but OSG does not build on OSX when using XCode 7 and CMake 3.4+. Specifically, the Configure step can be run once, but cannot ever be run again unless the CMake cache is deleted. The error through by CMake is the infamous:

Code:
CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but CMAKE_OSX_SYSROOT:
   ""
  is not set to a MacOSX SDK with a recognized version.  Either set
  CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to
  empty.



After hours of debugging, I found that this error only happens on CMake 3.4 and onward, which led me to see what changed in in that version. Basically, the OS initialization phase of CMake has changed how it uses the CMAKE_OSX_ARCHITECTURES variable, which according to CMake documentation (https://cmake.org/cmake/help/v3.5/variable/CMAKE_OSX_ARCHITECTURES.html) should be set before the first call to PROJECT(). In OSG's CMakeLists.txt file, that variable is set waaaay down in line 1114:

Code:
SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX" FORCE)



So the fact that this ever worked was just good fortune, but it seems our luck has run out. Commenting out that line, or equivalently removing the FORCE flag, fixes the Configure-stage error for all versions of CMake.

Any thoughts on this? I think if CMAKE_OSX_ARCHITECTURES must be set in OSG, it should really be set before the first call to PROJECT. If we no longer have an OSX maintainer, then I can take a crack at coming up with a solution.

Thanks,
Ravi

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68155#68155








More information about the osg-users mailing list