-1

I have a top level CMakeLists.txt file which builds a library called Camellia and several executables in subdirectories which link with Camellia. I would like to add a third party library called XDMF as a dependency for Camellia under Camellia/TPL/Xdmf. Luckily, XDMF is already on a CMake build system, but when I use

add_subdirectory(TPL/Xdmf)

and then

add_library(Camellia ${LIB_SOURCES} ${HEADERS})

it builds Camellia in the build/TPL/Xdmf/bin directory rather than build as it does without the add_subdirectory(TPL/Xdmf). Why does adding a subdirectory change the build directory for Camellia, and how do I fix it? Also how do I make sure Camellia is linking with Xdmf once I get that figured out?

Truman Ellis
  • 183
  • 1
  • 5
  • Possible duplicate of [CMake: How to build external projects and include their targets](https://stackoverflow.com/questions/15175318/cmake-how-to-build-external-projects-and-include-their-targets) – Sean Francis N. Ballais Jun 12 '18 at 07:46

1 Answers1

0

I think that ExternalProject_Add(...) is what you want.

Please see CMake: How to build external projects and include their targets which describes a similar issue.

Community
  • 1
  • 1
wojciii
  • 4,253
  • 1
  • 30
  • 39