<div dir="ltr">Hi,<div><br></div><div>I am trying to use add_custom_command in my CMakeLists.txt, but it is not working properly.</div><div><br></div><div>Here is the code:</div><div>@@@@</div><div><div>CMAKE_MINIMUM_REQUIRED(VERSION 2.8)</div>
<div><br></div><div>find_program(PYTHON_EXECUTABLE python)</div><div>find_program(CMAKE_EXECUTABLE cmake)</div><div><br></div><div>set(CMAKE_INSTALL_PREFIX "/home/Documents/testCMakeBuild")</div><div><br></div><div>
SET(Output_file1 "cmakeVersion.txt")</div><div>SET(Output_file2 "pythonVersion.txt")</div><div><br></div><div>ADD_CUSTOM_COMMAND(</div><div> OUTPUT ${CMAKE_INSTALL_PREFIX}/${Output_file1}</div><div>
COMMAND ${CMAKE_EXECUTABLE} --version > ${CMAKE_INSTALL_PREFIX}/${Output_file1})</div><div> </div><div>ADD_CUSTOM_TARGET(cmakeInternal ALL DEPENDS ${CMAKE_INSTALL_PREFIX}/${Output_file1})</div><div><br></div><div><br>
</div><div>ADD_CUSTOM_COMMAND(</div><div> OUTPUT ${CMAKE_INSTALL_PREFIX}/${Output_file2}</div><div> COMMAND ${PYTHON_EXECUTABLE} --version > ${CMAKE_INSTALL_PREFIX}/${Output_file2})</div><div> </div><div>ADD_CUSTOM_TARGET(pythonInternal ALL DEPENDS ${CMAKE_INSTALL_PREFIX}/${Output_file2})</div>
</div><div><br></div><div>@@@@@@@@@</div><div><br></div><div>In case of cmakeVersion.txt, o/p of cmake --version is written to cmakeVersion.txt and nothing is printed to console, but in case of python just o/p of python --version is written to console. pythonVersion.txt is created but file is empty.</div>
<div><br></div><div>Please share your views.</div><div><br></div><div>Appreciate your help in this regard.</div><div><br></div><div>Thanks,</div><div>Pandu.</div></div>