2

I used ExternalProject_Add to add multiple libraries to my project but I cannot set location of output of these libs. ExternalProject_Add has a BINARY_DIR parameter which setting it to desired location does not work as I expect. Also I set INSTALL_DIR but anything changed.

ExternalProject_Add (${name}
        SOURCE_DIR "${${name}_SOURCE_DIR}"
        BINARY_DIR "${${name}_BINARY_DIR}"
        CMAKE_ARGS "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
        "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
        "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
        INSTALL_COMMAND ""
        )

PS:

1) I need to collect all libs in the project/bin/libs folder in order to use other programs (suppose project is the main folder which has CMakeLists.txt contained ExternalProject_Add. Also libs are in the path project/lib/third party/libA through libf and project/lib/MyLibs/lib1 through lib3).

2) Q: What can do if we need to copy libs (like libA.dll and lib1.dll) to multiple destinations (like project/../external_application_A and project/../external_application_B) using project/CMakeLists.txt?

3) I used alexander-huszagh macros from this link (last answer).

Bonje Fir
  • 787
  • 8
  • 25
  • I've only used ExternalProject_Add when dealing with established project that use autotools (automake). If the project doesn't have any project files, consider create a CMakelist.txt for it, and adding as subdirectory or installed package. – jerrylogansquare Aug 24 '17 at 17:55
  • If it were just one file per external project that you needed to move, something like `INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ` should work. However, this does not seem to work with multiple files. You could also add an argument to `CMAKE_ARGS`, e.g. `"-DCMAKE_INSTALL_PREFIX="` and then set `INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install`. This would put all your external libraries into the same folder, if they support that option. – Raul Laasner Aug 24 '17 at 18:10
  • @jerrylogansquare As you can see in the mentioned link `ExternalProject_Add` is useful to add external libraries which it build just once(if it does not exist compiled and at rebuild time these libs do not recompile). It is very useful to reduce compile time of projects with multiple external libs. – Bonje Fir Aug 26 '17 at 05:47

0 Answers0