1

We are using a vendor code as third party project in our source code. The Vendor code uses Makefile, for which we wrote new CMake add_custom_target for vendor source code.

To copy library from vendor specific build/lib dir to Our CMAKE binary/library dir, I coded Step to copy all the libs as

ExternalProject_Add_Step(CopyStep)

However I see that whenever I build, CopyStep is executed all the time. Is there any way to control the CopyStep to exec only if there is change in library (something similar as Make, whenever there is not code change, source code is not rebuilt).

Let me know if there is any other way I could do copy etc.

ekchom
  • 113
  • 13

1 Answers1

0

For make an ExternalProject's step to be re-executed only when some file(s) are changed, add DEPENDS option to it:

ExternalProject_Add_Step(extLibrary CopyStep
    COMMAND cp <BINARY_DIR>/lib/libext.a <...>
    DEPENDS <BINARY_DIR>/lib/libext.a
    )

Alternatively (e.g. if you don't want to list all files you depends on), you may make the step to be a part of the build step. For that, modify ExternalProject_Add by adding appropriate command:

ExternalProject_Add(extLibrary
    ...
    BUILD_COMMAND make # Need to explicitely specify build command.
    COMMAND cp -r <BINARY_DIR>/lib <...> # Additional action for the build step
    )
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153