How to have a sub project within project and decide which one to run?
Hey
I'm fairly new to this so I'm not sure if this is cmake question or cLion as cLion does some management of projects. In any case
I have
projectFolder
testFolder
testProjectAFolder
CMakeList.txt
main.cpp
testProjectBFlder
CMakeList.txt
main.cpp
libraryFolder
liba.h
liba.cpp
cmake-build-debug
CMakeList.txt
main.cpp
How can I configure cLIon to allow me to execute either projectFolder main.cpp or testProjectA main.cpp/or projectB main.cpp ?
Edit 1
I'd like to use the projectA with liba.h for example. SO that I can have my main project from main, and test projects using projectAtest ones.
Edit 2
It seemst hat "Set root project" in cmake to not work as it should. I I open new clion project inside the testProjectA and set the root project to projectFolder, in FMakeList.txt I I can do main.cpp to get that testProjectA main, but if I want to access the library file I have to do ../../libraryFolder/liba.cpp etc. So the root folder seem to not be working as it should?
请先登录再写评论。
Hello! You need to add several build targets (for main project and subprojects) in order to be able to run each of them separately. Please read the corresponding web-help article. Also you can use our sample project with Google Tests on github as a reference: in it, for example, the target for main.cpp is specified in the main CMakeLists.txt (add_executable(calendar_run ${SOURCE_FILES})) and the target for test is specified in ../calendars_tests/basic_tests/CMakeLists.txt (add_executable(runBasicCalendarTests ...)).
After the targets are added, the corresponding Run/Debug configurations will be created automatically by CLion. Then you will be able to choose which configuration to run from the list near to the Run button: