|
|
@@ -89,17 +89,38 @@ function(__check_type_size_impl type var map builtin language)
|
|
|
message(CHECK_START "Check size of ${type}")
|
|
|
endif()
|
|
|
|
|
|
+ # Perform language check
|
|
|
+ if(language STREQUAL "C")
|
|
|
+ set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c)
|
|
|
+ elseif(language STREQUAL "CXX")
|
|
|
+ set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.cpp)
|
|
|
+ else()
|
|
|
+ message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n")
|
|
|
+ endif()
|
|
|
+
|
|
|
# Include header files.
|
|
|
set(headers)
|
|
|
if(builtin)
|
|
|
- if(HAVE_SYS_TYPES_H)
|
|
|
- string(APPEND headers "#include <sys/types.h>\n")
|
|
|
- endif()
|
|
|
- if(HAVE_STDINT_H)
|
|
|
- string(APPEND headers "#include <stdint.h>\n")
|
|
|
- endif()
|
|
|
- if(HAVE_STDDEF_H)
|
|
|
- string(APPEND headers "#include <stddef.h>\n")
|
|
|
+ if(language STREQUAL "CXX" AND type MATCHES "^std::")
|
|
|
+ if(HAVE_SYS_TYPES_H)
|
|
|
+ string(APPEND headers "#include <sys/types.h>\n")
|
|
|
+ endif()
|
|
|
+ if(HAVE_CSTDINT)
|
|
|
+ string(APPEND headers "#include <cstdint>\n")
|
|
|
+ endif()
|
|
|
+ if(HAVE_CSTDDEF)
|
|
|
+ string(APPEND headers "#include <cstddef>\n")
|
|
|
+ endif()
|
|
|
+ else()
|
|
|
+ if(HAVE_SYS_TYPES_H)
|
|
|
+ string(APPEND headers "#include <sys/types.h>\n")
|
|
|
+ endif()
|
|
|
+ if(HAVE_STDINT_H)
|
|
|
+ string(APPEND headers "#include <stdint.h>\n")
|
|
|
+ endif()
|
|
|
+ if(HAVE_STDDEF_H)
|
|
|
+ string(APPEND headers "#include <stddef.h>\n")
|
|
|
+ endif()
|
|
|
endif()
|
|
|
endif()
|
|
|
foreach(h ${CMAKE_EXTRA_INCLUDE_FILES})
|
|
|
@@ -107,14 +128,6 @@ function(__check_type_size_impl type var map builtin language)
|
|
|
endforeach()
|
|
|
|
|
|
# Perform the check.
|
|
|
-
|
|
|
- if(language STREQUAL "C")
|
|
|
- set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c)
|
|
|
- elseif(language STREQUAL "CXX")
|
|
|
- set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.cpp)
|
|
|
- else()
|
|
|
- message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n")
|
|
|
- endif()
|
|
|
set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin)
|
|
|
configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY)
|
|
|
try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src}
|
|
|
@@ -232,8 +245,13 @@ macro(CHECK_TYPE_SIZE TYPE VARIABLE)
|
|
|
check_include_file(stddef.h HAVE_STDDEF_H)
|
|
|
elseif(_language STREQUAL "CXX")
|
|
|
check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
|
|
|
- check_include_file_cxx(stdint.h HAVE_STDINT_H)
|
|
|
- check_include_file_cxx(stddef.h HAVE_STDDEF_H)
|
|
|
+ if("${TYPE}" MATCHES "^std::")
|
|
|
+ check_include_file_cxx(cstdint HAVE_CSTDINT)
|
|
|
+ check_include_file_cxx(cstddef HAVE_CSTDDEF)
|
|
|
+ else()
|
|
|
+ check_include_file_cxx(stdint.h HAVE_STDINT_H)
|
|
|
+ check_include_file_cxx(stddef.h HAVE_STDDEF_H)
|
|
|
+ endif()
|
|
|
endif()
|
|
|
endif()
|
|
|
unset(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY)
|