3 #-----------------------------------------------------------------------------
4 # Test how compiler handle the case of a malloc(0). If it returns 0
5 # then we are doomed (jasper does not support this case)
6 IF("NULL_ON_MALLOC_0" MATCHES "^NULL_ON_MALLOC_0$")
8 FILE(WRITE ${GDCMJASPER_BINARY_DIR}/jasperNULLmalloc.c
9 "${POUND}include <stdlib.h>\n"
10 "int main() { return (int)malloc(0); }")
11 MESSAGE(STATUS "Checking if compiler return NULL on malloc(0)")
12 TRY_RUN(RESULT_NULL_ON_MALLOC_0 COMPILE_NULL_ON_MALLOC_0
13 "${GDCMJASPER_BINARY_DIR}"
14 "${GDCMJASPER_BINARY_DIR}/jasperNULLmalloc.c"
15 OUTPUT_VARIABLE OUTPUT)
16 IF(RESULT_NULL_ON_MALLOC_0 EQUAL 0)
17 MESSAGE(STATUS "Checking if compiler return NULL on malloc(0) -- yes")
18 SET(NULL_ON_MALLOC_0 1 CACHE INTERNAL "Check if compiler returns NULL on malloc(0)")
19 WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log
20 "Determining how compiler implement malloc(0)"
21 "passed with the following output:\n"
23 ELSE(RESULT_NULL_ON_MALLOC_0 EQUAL 0)
24 MESSAGE(STATUS "Checking if compiler returns NULL on malloc(0) -- no")
25 SET(NULL_ON_MALLOC_0 0 CACHE INTERNAL "Check if compiler returns NULL on malloc(0)")
26 WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
27 "Determining how compiler implement malloc(0)"
28 "failed with the following output:\n"
30 ENDIF(RESULT_NULL_ON_MALLOC_0 EQUAL 0)
31 ENDIF("NULL_ON_MALLOC_0" MATCHES "^NULL_ON_MALLOC_0$")
33 #OPTION(HAVE_LIBJPEG "Do you have ijg" OFF)
35 SET(HAVE_LIBJPEG ON CACHE BOOL "Do you have ijg" FORCE)
37 SET(HAVE_LIBJPEG OFF CACHE BOOL "Do you have ijg" FORCE)
38 ENDIF(GDCM_SOURCE_DIR)
40 MARK_AS_ADVANCED(HAVE_LIBJPEG)