[CMake] Finding the "Temp" directory code

Michael Wild themiwi at gmail.com
Sat Nov 14 01:25:53 EST 2009


On 14. Nov, 2009, at 24:55 , Michael Jackson wrote:

> Does anyone have any CMake code to find the designated temp folder  
> location for each platform? Was thinking this might be in CMake  
> somewhere but I did not seem to find anything.
>
> Thanks
>

I think on WIN32 its TEMP and TMP and on all UNIX I kno of its TMPDIR.

So in a first, naive attempt I would do:

if(WIN32)
   set(TMPDIR "$ENV{TEMP}")
else()
   set(TMPDIR "$ENV{TMPDIR}")
endif()

if(NOT EXISTS "${TMPDIR}")
   message(FATAL_ERROR "OOOPS, can't determine temporary directory")
endif()

Michael


More information about the CMake mailing list