X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2Fgdcmjasper%2FCMakeLists.txt;h=4ab3071a3470f204a520ac754b29a8642a017156;hb=ae64a0ce6b0e05103e13d8b2eedc87b7fcf02380;hp=ba52b3c660f508754c2c4dc8cae39e2671f7de3b;hpb=899e8669c13651e11b308af90a5454f72f5c3d5c;p=gdcm.git diff --git a/src/gdcmjasper/CMakeLists.txt b/src/gdcmjasper/CMakeLists.txt index ba52b3c6..4ab3071a 100644 --- a/src/gdcmjasper/CMakeLists.txt +++ b/src/gdcmjasper/CMakeLists.txt @@ -1,9 +1,34 @@ PROJECT(GDCMJASPER C) -# Don't ask my why... -IF(APPLE) - SET(CMAKE_SHARED_LINKER_FLAGS "-single_module") -ENDIF(APPLE) +#----------------------------------------------------------------------------- +# Test how compiler handle the case of a malloc(0). If it returns 0 +# then we are doomed (jasper does not support this case) +IF("NULL_ON_MALLOC_0" MATCHES "^NULL_ON_MALLOC_0$") + STRING(ASCII 35 POUND) + FILE(WRITE ${GDCMJASPER_BINARY_DIR}/jasperNULLmalloc.c + "${POUND}include \n" + "int main() { return (int)malloc(0); }") + MESSAGE(STATUS "Checking if compiler return NULL on malloc(0)") + TRY_RUN(RESULT_NULL_ON_MALLOC_0 COMPILE_NULL_ON_MALLOC_0 + "${GDCMJASPER_BINARY_DIR}" + "${GDCMJASPER_BINARY_DIR}/jasperNULLmalloc.c" + OUTPUT_VARIABLE OUTPUT) + IF(RESULT_NULL_ON_MALLOC_0 EQUAL 0) + MESSAGE(STATUS "Checking if compiler return NULL on malloc(0) -- yes") + SET(NULL_ON_MALLOC_0 1 CACHE INTERNAL "Check if compiler returns NULL on malloc(0)") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log + "Determining how compiler implement malloc(0)" + "passed with the following output:\n" + "${OUTPUT}\n" APPEND) + ELSE(RESULT_NULL_ON_MALLOC_0 EQUAL 0) + MESSAGE(STATUS "Checking if compiler returns NULL on malloc(0) -- no") + SET(NULL_ON_MALLOC_0 0 CACHE INTERNAL "Check if compiler returns NULL on malloc(0)") + WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log + "Determining how compiler implement malloc(0)" + "failed with the following output:\n" + "${OUTPUT}\n" APPEND) + ENDIF(RESULT_NULL_ON_MALLOC_0 EQUAL 0) +ENDIF("NULL_ON_MALLOC_0" MATCHES "^NULL_ON_MALLOC_0$") #OPTION(HAVE_LIBJPEG "Do you have ijg" OFF) IF(GDCM_SOURCE_DIR)