fix for CMake file grouping with MSVC project files.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 8 Nov 2010 06:31:45 +0000 (06:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 8 Nov 2010 06:31:45 +0000 (06:31 +0000)
build_files/cmake/macros.cmake

index 42aa9d1f8b51ff025a60ba406af839fadd2a8139..3392398fd446c1a5004625275592cd2f7ad732cd 100644 (file)
@@ -14,17 +14,15 @@ MACRO(BLENDERLIB_NOLIST
        ADD_LIBRARY(${name} ${INC_ALL} ${sources})
 
        # Group by location on disk
-       SOURCE_GROUP(Files FILES CMakeLists.txt)
+       SOURCE_GROUP("Source Files" FILES CMakeLists.txt)
        SET(ALL_FILES ${sources} ${INC_ALL})
        FOREACH(SRC ${ALL_FILES})
-               STRING(REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "Files" REL_DIR "${SRC}")
-               STRING(REGEX REPLACE "[\\\\/][^\\\\/]*$" "" REL_DIR "${REL_DIR}")
-               STRING(REGEX REPLACE "^[\\\\/]" "" REL_DIR "${REL_DIR}")
-               IF(REL_DIR)
-                       SOURCE_GROUP(${REL_DIR} FILES ${SRC})
-               ELSE(REL_DIR)
-                       SOURCE_GROUP(Files FILES ${SRC})
-               ENDIF(REL_DIR)
+               GET_FILENAME_COMPONENT(SRC_EXT ${SRC} EXT)
+               IF(${SRC_EXT} MATCHES ".h" OR ${SRC_EXT} MATCHES ".hpp") 
+                       SOURCE_GROUP("Header Files" FILES ${SRC})
+               ELSE()
+                       SOURCE_GROUP("Source Files" FILES ${SRC})
+               ENDIF()
        ENDFOREACH(SRC)
 ENDMACRO(BLENDERLIB_NOLIST)