I am having a bit of a problem with CMake regarding the organisation of my code within a solution. I have for an habit to organise my namespace by creating a directory for each. For example if I create something like this :
namespace test { namespace blabla { ... } }
I would create a directory test and inside of it a directory blabla, however CMake does not make them appear in my Visual studio or Xcode project.
Is there a trick to get it done ?
Try using the source_group command. After the call to add_executable
add source_group
statements to structure your project as you wish, e.g.:
source_group("test\\blabla" FILES file1.cpp file2.cpp)
For grouping projects in VS you could use this way in CMake (ver after 2.8.3)
//turn on using solution folders
set_property( GLOBAL PROPERTY USE_FOLDERS ON)
//add test projects under 1 folder 'Test-projects'
FOREACH(TEST ${TESTS_LIST})
add_test(NAME ${TEST} COMMAND $<TARGET_FILE:${TEST}>)
set_tests_properties( ${TEST} PROPERTIES TIMEOUT 1)
set_property(TARGET ${TEST} PROPERTY FOLDER "Test-projects")
ENDFOREACH(TEST)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With