From bce17c5417824794ea90db7dd3b38a51fb9f1695 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 8 Oct 2020 11:21:10 +0300 Subject: [PATCH] Add option MED_INT_SIZE to know when medfile is built with med_int=long --- cmake/FindMEDFile.cmake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmake/FindMEDFile.cmake b/cmake/FindMEDFile.cmake index 2a483da..1e40c63 100644 --- a/cmake/FindMEDFile.cmake +++ b/cmake/FindMEDFile.cmake @@ -52,3 +52,25 @@ ENDIF(MEDFILE_F_LIBRARIES) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(MEDFile REQUIRED_VARS MEDFILE_INCLUDE_DIRS MEDFILE_LIBRARIES) + +IF(MEDFile_FOUND) + # Check size of med_int + SET(_med_int_cxx ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_med_int_size.cxx) + FILE(WRITE ${_med_int_cxx} + "#include \n#include \nint main(){printf(\"%d\", sizeof(med_int)); return 0;}") + TRY_RUN(_med_int_run_result _med_int_compile_results + ${CMAKE_BINARY_DIR} ${_med_int_cxx} + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${MEDFILE_INCLUDE_DIRS};${HDF5_INCLUDE_DIR}" + LINK_LIBRARIES ${MEDFILE_C_LIBRARIES} + RUN_OUTPUT_VARIABLE _med_int_output) + IF(_med_int_compile_results) + SET(MED_INT_SIZE ${_med_int_output}) + ELSE() + SET(MED_INT_SIZE UNKNOWN) + ENDIF() + MESSAGE(STATUS "Size of med_int is ${MED_INT_SIZE}") + UNSET(_med_int_cxx) + UNSET(_med_int_run_result) + UNSET(_med_int_compile_results) + UNSET(_med_int_output) +ENDIF() -- 2.39.2