[CMake] Sorting Xcode source groups

Kevin Wojniak kainjow at kainjow.com
Wed Jan 29 13:22:11 EST 2014


The way source groups are sorted in Xcode seems off.

Here’s a sample file (using v2.8.12):

cmake_minimum_required(VERSION 2.8)
project(SourceGroupTest)
set(SOURCES
    ./Zebra/file.c
    ./Snake/file.c
    ./Dog/file.c
)
source_group(Snake REGULAR_EXPRESSION "Snake/.*")
source_group(Zebra REGULAR_EXPRESSION "Zebra/.*")
source_group(Dog REGULAR_EXPRESSION "Dog/.*")
add_executable(${PROJECT_NAME} ${SOURCES})

Full download here:
https://www.dropbox.com/s/ikrlhslqk3yvsay/XcodeSourceGroups.zip

I would expect that the order of the groups be Snake, Zebra, Dog, however it's Zebra, Snake, Dog.

I played around with this and it seems that the order of SOURCES dictates the order of the groups. If I rearrange the listings of the files in SOURCES, it affects the group order. But this seems counterintuitive.

Shouldn’t the groups by sorted based on the order of calls to source_group()?

Kevin


More information about the CMake mailing list