[CMake] CMake ignores CPLUS_INCLUDE_PATH?

Alain Leblanc aalebl at gmail.com
Mon Oct 19 16:46:26 EDT 2009


On 10/19/2009 04:35 PM, David Doria wrote:
> On Mon, Oct 19, 2009 at 4:31 PM, Eric Noulard<eric.noulard at gmail.com>  wrote:
>    
>> 2009/10/19 David Doria<daviddoria at gmail.com>:
>>      
>>>> You can use $ENV{CPLUS_INCLUDE_PATH} to get the contents of the path.
>>>>
>>>>          
>>> I tried to do this:
>>> INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} $ENV{CPLUS_INCLUDE_PATH})
>>>        
>> I think the appropriate syntax should be:
>>
>> INCLUDE_DIRECTORIES($ENV{CPLUS_INCLUDE_PATH}))
>>
>> even if I don't know if comma separated value is supported because
>> the doc says:
>>      
> My understanding was that:
> INCLUDE_DIRECTORIES(a)
> sets INCLUDE_DIRECTORIES to a
>
> where
> INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} a)
> sets INCLUDE_DIRECTORIES to what it was PLUS a
>
> Is this correct?
>
> Also, these are colon separated values in the .bashrc file - so is the
> answer that cmake cannot do this? If so, does it seem like a
> reasonable feature request?
>
> Thanks,
>
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>    
The CPLUS_INCLUDE_PATH variable is separated with colons (':'). For 
cmake you need to replace those with either spaces or semicolons (sorry, 
can't remember exactly). This is what I have in one of my files.

if (NOT $ENV{CPLUS_INCLUDE_PATH}  STREQUAL "")
   string (REPLACE ":" " " INCLUDES $ENV{CPLUS_INCLUDE_PATH})
   string (REPLACE "//" "/" INCLUDES ${INCLUDES})
   string(REGEX MATCHALL "[^ ]+" LIST_INCLUDES ${INCLUDES})
endif (NOT $ENV{CPLUS_INCLUDE_PATH}  STREQUAL "")

I forgot why I needed the second REPLACE. The first one replaces the ':' 
with spaces. The REGEX_MATCHALL creates a list with all paths in the 
original CPLUS_INCLUDE_PATH. At the end you probably want

include_directories(LIST_INCLUDES)

Sorry it's been a while since I wrote this and didn't do a good job 
documenting. Let me know if it does not solve your problem.

a






More information about the CMake mailing list