I want to trigger the building process and use the header file & shared lib (.so file) from different project to another single project.
Here, my parents projects are proj_1 & proj_2. And the project where I am intended to use the information is new_proj.
Structure looks like as follows:
infos/
|-- New_Stuff
| `-- new_proj
| |-- CMakeLists.txt
| |-- include
| | `-- foo_bar.h
| `-- src
| |-- foo_bar.cpp
| `-- main.cpp
`-- Old_Stuff
|-- proj_1
| |-- CMakeLists.txt
| |-- include
| | `-- foo.h
| `-- src
| `-- foo.cpp
`-- proj_2
|-- CMakeLists.txt
|-- include
| `-- bar.h
`-- src
`-- bar.cpp
Minimal Example of the header and Source file. Pseudo code
proj_1
foo.h
#include <iostream>
using namespace std;
void print_foo();
foo.cpp
#include "foo.h"
#include <iostream>
using namespace std;
void print_foo()
{
cout << "foo is here" endl;
}
proj_2
bar.h
#include <iostream>
using namespace std;
void print_bar();
bar.cpp
#include "bar.h"
#include <iostream>
using namespace std;
void print_bar()
{
cout << "bar is here" endl;
}
new_proj
foo_bar.h
#include "foo.h"
#include "bar.h"
#include <iostream>
using namespace std;
void print_message();
foo_bar.cpp
#include "foo_bar.h"
#include <iostream>
using namespace std;
void print_message()
{
cout << "Combining project" endl;
}
main.cpp
#include "foo_bar.h"
int main()
{
void print_message();
void print_foo();
void print_bar();
return 0;
}
preferred output
Combining project
foo is here
bar is here
I have no idea how can I write the CMakeLists.txt file of new_proj.
Some facts about the parents projects (examples are given on behalf of proj_1)
- Header files are always resides in
/proj_1/include - Executable resides in
/proj_1/binand shared lib in/proj_1/lib
My approach
- I have gone through 1 2 but didn't get a clear idea.
proj_1&proj_2are already exist and they will in the same location. Besides, I can clone them too if needed.
Want idea how to organize the CMakeLists.txt for new_proj.