On 17. Mar, 2010, at 16:06 , David Doria wrote:

>> Those files should not need to be on the include path since your compiler 
>> should know how to find them (after all, they belong to the c++ standard 
>> library). Do you happen to use -nostdinc or -nostdinc++ in your compile 
>> flags? Also, what is your c++ compiler?
>> 
>> If you do a verbose build ("make VERBOSE=1"), what do you see on the compile 
>> line?
>> 
>> Michael
>> 
>> 
> 
> I am using:
> g++ (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
> 
> I am not using -nostdinc or -nostdinc++.
> 
> The verbose output showed me that it is running gcc (instead of g++).
> I imagine this is the problem. Does cmake tell make to use gcc if the
> file extensions are .c? That is only thing I can think of that is
> different about this project than my normal projects (which typically
> have .cxx and .cpp). Is there a way to force it to use g++ no matter
> what the extensions are?
> 
> Thanks,
> 
> David

Yes, that would be the problem. CMake assumes that .c is a C file, not C++.

To override this:

set(SRCS src1.c src2.c src3.c)
add_executable(super ${SRCS})
set_source_files_properties(${SRCS} PROPERTIES
  LANGUAGE CXX)

To set this globally, you can override the CMAKE_C_SOURCE_FILE_EXTENSIONS and 
CMAKE_CXX_SOURCE_FILE_EXTENSIONS variables, e.g.

# never compile C (unless explicitly specified with the LANGUAGE property)
set(CMAKE_C_SOURCE_FILE_EXTENSIONS)
# consider .c files to be C++
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS c)



Michael
_______________________________________________
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

Reply via email to