2

I'm writing makefile, that works with cmake. makefile just creates the build directory and start cmake in it, if build directory is not created yet, or redirects targets to makefile created by cmake, if it already exists. I used mkdir -p to create a build directory, but it is not cross platform.

Is there any cross platform variant for mkdir -p? May be cmake provides alternative command, like it does autoconf?

Роман Коптев
  • 1,555
  • 1
  • 13
  • 35

1 Answers1

5

You can use cmake -E make_directory (see documentation). If the parent directories are not existing, it does create all directories up the given one.

If you use it inside a CMake script itself, e.g. as pre-build step: ${CMAKE_COMMAND} -E make_directory

References

Community
  • 1
  • 1
Florian
  • 39,996
  • 9
  • 133
  • 149