Update Find{MSize,MallocSize,MallocUsableSize}.cmake to handle the case where find_path fails

This commit is contained in:
Soonho Kong 2013-09-21 00:10:25 -07:00
parent 48318511f2
commit 80581a76bb
3 changed files with 66 additions and 60 deletions

View file

@ -1,46 +1,49 @@
find_path(MALLOC_DIR NAMES malloc.h ) find_path(MALLOC_DIR NAMES malloc.h )
if(NOT "${MALLOC_DIR}" MATCHES "MALLOC_DIR-NOTFOUND")
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
# If it's cross-compilation and target is windows, first compile MSIZE_CHECK.exe # If it's cross-compilation and target is windows, first compile MSIZE_CHECK.exe
execute_process(COMMAND ${CMAKE_CXX_COMPILER} execute_process(COMMAND ${CMAKE_CXX_COMPILER}
"-o" ${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/MSIZE_CHECK.exe "-o" ${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/MSIZE_CHECK.exe
${LEAN_SOURCE_DIR}/cmake/Modules/CheckMSize.cc ${LEAN_SOURCE_DIR}/cmake/Modules/CheckMSize.cc
RESULT_VARIABLE MSIZE_CHECK_BUILD_RESULT) RESULT_VARIABLE MSIZE_CHECK_BUILD_RESULT)
if("${MSIZE_CHECK_BUILD_RESULT}" MATCHES "0") if("${MSIZE_CHECK_BUILD_RESULT}" MATCHES "0")
set(MSIZE_CHECK_BUILD "TRUE") set(MSIZE_CHECK_BUILD "TRUE")
# Check whether "wine" exists to run "MSIZE_CHECK.exe" # Check whether "wine" exists to run "MSIZE_CHECK.exe"
execute_process(COMMAND "bash" "-c" "wine --version > /dev/null 2&>1" execute_process(COMMAND "bash" "-c" "wine --version > /dev/null 2&>1"
RESULT_VARIABLE WINE_CHECK) RESULT_VARIABLE WINE_CHECK)
if("${WINE_CHECK}" MATCHES "0") if("${WINE_CHECK}" MATCHES "0")
execute_process(COMMAND "wine" execute_process(COMMAND "wine"
${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/MSIZE_CHECK.exe ${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/MSIZE_CHECK.exe
RESULT_VARIABLE MSIZE_CHECK) RESULT_VARIABLE MSIZE_CHECK)
else()
# NOTE: We can compile a progrm with _msize, but we can't test
# it due to the lack of wine. We assume that it is usable
set(MSIZE_CHECK "0")
set(MSIZE_UNTESTED "(untested)")
endif()
else() else()
# NOTE: We can compile a progrm with _msize, but we can't test set(MSIZE_CHECK_BUILD "FALSE")
# it due to the lack of wine. We assume that it is usable
set(MSIZE_CHECK "0")
set(MSIZE_UNTESTED "(untested)")
endif() endif()
else() else()
set(MSIZE_CHECK_BUILD "FALSE") # It's cross-compilation but the target is not Windows
set(MSIZE_FOUND FALSE)
endif() endif()
else() else()
# It's cross-compilation but the target is not Windows try_run(MSIZE_CHECK MSIZE_CHECK_BUILD
${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
${LEAN_SOURCE_DIR}/cmake/Modules/CheckMSize.cc
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${MALLOC_DIR}
RUN_OUTPUT_VARIABLE MSIZE_TRY_OUT)
endif()
if("${MSIZE_CHECK_BUILD}" MATCHES "TRUE" AND "${MSIZE_CHECK}" MATCHES "0")
message(STATUS "Found _msize " "${MSIZE_UNTESTED}")
set(MSIZE_FOUND TRUE)
else()
message(STATUS "Usable _msize was not detected")
set(MSIZE_FOUND FALSE) set(MSIZE_FOUND FALSE)
endif() endif()
else() else()
try_run(MSIZE_CHECK MSIZE_CHECK_BUILD
${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
${LEAN_SOURCE_DIR}/cmake/Modules/CheckMSize.cc
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${MALLOC_DIR}
RUN_OUTPUT_VARIABLE MSIZE_TRY_OUT)
endif()
if("${MSIZE_CHECK_BUILD}" MATCHES "TRUE" AND "${MSIZE_CHECK}" MATCHES "0")
message(STATUS "Found _msize " "${MSIZE_UNTESTED}")
set(MSIZE_FOUND TRUE)
else()
message(STATUS "Usable _msize was not detected")
set(MSIZE_FOUND FALSE) set(MSIZE_FOUND FALSE)
endif() endif()

View file

@ -1,15 +1,18 @@
find_path(MALLOC_DIR NAMES malloc/malloc.h ) find_path(MALLOC_DIR NAMES malloc/malloc.h )
if(NOT "${MALLOC_DIR}" MATCHES "MALLOC_DIR-NOTFOUND")
try_run(MALLOCSIZE_CHECK MALLOCSIZE_CHECK_BUILD try_run(MALLOCSIZE_CHECK MALLOCSIZE_CHECK_BUILD
${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp ${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
${LEAN_SOURCE_DIR}/cmake/Modules/CheckMallocSize.cc ${LEAN_SOURCE_DIR}/cmake/Modules/CheckMallocSize.cc
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${MALLOC_DIR} CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${MALLOC_DIR}
RUN_OUTPUT_VARIABLE MALLOCSIZE_TRY_OUT) RUN_OUTPUT_VARIABLE MALLOCSIZE_TRY_OUT)
if("${MALLOCSIZE_CHECK_BUILD}" MATCHES "TRUE" AND "${MALLOCSIZE_CHECK}" MATCHES "0") if("${MALLOCSIZE_CHECK_BUILD}" MATCHES "TRUE" AND "${MALLOCSIZE_CHECK}" MATCHES "0")
message(STATUS "Found malloc_size " "${MALLOCSIZE_UNTESTED}") message(STATUS "Found malloc_size " "${MALLOCSIZE_UNTESTED}")
set(MALLOCSIZE_FOUND TRUE) set(MALLOCSIZE_FOUND TRUE)
else()
message(STATUS "Usable malloc_size was not detected")
set(MALLOCSIZE_FOUND FALSE)
endif()
else() else()
message(STATUS "Usable malloc_size was not detected")
set(MALLOCSIZE_FOUND FALSE) set(MALLOCSIZE_FOUND FALSE)
endif() endif()

View file

@ -1,18 +1,18 @@
find_path(MALLOC_DIR NAMES malloc.h ) find_path(MALLOC_DIR NAMES malloc.h )
if(NOT "${MALLOC_DIR}" MATCHES "MALLOC_DIR-NOTFOUND")
try_run(MUS_CHECK MUS_CHECK_BUILD try_run(MUS_CHECK MUS_CHECK_BUILD
${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp ${LEAN_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
${LEAN_SOURCE_DIR}/cmake/Modules/CheckMallocUsableSize.cc ${LEAN_SOURCE_DIR}/cmake/Modules/CheckMallocUsableSize.cc
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${MALLOC_DIR} CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${MALLOC_DIR}
RUN_OUTPUT_VARIABLE MUS_TRY_OUT) RUN_OUTPUT_VARIABLE MUS_TRY_OUT)
if("${MUS_CHECK_BUILD}" MATCHES "TRUE" AND "${MUS_CHECK}" MATCHES "0") if("${MUS_CHECK_BUILD}" MATCHES "TRUE" AND "${MUS_CHECK}" MATCHES "0")
message(STATUS "Found malloc_usable_size") message(STATUS "Found malloc_usable_size")
set(MUS_FOUND TRUE) set(MUS_FOUND TRUE)
else()
message(STATUS "Usable malloc_usable_size was not detected")
set(MUS_FOUND FALSE)
endif()
else() else()
message(STATUS "Usable malloc_usable_size was not detected")
set(MUS_FOUND FALSE) set(MUS_FOUND FALSE)
endif() endif()