]> Creatis software - gdcm.git/blob - src/gdcmjasper/CMakeLists.txt
4ab3071a3470f204a520ac754b29a8642a017156
[gdcm.git] / src / gdcmjasper / CMakeLists.txt
1 PROJECT(GDCMJASPER C)
2
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$")
7   STRING(ASCII 35 POUND)
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"
22       "${OUTPUT}\n" APPEND)
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"
29       "${OUTPUT}\n" APPEND)
30   ENDIF(RESULT_NULL_ON_MALLOC_0 EQUAL 0)
31 ENDIF("NULL_ON_MALLOC_0" MATCHES "^NULL_ON_MALLOC_0$")
32
33 #OPTION(HAVE_LIBJPEG "Do you have ijg" OFF)
34 IF(GDCM_SOURCE_DIR)
35   SET(HAVE_LIBJPEG ON CACHE BOOL "Do you have ijg" FORCE)
36 ELSE(GDCM_SOURCE_DIR)
37   SET(HAVE_LIBJPEG OFF CACHE BOOL "Do you have ijg" FORCE)
38 ENDIF(GDCM_SOURCE_DIR)
39
40 MARK_AS_ADVANCED(HAVE_LIBJPEG)
41
42 SUBDIRS(src)