Here are some steps you can take to avoid unnecessary recompilation of Protobuf-generated files with CMake:
Set up dependencies: Make sure that your protobuf-generated files depend on the .proto files and any other files that are inputs to the code generation process. This can be achieved by using CMake's add_dependencies function.
Preserve file timestamps: CMake can modify the file timestamps of the generated files during the build process, which can lead to unnecessary recompilation. To avoid this, you can set the FILENAMECOMPUTE parameter of the configurefile function to "ALL".
Use targetsources: Instead of adding the generated files directly to a target using the addexecutable or addlibrary functions, use the targetsources function. This function allows you to specify a list of source files that belong to a target, without actually compiling them.
Use out-of-source builds: When building your project, try to use an out-of-source build directory. This will ensure that the generated files are placed in a separate directory from the source files, which can help avoid unnecessary recompilation.
Use a custom command: If none of the above steps work, you can use a custom command to generate the protobuf-generated files. This command can be triggered manually or as part of the build process using the addcustomcommand function.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-13 03:52:24 +0000
Seen: 13 times
Last updated: Jun 13 '23
How can a function pointer be transferred between different files in CUDA?
How can I print all but the first 1000 Lines from a File in Bash?
How can I transfer .avi video files to Unity?
Is it possible for Github Copilot to consider the context of a project that contains multiple files?
How to access HTML files stored on Google Drive?
Can migration files be executed in knex upon making an API request?
In what manner does react-scripts v5 manage the lasting caching created through webpack?