diff --git a/CMakeLists.txt b/CMakeLists.txt index 892d420..3e73c2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,11 +54,13 @@ target_link_libraries(${APP_NAME} # 拷贝配置文件(仅在不存在时) add_custom_command(TARGET ${APP_NAME} POST_BUILD - COMMAND sh -c - "test -f \"$/${CONFIG_FILE}\" || \ - (mkdir -p \"$\" && \ - cp \"${CMAKE_SOURCE_DIR}/${CONFIG_EXAMPLE_FILE}\" \ - \"$/${CONFIG_FILE}\" && \ - echo \"config.json created from example\")" + COMMAND /bin/bash -c + "if [ ! -f \"$/${CONFIG_FILE}\" ]; then \ + mkdir -p \"$\" && \ + cp \"${CMAKE_SOURCE_DIR}/${CONFIG_EXAMPLE_FILE}\" \ + \"$/${CONFIG_FILE}\" && \ + echo \"config.json created from example\"; \ + else \ + echo \"config.json exists, keep it\"; \ + fi" ) -