CMake 执行shell

使用cmake时,可以在cmakelist.txt中如下执行shell

一,方法1

set(LOG "log.txt")
add_custom_command(OUTPUT  ${LOG}
  COMMAND echo "Generating log.txt file..."
  COMMAND echo "welcome"
  COMMAND sh -x shell.sh
  COMMENT  "This is a test"
 )
add_custom_target(T1 ALL DEPENDS ${LOG})

二,方法2

add_custom_command(TARGET T1
  PRE_BUILD 
  COMMAND echo "hello"
  COMMENT "This command will be executed before build target T1"
 )


你可能感兴趣的:(CMake 执行shell)