Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
Qt Creator 7.0.0
-
None
-
-
6431932569 (qt-creator/qt-creator/master) 6431932569 (qt-creator/qt-creator/9.0), f76e0de7b (13.0)
Description
Hi,
the cmake source_group setting is still a bit buggy in QtCreator
Example:
# "" ->empty named group, i.e. toplevel - directly under target
source_group("" FILES
${CMAKE_BINARY_DIR}/src/a/a1.cpp
${CMAKE_BINARY_DIR}/src/a/a2.cpp
)
source_group("" FILES
${CMAKE_BINARY_DIR}/inc/a/a1.h
${CMAKE_BINARY_DIR}/inc/a/a2.h
)
results in the following wrong buggy tree-browser:
It should be fixed, to look like this:
In other words: both cpp files and h header under the same named group! (in this special case the named group is "", meaning: toplevel - directly under target).
To reproduce, simply grab this CMakeLists.txt and try it!
cmake_minimum_required(VERSION 3.18) project(go LANGUAGES CXX) file(WRITE ${CMAKE_BINARY_DIR}/src/a/a1.cpp "") file(WRITE ${CMAKE_BINARY_DIR}/src/a/a2.cpp "") file(WRITE ${CMAKE_BINARY_DIR}/inc/a/a1.h "") file(WRITE ${CMAKE_BINARY_DIR}/inc/a/a2.h "") add_library(a ${CMAKE_BINARY_DIR}/src/a/a1.cpp ${CMAKE_BINARY_DIR}/src/a/a2.cpp ${CMAKE_BINARY_DIR}/inc/a/a1.h ${CMAKE_BINARY_DIR}/inc/a/a2.h ) set(SG_VARIANT "1a" CACHE STRING "variant") set(SG_VARIANT_CHOICES "1a" "1b" "2a" "2b") set_property(CACHE SG_VARIANT PROPERTY STRINGS ${SG_VARIANT_CHOICES}) if (NOT SG_VARIANT IN_LIST SG_VARIANT_CHOICES) message(FATAL_ERROR "SG_VARIANT must be one of ${SG_VARIANT_CHOICES}") endif () message(STATUS "SG_VARIANT " ${SG_VARIANT}) if ("${SG_VARIANT}" STREQUAL "1a") ## variant 1a source_group("" FILES ${CMAKE_BINARY_DIR}/src/a/a1.cpp ${CMAKE_BINARY_DIR}/src/a/a2.cpp ) source_group("" FILES ${CMAKE_BINARY_DIR}/inc/a/a1.h ${CMAKE_BINARY_DIR}/inc/a/a2.h ) elseif ("${SG_VARIANT}" STREQUAL "1b") ## variant 1b source_group(TREE ${CMAKE_BINARY_DIR}/src/a FILES ${CMAKE_BINARY_DIR}/src/a/a1.cpp ${CMAKE_BINARY_DIR}/src/a/a2.cpp ) source_group(TREE ${CMAKE_BINARY_DIR}/inc/a FILES ${CMAKE_BINARY_DIR}/inc/a/a1.h ${CMAKE_BINARY_DIR}/inc/a/a2.h ) elseif ("${SG_VARIANT}" STREQUAL "2a") ## variant 2a source_group("here\\sources" FILES ${CMAKE_BINARY_DIR}/src/a/a1.cpp ${CMAKE_BINARY_DIR}/src/a/a2.cpp ) source_group("here\\includes" FILES ${CMAKE_BINARY_DIR}/inc/a/a1.h ${CMAKE_BINARY_DIR}/inc/a/a2.h ) elseif ("${SG_VARIANT}" STREQUAL "2b") ## variant 2b source_group(TREE ${CMAKE_BINARY_DIR}/src/a PREFIX "here\\sources" FILES ${CMAKE_BINARY_DIR}/src/a/a1.cpp ${CMAKE_BINARY_DIR}/src/a/a2.cpp ) source_group(TREE ${CMAKE_BINARY_DIR}/inc/a PREFIX "here\\includes" FILES ${CMAKE_BINARY_DIR}/inc/a/a1.h ${CMAKE_BINARY_DIR}/inc/a/a2.h ) endif()
CmakeVariable SG_VARIANT is "1a" or "1b"
Bug (current):
Fix should be:
CmakeVariable SG_VARIANT is "2a" or "2b"
Bug (current):
Fix should be:
To compare with visual studio:
(in visual studio it is correct, when generating a sln solution)
cmake -G "Visual Studio 17 2022" -D SG_VARIANT=1a ../bugreport
cmake --open .
Reference documentation:
https://cmake.org/cmake/help/latest/command/source_group.html
Attachments
Issue Links
- relates to
-
QTCREATORBUG-30620 cmake: incorrect source_group filters in some situations
- Closed
For Gerrit Dashboard: QTCREATORBUG-27432 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
420031,4 | cmake: Add option to disable subfolders | 8.0 | qt-creator/qt-creator | Status: ABANDONED | +1 | 0 |
420040,2 | cmake: Add option to disable subfolders | master | qt-creator/qt-creator | Status: MERGED | +2 | 0 |
553556,2 | CMakePM: Do not show subfolders for custom source_groups | 13.0 | qt-creator/qt-creator | Status: MERGED | +2 | 0 |