I have a complex C++ Project folder which contains two folders.
- a C++ src folder with multiple sub-folders and CmakeList.txt file. The src folder contains main.cpp file.
- a C++ build standard external folder ExtLib containing multipe subfolders and a build.sh script for its compilation and CmakeList.txt file. The .cpp files are linked (includes header(.h) files) to this ExtLib folder.
The Project folder contains a main build.sh file which compiles the project and creates a build folder including debug and release configurations. It also contains a CmakeList.txt file which I suppose gets executed when build.sh file is executed. The task that I need to perform on this project is to create a new tests folder and add a file (runtests.cpp) which performs unit-testing (using catch unit-test) on the code written in the src folder .cpp files.
Problem I face:
The first problem is when I am creating a source test file in my tests folder, and trying to include header files from src folder, the compiler throws a fatal error that no such (.h) files found.(from src folder). Also sometimes the problem occurs in the src folder files, as they are unable to locate ExtLib folder files.
The second question is, if by some how I am able to include files from other src or ExtLib folders successfully, how can I be able to run the test source file runtests.cpp for executing my test cases?
The project heirarchy is shown below:
TestProject
│ build.sh
│ CMakeList.txt
└───ExtLib
│ │ buildscript.sh
│ │ CMakeList.txt
│ └───subfolder1
│ └───subfolder2(containing sub-folders)
└───src
│ │ main.cpp
│ │ CMakeList.txt
│ └───folder1
│ └───folder2(containing sub-folders)
└───tests
│ runtests.cpp
│ catch.hpp
Do I need to include a CMakelist.txt file for my tests folder too? How to make it if I have to? I am very new to this field. Hope you guys can help. Thanks Rg