0

I currently have a directory that looks like this

dir1/
    dirA/
        dirAa/
              CMakeLists.txt <- add_library(x STATIC x.cpp)
    dirB/
        dirBb/
             dirBbb/
                    y is a static library that depends on DirAa (x) Library

How would I link those directories? using the relative paths didn't work when I tried linking y to x. in y.cpp, I've tried using <x.h> and "x.h". When I used the former, depending on which line it's declared, y.h becomes undeclared.

in my dirAa CMake file, I have

add_library(x STATIC x.cpp) install(TARGETS x DESTINATION lib)

and in my dirBb directory, without the junk that I tried putting in:

add_library(y y.cpp) target_link_libraries(y <a library with install destination bin>) I'm trying to link y and x together.

Bill
  • 33
  • 6
  • Possible duplicate of [Cmake include\_directories()](http://stackoverflow.com/questions/19981534/cmake-include-directories) – Evgeniy Oct 16 '16 at 07:30
  • 1
    It is not possible to answer without knowing the content of your cmake file(s). Please provide a [MCVE](http://stackoverflow.com/help/mcve) – rocambille Oct 16 '16 at 09:47
  • @wasthishelpful I've added the cmake snippets – Bill Oct 16 '16 at 16:59

1 Answers1

0

Can't yet comment, hence replying here. I believe this is also the answer you are looking for!

The assumption is that you want to link y to the installed library x, not the original x. If so, you need the full install path of the item you are linking to so: target_link_libraries (y ${CMAKE_INSTALL_PREFIX}/lib/x). The rationale is that you would have defined ${CMAKE_INSTALL_PREFIX} before the install command, hence this should work.

NameRakes
  • 463
  • 6
  • 12