Copy target file to another location in a post build step in CMake

前端 未结 3 889
攒了一身酷
攒了一身酷 2020-12-04 17:11

I have a dynamic library that gets a different name depending on configuration, specified in the CMake scripts by:

set_target_properties(${name} PROPERTIES O         


        
3条回答
  •  没有蜡笔的小新
    2020-12-04 17:21

    Use generator expressions in the POST_BUILD command instead of manually computing the output path. These are configuration aware. Example:

    add_custom_command(TARGET mylibrary POST_BUILD 
      COMMAND "${CMAKE_COMMAND}" -E copy 
         "$"
         "my_target_path/$/$" 
      COMMENT "Copying to output directory")
    

提交回复
热议问题