[CMake] Cmake issue regarding conversion of existing Visual Studio .targets files to cmake

David Cole dlrdave at aol.com
Tue Aug 12 06:43:32 EDT 2014


From
http://www.cmake.org/cmake/help/v3.0/command/add_custom_command.html :

"If COMMAND specifies an executable target (created by ADD_EXECUTABLE)
it will automatically be replaced by the location of the executable
created at build time. Additionally a target-level dependency will be
added so that the executable target will be built before any target
using this custom command. However this does NOT add a file-level
dependency that would cause the custom command to re-run whenever the
executable is recompiled."

So... if TestVersion.exe is created as a result of an
"add_executable(TestVersion ..." call, then you should be able to use

    add_custom_command(
        TARGET ${TARGETNAME}
        POST_BUILD
        COMMAND TestVersion \"$(VersionPath)\"
        COMMENT "Check if $(VersionPath) has version information...")

If you must pass the full path to TestVersion as an argument to a batch
file, you should be able to use

    $<TARGET_FILE:TestVersion>

(again, assuming TestVersion is the name of your add_executable target)


By the way, the error message "'TestVer\TestVersion.exe' is not
recognized ..." is probably happening because the working directory is
not set correctly relative to the name "TestVer\TestVersion.exe" - a
simple pushd/popd combination to the correct directory in the batch
file may solve this.


HTH,
David




More information about the CMake mailing list