当前位置: 首页 > 工具软件 > Prebuild > 使用案例 >

cmake中prebuild/postbuild命令

翟京
2023-12-01

add_custom_command(TARGET target
                     PRE_BUILD | PRE_LINK| POST_BUILD
                     COMMAND command1[ARGS] [args1...]
                     [COMMAND command2[ARGS] [args2...] ...]
                     [WORKING_DIRECTORYdir]
                     [COMMENT comment][VERBATIM])

 

  

add_custom_command(OUTPUT  ${TEST_FILE}
  COMMAND echo "Generating log.txt file..."
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_FILE} ${TEST_FILE}
  COMMENT  "This is a test"
 )
 

上面是copy用法,其他可以用的命令如下

Usage: C:\Program Files\CMake\bin\cmake.exe -E <command> [arguments...]

  Available commands:

    capabilities              - Report capabilities built into cmake in JSON format

    chdir dir cmd [args...]   - run command in a given directory

    compare_files file1 file2 - check if file1 is same as file2

    copy <file>... destination  - copy files to destination (either file or directory)

    copy_directory <dir>... destination   - copy content of <dir>... directories to 'destination' directory

    copy_if_different <file>... destination  - copy files if it has changed

    echo [<string>...]        - displays arguments as text

    echo_append [<string>...] - displays arguments as text but no new line

    env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...

                              - run command in a modified environment

    environment               - display the current environment

    make_directory <dir>...   - create parent and <dir> directories

    md5sum <file>...          - create MD5 checksum of files

    sha1sum <file>...         - create SHA1 checksum of files

    sha224sum <file>...       - create SHA224 checksum of files

    sha256sum <file>...       - create SHA256 checksum of files

    sha384sum <file>...       - create SHA384 checksum of files

    sha512sum <file>...       - create SHA512 checksum of files

    remove [-f] <file>...     - remove the file(s), use -f to force it

    remove_directory dir      - remove a directory and its contents

    rename oldname newname    - rename a file or directory (on one volume)

    server                    - start cmake in server mode

    sleep <number>...         - sleep for given number of seconds

    tar [cxt][vf][zjJ] file.tar [file/dir1 file/dir2 ...]

                              - create or extract a tar or zip archive

    time command [args...]    - run command and display elapsed time

    touch file                - touch a file.

    touch_nocreate file       - touch a file but do not create it.

  Available on Windows only:

    delete_regv key           - delete registry value

    env_vs8_wince sdkname     - displays a batch file which sets the environment for the provided Windows CE SDK installed in VS2005

    env_vs9_wince sdkname     - displays a batch file which sets the environment for the provided Windows CE SDK installed in VS2008

    write_regv key value      - write registry value

 

 类似资料: