I'm setting up cmake for my project and I've set up a testing project for it. When it generates my visual studio 2010 project I want to make it as the project I've had earlier.
- it creates a ALL_BUILD and ZERO_CHECK project that I dont want.
- it puts the .h files into the External Dependencies folder. I want a Include Files folder where all the .h files goes.
- I also want to group some files under different filters. Like in my core lib I want to group all files related to Maths in a folder and all files related to Event management in another.
- On the filesystem it puts the project files inside /Lib/src. Probably cause I have it organized that in the code folder, but I dont want that for the project files.
- I want to set up different configuration so I have DebugOpenGL, DebugDirectX, ReleaseOpenGL, ReleaseDirectX and then setting a flag USE_OPENGL or USE_DIRECTX for the two types of configurations.
How can I exclude some files when I build on windows and others when I build on linux? Like I have WindowWin.cpp and WindowLinux.cpp.
I've tried what you sugested but cant get it working:
#LibProject/src
FILE(GLOB test0_headers $CMakeTest_SOURCE_DIR/LibProject/inc/test.h)
source_group(include0 FILES ${test0_headers})
FILE(GLOB test0_source ${CMakeTest_SOURCE_DIR}/LibProject/src/test.cpp)
source_group(source0 FILES ${test0_source})
FILE(GLOB test1_headers $CMakeTest_SOURCE_DIR/LibProject/inc/test1.h)
source_group(include1 FILES ${test1_headers})
FILE(GLOB test1_source ${CMakeTest_SOURCE_DIR}/LibProject/src/test1.cpp)
source_group(source1 FILES ${test1_source})
include_directories(${test0_headers} ${test1_headers})
add_library(LibProject ${test0_headers} ${test1_headers} ${test0_source} ${test
1_source})
I kind of got it working now.. only that I want sub folders for headers and source files inside the source group.
set(test_source0 ${CMakeTest_SOURCE_DIR}/LibProject/inc/test.h ${CMakeTest_SOURCE_DIR}/LibProject/src/test.cpp)
source_group(TEST FILES ${test_source0})
set(test_source1 ${CMakeTest_SOURCE_DIR}/LibProject/inc/test2.h ${CMakeTest_SOURCE_DIR}/LibProject/src/test2.cpp)
source_group(TEST2 FILES ${test_source1})
include_directories(${CMakeTest_SOURCE_DIR}/LibProject/inc)
add_library(LibProject ${test_source0} ${test_source1})
Heres my solution :)
set(test_header
${CMakeTest_SOURCE_DIR}/LibProject/inc/test.h)
set(test_source
${CMakeTest_SOURCE_DIR}/LibProject/src/test.cpp)
source_group(TEST\\Headers FILES ${test_header})
source_group(TEST\\Source FILES ${test_source})
set(test2_header
${CMakeTest_SOURCE_DIR}/LibProject/inc/test2.h)
set(test2_source
${CMakeTest_SOURCE_DIR}/LibProject/src/test2.cpp)
source_group(TEST2\\Headers FILES ${test2_header})
source_group(TEST2\\Source FILES ${test2_source})
include_directories(${CMakeTest_SOURCE_DIR}/LibProject/inc)
add_library(LibProject
${test_header}
${test_source}
${test2_header}
${test2_source})