From 0624cd1d19d1a5fb475683b128699383a958691f Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 23 Oct 2022 13:40:26 +0200 Subject: [PATCH] Show a nice folder structure in Visual Studio (#2890) --- CMakeLists.txt | 6 ++++++ src/CMakeLists.txt | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7f950f2..3c615e56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,12 @@ set(CUTTER_VERSION_FULL "${CUTTER_VERSION_MAJOR}.${CUTTER_VERSION_MINOR}.${CUTTE project(Cutter VERSION "${CUTTER_VERSION_FULL}") +# Enable solution folder support +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +# Put Qt files in a separate folder +set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "Generated Files") + set(CMAKE_CXX_STANDARD 11) include(CutterInstallDirs) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9b606132..e3c2c97d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -442,8 +442,11 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" set_source_files_properties(${BINDINGS_SOURCE} PROPERTIES COMPILE_FLAGS -w) endif() +# Make a source group for Visual Studio +set(CUTTER_SOURCES ${OPTIONS} ${UI_FILES} ${QRC_FILES} ${PLATFORM_RESOURCES} ${SOURCES} ${HEADER_FILES}) +source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${CUTTER_SOURCES}) -add_executable(Cutter ${OPTIONS} ${UI_FILES} ${QRC_FILES} ${PLATFORM_RESOURCES} ${SOURCES} ${HEADER_FILES} ${BINDINGS_SOURCE}) +add_executable(Cutter ${CUTTER_SOURCES} ${BINDINGS_SOURCE}) set_target_properties(Cutter PROPERTIES OUTPUT_NAME cutter RUNTIME_OUTPUT_DIRECTORY .. @@ -452,6 +455,9 @@ set_target_properties(Cutter PROPERTIES CXX_VISIBILITY_PRESET hidden) target_compile_definitions(Cutter PRIVATE CUTTER_SOURCE_BUILD) +# Set Cutter as the startup project in Visual Studio +set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Cutter) + set(CUTTER_INCLUDE_DIRECTORIES core widgets common plugins menus .) foreach(_dir ${CUTTER_INCLUDE_DIRECTORIES}) target_include_directories(Cutter PUBLIC