I'm using an external library which provides a CMake function for automatic code generation, to be used in my CMakeLists. The problem is that whenever I modify a CMakeLists then the function is run again, triggering the recompilation of the newly generated but unchanged sources. I'd need something like add_custom_command with the possibility to specify the CMake function as COMMAND instead of an executable, so that the function is run only if the automatically generated files are not already present. Is this feasible? If not, does it exist another way to obtain the same result? Thanks.
相关问题
- Avoid cmake to add the flags -search_paths_first a
- CMakeList file to generate LLVM bitcode file from
- How to fix NDK build error for HelloCardboard samp
- Linking against GLEW with CMake
- Linking libavcodec in Cmake, find_library won'
相关文章
- Target requires the language dialect “CXX17” (with
- How do I tell cmake not to create a console window
- Do something for all targets
- CMake: Replace compile flags of an INTERFACE targe
- Generate Web Assembly from CMake Project with a Sp
- Integrate ITK (Insight Toolkit) into own project
- Is there a way to disallow “experimental” C++17 in
- CMake properties and expanding generator expressio
To prevent that function to run, just wrap it into
if
:Easy!
Update: To run it when config file has changed just use little more complicated condition:
and use
add_dependencies
command to make sure your binary will be rebuild in case of config file modifications:Take a look to this SO post.
You can call your function in a separate CMake script, call this script with
add_custom_target
andcmake -P
then add a dependency to your binary :