I use cmake to create my C ++ project. Suppose I have the following directories in my source folder
Source |_Dir1 | |_Class.cpp | |_Class.hpp | |_Dir2 |_Main.cpp
Dir1 has a class with a header and implementation files (Class.cpp and Class.hpp).
Dir2 has a main application that uses a class in Dir1
What is a good way to tell CMakeLists in Dir2 to create an executable file with the Dir1 / Class.cpp file?
EDIT: To be more specific, I want to determine that the source file for Class.cpp should be used in Dir1 CMakeLists.txt, and not in Dir2. Doing this on the other hand seems wrong to me, and it is difficult to use, so if there is a reason why they force me, some clarifications on the topic will be pleasant.
What I am doing now hardcodes the location of the Class.cpp file in Dir2 / CMakeLists.txt, but it just doesn't scale when I have a group of classes interacting together.
source share