CMake: How to execute a command before make install?

B Faley

This is the way I install the config files:

file(GLOB ConfigFiles  ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.xml
                            ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.xsd
                            ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.conf)

install(FILES ${ConfigFiles} DESTINATION ${INSTDIR})

But I need to convert one of the xml files before installing it. There is an executable that can do this job for me:

./Convertor a.xml a-converted.xml

How can I automatically convert the xml file before installing it? It should be a custom command or target that installing depends on it, I just don't know how to make the install command depend on it though. Any advice would be appreciated!

ComicSansMS

Take a look at the SCRIPT version of install:

The SCRIPT and CODE signature:

install([[SCRIPT <file>] [CODE <code>]] [...])

The SCRIPT form will invoke the given CMake script files during installation. If the script file name is a relative path it will be interpreted with respect to the current source directory. The CODE form will invoke the given CMake code during installation. Code is specified as a single argument inside a double-quoted string.

For example:

install(CODE "execute_process(\"./Convertor a.xml a-converted.xml\")")
install(FILES a-converted.xml DESTINATION ${INSTDIR})

Be sure to checkout the entry for execute_process in the manual. Also be aware that macro expansion inside the CODE parameter can be a bit tricky to get right. Check the generated cmake_install.cmake in your build directory where the generated code will be placed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to execute shell command before compile task?

From Dev

How to execute shell command before compile task?

From Dev

How to execute command before user login on linux

From Dev

How to execute 'clear' bash command before any other command is executed?

From Dev

Execute a command before shutdown

From Dev

cmake execute_process COMMAND

From Dev

How to make a command execute once a certain command terminates?

From Dev

How to use CMake macro as INSTALL_COMMAND in ExternalProject_Add?

From Dev

How do I install the latest version of cmake from the command line?

From Dev

How do I install the latest version of cmake from the command line?

From Dev

How I would make the php vaild code execute before action?

From Dev

Execute command before shutdown/reboot

From Dev

Execute command before shutdown/reboot

From Dev

ssh: execute a command before login

From Dev

Regular expression in CMake install command

From Dev

How to execute custom command or script in Install section of systemd service file?

From Dev

How to make 'python' program command execute Python 3?

From Dev

How to make 'python' program command execute Python 3?

From Dev

How To Make A Child Execute Command Button in C#

From Dev

How to make shell to execute command file without making a new process?

From Dev

How to make Python execute a command when a key is detected to be pressed

From Dev

How to make sure Elastic Search is healthy before sending a command?

From Dev

How to make Javascript execute a code every x seconds, but make it wait before a function was fully executed?

From Dev

Using cmake variable in execute_process command in cmake file

From Dev

How to install vte-ng from the source: make command fails

From Dev

How to compile and use make command to install this certain program/tool?

From Dev

execute command 10 seconds before alarm

From Dev

multiprocessing - execute external command and wait before proceeding

From Dev

Bash : Execute command before redirection as standard input

Related Related

  1. 1

    How to execute shell command before compile task?

  2. 2

    How to execute shell command before compile task?

  3. 3

    How to execute command before user login on linux

  4. 4

    How to execute 'clear' bash command before any other command is executed?

  5. 5

    Execute a command before shutdown

  6. 6

    cmake execute_process COMMAND

  7. 7

    How to make a command execute once a certain command terminates?

  8. 8

    How to use CMake macro as INSTALL_COMMAND in ExternalProject_Add?

  9. 9

    How do I install the latest version of cmake from the command line?

  10. 10

    How do I install the latest version of cmake from the command line?

  11. 11

    How I would make the php vaild code execute before action?

  12. 12

    Execute command before shutdown/reboot

  13. 13

    Execute command before shutdown/reboot

  14. 14

    ssh: execute a command before login

  15. 15

    Regular expression in CMake install command

  16. 16

    How to execute custom command or script in Install section of systemd service file?

  17. 17

    How to make 'python' program command execute Python 3?

  18. 18

    How to make 'python' program command execute Python 3?

  19. 19

    How To Make A Child Execute Command Button in C#

  20. 20

    How to make shell to execute command file without making a new process?

  21. 21

    How to make Python execute a command when a key is detected to be pressed

  22. 22

    How to make sure Elastic Search is healthy before sending a command?

  23. 23

    How to make Javascript execute a code every x seconds, but make it wait before a function was fully executed?

  24. 24

    Using cmake variable in execute_process command in cmake file

  25. 25

    How to install vte-ng from the source: make command fails

  26. 26

    How to compile and use make command to install this certain program/tool?

  27. 27

    execute command 10 seconds before alarm

  28. 28

    multiprocessing - execute external command and wait before proceeding

  29. 29

    Bash : Execute command before redirection as standard input

HotTag

Archive