MantisBT - CMake
View Issue Details
0014057CMakeCMakepublic2013-04-02 10:562016-06-10 14:31
szx 
Kitware Robot 
normalfeatureN/A
closedmoved 
 
 
0014057: Add GROUP_SOURCES property for targets
It would be nice if there was a property that automatically grouped target's soruce files on directory basis, similar to what source_group() does.

set_target_properties(foo PROPERTIES GROUP_SOURCES ON)
At the moment this can be achieved with e.g. a macro like this:

function(group_target_sources target)
    get_target_property(sources ${target} SOURCES)
    foreach(file ${sources})
        get_filename_component(path "${file}" ABSOLUTE)
        get_filename_component(path "${path}" PATH)
        if(file MATCHES "${PROJECT_BINARY_DIR}")
            file(RELATIVE_PATH path ${PROJECT_BINARY_DIR} "${path}")
        else()
            file(RELATIVE_PATH path ${PROJECT_SOURCE_DIR} "${path}")
        endif()
        string(REGEX REPLACE "/" "\\\\" win_path "${path}")
        source_group("${win_path}" REGULAR_EXPRESSION "${path}/[^/\\]+\\..*")
    endforeach()
endfunction()

(in fact this is what I use in personal projects)
No tags attached.
Issue History
2013-04-02 10:56szxNew Issue
2016-06-10 14:28Kitware RobotNote Added: 0042260
2016-06-10 14:28Kitware RobotStatusnew => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0042260)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.