Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organise my files using CMake?

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 ?

like image 682
lollancf37 Avatar asked Aug 17 '11 10:08

lollancf37


2 Answers

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)
like image 138
sakra Avatar answered Oct 21 '22 20:10

sakra


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)
like image 34
Andrew Avatar answered Oct 21 '22 18:10

Andrew