In CMake, I want to create a directory if it doesn't already exist. How can I do this?
相关问题
- 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 create a directory at install time,
These will both run at configure time:
To create during the build, use a custom target:
In addition to Chin Huang's reply, you can also do this at build time with
add_custom_command
:You can also change the moment, when your directory is created with PRE_BUILD | PRE_LINK | POST_BUILD parameters.
When do you want to create the directory?
At build system generation
To create a directory when CMake generates the build system,
At build time
In the
add_custom_command()
command (which adds a custom build rule to the generated build system), and theadd_custom_target()
command (which adds a target with no output so it will always be built), you specify the commands to execute at build time. Create a directory by executing the command${CMAKE_COMMAND} -E make_directory
. For example:At install time
To create a directory at install time,