Using CMake add_custom_command() to perform POST_BUILD action
Posted: Sat Jul 20, 2019 3:08 am
I want to be able to copy the main binary (and eventually the other binaries) to another folder post build.
Note: I don't want to generate the output in this other folder. Taking a copy is a necessarily separate and discrete step.
I tried using CMake "add_custom_command"
In both the root CMakeLists.txt (after project) and in the mina/CmakeLists.txt (after register_component), and while it builds, it doesn't like target 'esp32' so never copies. Output is:
Is this the correct way to execute a post build action with esp32 CMake?
And if so,
- What target am I looking for in order to make it work ?
- In which CMakeLists.txt should I add the command?
William
Note: I don't want to generate the output in this other folder. Taking a copy is a necessarily separate and discrete step.
I tried using CMake "add_custom_command"
Code: Select all
add_custom_command(
TARGET esp32
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:esp32> "E:/SomeFolder"
COMMENT "Copying esp32 binary output to SomeFolder"
)
Code: Select all
Loading defaults file E:/Source/esp32/wave_touchpad/sdkconfig.defaults...
-- IDF_VER: v3.3-beta1-849-g630ffde6b
-- Project version: 1
-- Could NOT find Perl (missing: PERL_EXECUTABLE)
-- Adding linker script E:/Source/esp32/wave_touchpad/build/esp-idf/esp32/esp32_out.ld
-- Adding linker script E:/Dev/Espressif/esp-idf/components/esp32/ld/esp32.rom.ld
-- Adding linker script E:/Dev/Espressif/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Adding linker script E:/Dev/Espressif/esp-idf/components/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script E:/Dev/Espressif/esp-idf/components/esp32/ld/esp32.rom.spiram_incompatible_fns.ld
-- Building empty aws_iot component due to configuration
-- Component libraries:
CMake Error at CMakeLists.txt:31 (add_custom_command):
No TARGET 'esp32' has been created in this directory.
And if so,
- What target am I looking for in order to make it work ?
- In which CMakeLists.txt should I add the command?
William