The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=14057 
====================================================================== 
Reported By:                szx
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14057
Category:                   CMake
Reproducibility:            N/A
Severity:                   feature
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-04-02 10:56 EDT
Last Modified:              2013-04-02 10:56 EDT
====================================================================== 
Summary:                    Add GROUP_SOURCES property for targets
Description: 
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)


Additional Information: 
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)
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-04-02 10:56 szx            New Issue                                    
======================================================================

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to