MantisBT - CMake
View Issue Details
0014008CMakeCMakepublic2013-03-13 05:372014-05-26 17:09
Magnus 
Alex Neundorf 
normalminoralways
closedno change required 
AMD64LinuxArchLinux
CMake 2.8.10.2 
 
0014008: Eclipse generator - grouping header files with non-standard suffix in the 'Header Files' folder
The 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.
Create 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.
No tags attached.
related to 0014261closed Alex Neundorf virtual subfolders not created in CDT generator 
png non-standard-header.png (33,748) 2013-03-13 05:37
https://public.kitware.com/Bug/file/4680/non-standard-header.png
png
Issue History
2013-03-13 05:37MagnusNew Issue
2013-03-13 05:37MagnusFile Added: non-standard-header.png
2013-03-13 17:35Alex NeundorfAssigned To => Alex Neundorf
2013-03-13 17:35Alex NeundorfStatusnew => assigned
2013-04-28 09:29Alex NeundorfNote Added: 0032948
2013-06-12 07:14MagnusNote Added: 0033278
2013-06-12 07:19MagnusNote Edited: 0033278bug_revision_view_page.php?bugnote_id=33278#r1189
2013-06-30 15:12Alex NeundorfRelationship addedrelated to 0014261
2014-05-26 17:09Alex NeundorfNote Added: 0035934
2014-05-26 17:09Alex NeundorfStatusassigned => closed
2014-05-26 17:09Alex NeundorfResolutionopen => no change required

Notes
(0032948)
Alex Neundorf   
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   
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   
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.