cmake execute_process() always fails with “No such file or directory” when I call git

后端 未结 1 939
余生分开走
余生分开走 2020-12-15 16:31

On a linux machine, from a cmake project, I\'m trying to call git using execute_process so that I can include info from source control into my app.

I created a littl

相关标签:
1条回答
  • 2020-12-15 16:57

    You have to pass the arguments as a second option like this:

    cmake_minimum_required (VERSION 2.8)
    
    set (git_cmd "git")
    set (git_arg "--version")
    message(STATUS "git cmd: ${git_cmd}")
    execute_process(COMMAND ${git_cmd} ${git_arg}
      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
      RESULT_VARIABLE git_result
      OUTPUT_VARIABLE git_ver)
    
    message(STATUS "git ver[${git_result}]: ${git_ver}")
    
    0 讨论(0)
提交回复
热议问题