2017-08-26 70 views
0

我想將somefile.bmp複製到我的「$ {PROJECT_BINARY_DIR}/bin/data」文件夾中,但它不起作用。但是,如果我將路徑更改爲「$ {PROJECT_BINARY_DIR}/bin」,它工作正常。我怎樣才能解決這個問題?使用cmake將文件複製到指定的目錄

add_custom_command(TARGET Invaders POST_BUILD 
      COMMAND ${CMAKE_COMMAND} -E copy_if_different 
      "${PROJECT_SOURCE_DIR}/Game/data/somefile.bmp"    
      "${PROJECT_BINARY_DIR}/bin/data") 

回答

1

該目錄不存在,我猜。您需要在複製之前創建它:

add_custom_command(TARGET Invaders POST_BUILD 
      COMMAND ${CMAKE_COMMAND} -E make_directory 
      "${PROJECT_SOURCE_DIR}/Game/data" 
      COMMAND ${CMAKE_COMMAND} -E copy_if_different 
      "${PROJECT_SOURCE_DIR}/Game/data/somefile.bmp"    
      "${PROJECT_BINARY_DIR}/bin/data") 
+0

傻我,你是絕對正確的。 – 0xBADF00

相關問題