OSX 10.10 CMake 3.0.2 and clang won't find local headers

On OSX 10.9 I have installed many header libraries under

/usr/include
/usr/local/include

      

And everything worked fine. Today I did a "free upgrade" to Yosemite and suddenly everything stopped working. Along with Yosemite, I also (previously) updated Xcode (note, I do not compile with Xcode, but clang directly via the command line).

I have CMakeLists.txt which explicitly includes / usr / include

set(INCLUDE_HEADERS ${INCLUDE_HEADERS}
             /usr/include
             /usr/local/include)
include_directories(SYSTEM ${INCLUDE_HEADERS})

      

However, when I try to compile, I instantly get:

fatal error: 'boost/lexical_cast.hpp' file not found
#include <boost/lexical_cast.hpp>

      

What's going on here? Does anyone else experience this or even know how to solve it? Everything worked fine in 10.9 (oh why did I upgrade?) I might also be doing something wrong as I noticed that cmake was upgraded to 3.0.2

+3


source to share


2 answers


The canonical way for such situations:

find_package(boost REQUIRED)
if(Boost_FOUND)
    include_directories(${boost_INCLUDE_DIRS})
endif()

      



It will add the path to the BOOST header to the compiler search path.

+2


source


I found the problem and solution. The problem is that by default clang only appears to search in the platform SDK folder:

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk

      

This hasn't been used before, or I've changed somehow without knowing. So, I changed mine .bash_profile

in my home directory and added:



export C_INCLUDE_PATH=/usr/include:/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/include:/usr/local/include

      

Close and reopen a new terminal and now clang finds the included dirs and works fine. Although I'm concerned about the fact that only the last one (/ usr / local / include) seems to be used with the -I flag.

+3


source







All Articles