Preserving directory structure
c++, cmake
Solution
I'm assuming that you are creating a Visual Studio project with CMake and want to visualize the source files as they are organized in the file system.
You can do that by using the CMake source group command explicitely for files in each subfolder.
FILE(GLOB TOOLS_FILES
${SRCROOT}/src/tools/*
)
SOURCE_GROUP(tools FILES ${TOOLS_FILES})
... and so on. (Not tested code)
Problem
I've got a project with the following structure : src - tools - modules - core - shader - buffer inc - tools - modules - core - shader - buffer CMake create my project with all .cpp files in a unique folder "Source files". I'm trying to preserve the original structure here is my CMakeLists.txt : ``` # Paths. set( SRCROOT ${PROJECT_SOURCE_DIR}/src/Framework/Graphic ) set( INCROOT ${PROJECT_SOURCE_DIR}/inc/Framework/Graphic ) # Get .hpp and .cpp files. file( GLOB_RECURSE GRAPHIC_FILES ${SRCROOT} ${INCROOT} ) # Packages. find_package(OpenGL REQUIRED) # Create the library. add_library(Graphic ${GRAPHIC_FILES} ) ``` How can I handle that ? Thanks for your time!