[CMake] possible bug VS2010 generation project

Andrea Galeazzi Galeazzi at korg.it
Thu Dec 16 07:18:31 EST 2010


I make this very simple project in order to reproduce a possible bug:

cmake_minimum_required(VERSION 2.8)
project(HelloLib)
set(SOURCES
    ./sayHello.cpp
    ./fileToExclude.c
)
set_source_files_properties(
                            ./fileToExclude.c
    PROPERTIES HEADER_FILE_ONLY TRUE)

add_library(HelloLib STATIC ${SOURCES})

When I try to generate a VS2010 project, it produces an invalid XML. In 
particular it generates the following section:
<ItemGroup>
    <ClCompile Include="..\sayHello.cpp" />
    <ClInclude Include="..\fileToExclude.c">
      <CompileAs 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsC</CompileAs>
      <CompileAs 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsC</CompileAs>
      <CompileAs 
Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">CompileAsC</CompileAs>
      <CompileAs 
Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">CompileAsC</CompileAs>
    </ClCompile>
  </ItemGroup>
 
It seems that CMake get confused when it has to merge the 
HEADER_FILE_ONLY property with some other informations like CompileAS 
etc....
In fact when I change the file extension from ./sayHello.cpp to 
./sayHello.c everything works fine.
A similar problem happens when I try to specify additional includes:
set_source_files_properties(./fileToExclude.c PROPERTIES COMPILE_FLAGS 
"-IW:\\myPath")

The same CMakeLists.txt works fine for Eclipse and MinGW makefile as target.
I currently use the last version of CMake (2.8.3)

Let me know if it's an actual bug or if I make some mistakes.


More information about the CMake mailing list