CMake not copying in custom target

Hi guys,

So I'm currently using CLion 2018.2.3

I've the following cmake command:

add_custom_target(

    iso

    COMMAND cp ${CMAKE_SOURCE_DIR}/build/bin/${PROJECT_NAME}.bin ${CMAKE_SOURCE_DIR}/build/iso/isodir/boot

    DEPENDS ${PROJECT_NAME}.bin

)

 

add_custom_command(

    COMMAND ${MAKE_RESCUE}

    ARGS -o ${PROJECT_NAME}.iso ${MAKE_SOURCE_FILE}/build/iso

    TARGET iso

}

 

When I build the project I get a ${PROJECT_NAME}.bin in the build/bin directory.

But when I then select to build the iso, it fails to copy the binary into the iso dir as stated.

However, if I add ${PROJECT_NAME}.bin to the end of the copy destination, I get a directory called ${PROJECT_NAME}.bin with the binary inside it in the boot directory. (make sense?) It still fails though

Am I doing something wrong?

0

Hello!

Unfortunately, I can't reproduce the issue on my side. I created a new default "C++ executable" project in CLion 2018.2.4 and added the following lines to the CMakeLists.txt:

add_custom_target(
iso
COMMAND cp ${CMAKE_SOURCE_DIR}/cmake-build-debug/${PROJECT_NAME} ${CMAKE_SOURCE_DIR}
DEPENDS ${PROJECT_NAME}
)

After that I built the "hello_world" target (the hello_world executable was created in the cmake-build-debug subfolder) and built the iso target (the hello_world executable was copied in the project folder).

Could you please check this scenario on your side?

0

请先登录再写评论。