使用execute_process 下载依赖包,配置环境等,各种操作。
参数必须要传,不用也要传空
set(getdep1 ${CMAKE_SOURCE_DIR}/clone.sh)
execute_process(
COMMAND ${getdep1} ""
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/dep
RESULT_VARIABLE result
OUTPUT_VARIABLE output
)
if(result EQUAL 0)
message(STATUS "task done")
else()
message(FATAL_ERROR "task Error! " "return code: " ${result})
endif()
set(MAKE_CMD "${CMAKE_CURRENT_SOURCE_DIR}/makeHeaders.sh")
MESSAGE("COMMAND: ${MAKE_CMD} ${CMAKE_CURRENT_SOURCE_DIR} ${INC_DIR}")
execute_process(COMMAND ${MAKE_CMD} ${CMAKE_CURRENT_SOURCE_DIR} ${INC_DIR}
RESULT_VARIABLE CMD_ERROR
OUTPUT_FILE CMD_OUTPUT)
MESSAGE( STATUS "CMD_ERROR:" ${CMD_ERROR})
MESSAGE( STATUS "CMD_OUTPUT:" ${CMD_OUTPUT})
https://stackoverflow.com/questions/43684051/cmake-execute-process-command