Commit cf92ec3b authored by Andreas Schuh's avatar Andreas Schuh

Modify CheckTypeSize.cmake module so it works with older CMake versions.

parent 1e0b54c6
......@@ -65,14 +65,17 @@ include (CheckIncludeFileCXX)
include (CheckCXXSymbolExists)
set (GFLAGS_INTTYPES_FORMAT "" CACHE STRING "Format of integer types: \"C99\" (uint32_t), \"BSD\" (u_int32_t), \"VC7\" (__int32)")
set_property (CACHE GFLAGS_INTTYPES_FORMAT PROPERTY STRINGS "C99;BSD;VC7")
mark_as_advanced (GFLAGS_INTTYPES_FORMAT)
if (NOT GFLAGS_INTTYPES_FORMAT)
foreach (type IN ITEMS uint32_t u_int32_t __int32)
check_type_size (${type} SIZE LANGUAGE CXX)
if (SIZE)
set (HAVE_${type} TRUE)
else ()
set (HAVE_${type} FALSE)
set (TYPES uint32_t u_int32_t)
if (MSVC)
list (INSERT TYPES 0 __int32)
endif ()
foreach (type IN LISTS TYPES)
check_type_size (${type} ${type} LANGUAGE CXX)
if (HAVE_${type})
break ()
endif ()
endforeach ()
if (HAVE_uint32_t)
......
# Copied from master branch of CMake (commit SHA 34a49dea) and
# modified to use CheckIncludeFileCXX instead of CheckIncludeFile
# when the LANGUAGE is CXX.
# when the LANGUAGE is CXX. Modified the try_compile call to
# not pass any LINK_LIBRARIES as this option is only supported by
# CMake since version 2.8.11
# -andreas
#.rst:
# CheckTypeSize
......@@ -62,7 +65,6 @@
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
# CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include
#=============================================================================
......@@ -121,7 +123,6 @@ function(__check_type_size_impl type var map builtin language)
configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY)
try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
CMAKE_FLAGS
"-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}"
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment