remove the commit message of peaceiris/actions-gh-pages
[liba.git] / cmake / TemporaryDirectory.cmake
blob3b1d94a4e9475c9795236ac099b9f956fe5074c5
1 function(TEMPORARY_DIRECTORY)
2   if(NOT DEFINED TEMPORARY_DIRECTORY)
3     if(DEFINED ENV{TMPDIR})
4       set(TEMPORARY_DIRECTORY $ENV{TMPDIR})
5     elseif(DEFINED ENV{TEMP})
6       set(TEMPORARY_DIRECTORY $ENV{TEMP})
7     elseif(DEFINED ENV{TMP})
8       set(TEMPORARY_DIRECTORY $ENV{TMP})
9     endif()
10   endif()
11   if(NOT DEFINED TEMPORARY_DIRECTORY)
12     find_program(MKTEMP NAMES mktemp)
13     if(EXISTS "${MKTEMP}")
14       execute_process(COMMAND ${MKTEMP} -d OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE dir RESULT_VARIABLE result)
15       if(result EQUAL 0)
16         get_filename_component(TEMPORARY_DIRECTORY "${dir}" DIRECTORY)
17       endif()
18     endif()
19   endif()
20   if(DEFINED TEMPORARY_DIRECTORY)
21     set(TEMPORARY_DIRECTORY ${TEMPORARY_DIRECTORY} CACHE PATH "Path to system temporary directory.")
22   endif()
23 endfunction()
24 if(NOT DEFINED TEMPORARY_DIRECTORY)
25   TEMPORARY_DIRECTORY()
26 endif()