CMake temporary directory

A temporary directory for build system use should be created under the build directory. Some CIs and systems do not define the environment variables “TMPDIR” or “TEMP” for temporary directory. Virus scanners can false detect activity in the system temporary directory as malicious.

Create a temporary directory in CMake using random string like:

if(NOT DEFINED tmpdir)
  string(RANDOM LENGTH 24 _s)
  set(tmpdir ${CMAKE_CURRENT_BINARY_DIR}/${_s} CACHE PATH "temporary directory")
endif()