Running into issues with a CMake POST_BUILD command. Whenever I try to build my CMake project (libFDSequencer) I error out with a pseudo-random error code (anything between 123 and 9009). I have narrowed down the root of the problem to the fact that CMake apparently generates extra batch code surrounding aa add_custom_command() call. I discovered this by building my project using Visual Studio, going to my project properties, and checking out the POST_BUILD commands.
My CMake code to run the custom command looks like this...
# The first line is the original command I want to run (which also work when
# I just copy paste it into the POST_BUILD commands in project properties).
MESSAGE("${CMAKE_CURRENT_SOURCE_DIR}/mexTesting.cmd ${CMAKE_CURRENT_SOURCE_DIR}/src/fd/util/interfaces ${CMAKE_CURRENT_SOURCE_DIR}/mex ${CMAKE_CURRENT_SOURCE_DIR}/build/RelWithDebInfo/ ${CMAKE_CURRENT_SOURCE_DIR}/include " \"-lFDSequencer\ -lFDCommon\ -lSetupAPI\ -lwbemuuid\" " ")
add_custom_command(
TARGET FDSequencer
POST_BUILD
COMMAND "echo Hello World"
)
MESSAGE("\n-----DONE------\n")
The version with CMake generated code in my POST_BUILD project properties secction looks like this...
setlocal
"echo Hello World"
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
However, when I just run echo Hello World like this (how I assumed it was run by add_custom_command()) (edited in the POST_BUILD command field in VS project properties)
"echo Hello World"
or
echo Hello World
It works just fine when I remove the extra code. I'm wondering if there is any way to disable this code generation from CMake or if there is a file that contains this generated code that I can overwrite somehow? Does anyone know why this is generated (besides unnecessary error handling)?