0

I've got two CMake projects and one builds a library needed for the other. I have set up both foo and bar as separate CMake projects and a top-level CMakeLists.txt to enable CLion's Code coverage. The folder structure looks like this:

├───cmake-build-debug  
│   ├───foo  
│   │   └───libfoo.a  
│   └───bar  
├───foo  
│   ├───include  
│   │   └───foo.h  
│   └───src  
│       └───src.cpp  
└───bar  
    ├───dependencies  
    │   └───foo  
    │       ├───include  
    │       └───lib  
    └───src  

How can i move libfoo.a and foo.h into /include and /lib under the bar project respectively?

Luna
  • 29
  • 3
  • Related: [https://stackoverflow.com/questions/40696990/cmake-post-build-event-copy-compiled-libraries](https://stackoverflow.com/questions/40696990/cmake-post-build-event-copy-compiled-libraries) – drescherjm Nov 02 '21 at 00:09
  • For `libfoo.a` you can simply change the (archive) output directory. However reading your description I'm 99% sure you're using CMake wrong. Your toplevel `CMakeLists.txt` should simply include the subdirectories in the correct order (foo before bar); assuming you used `target_include_directories` to specify the correct directory as public include directory for `foo`, simply linking `foo` to `bar` should provide you with the necessary include directories to use `foo.h` with the same include as in the sources of `foo`. – fabian Nov 02 '21 at 18:39

0 Answers0