[CMake] Makefile generator and header files in 2.8.8

David Nadlinger code at klickverbot.at
Fri May 25 11:03:10 EDT 2012


On 25 May 2012, at 16:48, Eric Noulard wrote:
> 2012/5/25 David Nadlinger <code at klickverbot.at>:
>> In our project, we are explicitly adding all the header files along 
>> with the
>> source files to the respective build targets in order for them to 
>> show up in
>> CMake-generated Visual C++ projects.
>>
>> Up to and including 2.8.7, this worked well as the Makefile generator 
>> simply
>> ignored the header files, but starting with 2.8.8, this no longer 
>> seems to
>> be the case.
>
> Which means?
> Generated makefile tries to compile the header?
Yes, it compiles both .h and .o files as separate object files.

> On which platform do you get that buggy behavior?
cmake version 2.8.8, on OS X 10.7, installed via MacPorts

> Could you give us a strip down example of the problem
> may be with one header and one C/C++ file?

Sorry, yes – this seems to be a fairly minimal test case (create some 
arbitrary test.c/test.h files to run):

---
cmake_minimum_required(VERSION 2.6)

set(TEST_SRC test.c test.h)
set_source_files_properties(${TEST_SRC} PROPERTIES LANGUAGE CXX)

add_library(test ${TEST_SRC})
---

Oh well, RTFM 
(http://www.cmake.org/cmake/help/v2.8.8/cmake.html#prop_sf:LANGUAGE): 
»Do not set this for header or files that should not be compiled.« I 
guess we have been relying on unspecified behavior all the time, then.

Anyway, thanks for your quick response,
David


More information about the CMake mailing list