A
A
Alexander Buliterov2018-10-28 23:18:24
CMake
Alexander Buliterov, 2018-10-28 23:18:24

How can Cmake describe non-source dependency and post-copy?

There is a configuration file (not the source) of a part of the project, when it is changed, it is necessary to run a Python script that regenerates the sources.
How to describe? But so that only when changing the configuration file.
How to run python script after linking?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
4
4rtzel, 2018-10-29
@4rtzel

You will most likely be helped by add_custom_command with the OUTPUT and DEPENDS options.
Example:

add_executable(
    my_target
    path/to/generated/file_1
    path/to/generated/file_2
)

add_custom_command(
    OUTPUT # Файлы, которые генерируем
        path/to/generated/file_1
        path/to/generated/file_2
    COMMAND # Команда генерации
        python generate.py
    DEPENDS # Файл конфига (CMake должен сам отслеживать изменения этого файла и вызывать COMMAND если это необходимо)
        path/to/config.cfg
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question