View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014008CMakeCMakepublic2013-03-13 05:372014-05-26 17:09
ReporterMagnus 
Assigned ToAlex Neundorf 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformAMD64OSLinuxOS VersionArchLinux
Product VersionCMake 2.8.10.2 
Target VersionFixed in Version 
Summary0014008: Eclipse generator - grouping header files with non-standard suffix in the 'Header Files' folder
DescriptionThe Eclipse project generator creates a number of (virtual) folders created for each target. The targets C/C++ files are put into 'Source Files' and header files with standard suffixes, e.g. .h, are put into 'Header Files'. This works as expected.

It's not uncommon in the wild to use different suffixes for automatically generated files, e.g. in a project I work on all auto-generated headers have a .inc suffix. These files do not get added to the 'Header Files' folder, instead they end up on the target's top level.
Steps To ReproduceCreate a CMakeLists.txt with the following contents:

cmake_minimum_required(VERSION 2.8)
project( test )

enable_language( C )

add_executable( silly
    silly.c
    silly.h
    non-standard.inc
    )

Generate an Eclipse project and load it. You'll see something like what's shown in the attached picture.
TagsNo tags attached.
Attached Filespng file icon non-standard-header.png [^] (33,748 bytes) 2013-03-13 05:37

 Relationships
related to 0014261closedAlex Neundorf virtual subfolders not created in CDT generator 

  Notes
(0032948)
Alex Neundorf (developer)
2013-04-28 09:29

The Eclipse generator uses the cmake source-groups feature to create those subfolders.
Did you try playing around with the source_group() command to achieve a grouping you like ?
The "Header Files" group is created automatically using the name "Header Files" and the regex "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$".

I'm not sure whether it is possible to override/redefine the regex for a built-in source group. If that does not work, you can create a new group, e.g. something like
source_group("Generated files" REGULAR_EXPRESSION "....")
(0033278)
Magnus (reporter)
2013-06-12 07:14
edited on: 2013-06-12 07:19

I modified the CMakeLists.txt file to look like this:

cmake_minimum_required(VERSION 2.8)
project( test )

enable_language( C )

source_group("Generated headers" REGULAR_EXPRESSION ".*\\.inc$")

add_executable( silly
    silly.c
    silly.h
    non-standard.inc
    )

The *.inc file is still not in a group, and there is not even a group called "Generated headers".

(0035934)
Alex Neundorf (developer)
2014-05-26 17:09

I tested this here with cmake 3.0.0 rc2 and Eclipse Kepler, and using the source_group() command this works without problems for me.
This is my CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)

source_group("Header Files" REGULAR_EXPRESSION
                      "\\. (h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl|blub)$")

add_executable(hello main.c foo.h bar.blub)


Both foo.h as well as bar.blub show up in the folder "Header Files" under the target "hello".

So I'm closing this ticket.
If I missed something, fell free to reopen it.

 Issue History
Date Modified Username Field Change
2013-03-13 05:37 Magnus New Issue
2013-03-13 05:37 Magnus File Added: non-standard-header.png
2013-03-13 17:35 Alex Neundorf Assigned To => Alex Neundorf
2013-03-13 17:35 Alex Neundorf Status new => assigned
2013-04-28 09:29 Alex Neundorf Note Added: 0032948
2013-06-12 07:14 Magnus Note Added: 0033278
2013-06-12 07:19 Magnus Note Edited: 0033278
2013-06-30 15:12 Alex Neundorf Relationship added related to 0014261
2014-05-26 17:09 Alex Neundorf Note Added: 0035934
2014-05-26 17:09 Alex Neundorf Status assigned => closed
2014-05-26 17:09 Alex Neundorf Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team