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) ...@@ -65,14 +65,17 @@ include (CheckIncludeFileCXX)
include (CheckCXXSymbolExists) include (CheckCXXSymbolExists)
set (GFLAGS_INTTYPES_FORMAT "" CACHE STRING "Format of integer types: \"C99\" (uint32_t), \"BSD\" (u_int32_t), \"VC7\" (__int32)") 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) mark_as_advanced (GFLAGS_INTTYPES_FORMAT)
if (NOT GFLAGS_INTTYPES_FORMAT) if (NOT GFLAGS_INTTYPES_FORMAT)
foreach (type IN ITEMS uint32_t u_int32_t __int32) set (TYPES uint32_t u_int32_t)
check_type_size (${type} SIZE LANGUAGE CXX) if (MSVC)
if (SIZE) list (INSERT TYPES 0 __int32)
set (HAVE_${type} TRUE) endif ()
else () foreach (type IN LISTS TYPES)
set (HAVE_${type} FALSE) check_type_size (${type} ${type} LANGUAGE CXX)
if (HAVE_${type})
break ()
endif () endif ()
endforeach () endforeach ()
if (HAVE_uint32_t) if (HAVE_uint32_t)
......
# Copied from master branch of CMake (commit SHA 34a49dea) and # Copied from master branch of CMake (commit SHA 34a49dea) and
# modified to use CheckIncludeFileCXX instead of CheckIncludeFile # 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: #.rst:
# CheckTypeSize # CheckTypeSize
...@@ -62,7 +65,6 @@ ...@@ -62,7 +65,6 @@
# CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories # 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 # CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include
#============================================================================= #=============================================================================
...@@ -121,7 +123,6 @@ function(__check_type_size_impl type var map builtin language) ...@@ -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) configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY)
try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src} try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
CMAKE_FLAGS CMAKE_FLAGS
"-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}" "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}"
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}" "-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