Skip to content

Instantly share code, notes, and snippets.

@jcfr
Last active August 1, 2016 17:53
Show Gist options
  • Select an option

  • Save jcfr/5289753 to your computer and use it in GitHub Desktop.

Select an option

Save jcfr/5289753 to your computer and use it in GitHub Desktop.
Small project created to try to reproduce failing BigEndian test
cmake_minimum_required(VERSION 2.8.6)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Release CACHE STRING "Release configuration" FORCE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release")
endif()
project(PythonTestBigEndianIssue C)
include(CheckIncludeFiles)
include(TestBigEndian)
set(CMAKE_REQUIRED_DEFINITIONS )
# Convenient macro allowing to conditonally update CMAKE_REQUIRED_DEFINITIONS
macro(set_required_def var value)
set(${var} ${value})
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${var}=${value}")
endmacro(set_required_def)
macro(ADD_COND var cond item)
if(${cond})
set(${var} ${${var}} ${item})
endif(${cond})
endmacro(ADD_COND)
message(STATUS "Checking for XOPEN_SOURCE")
# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
# disable features if it is defined, without any means to access these
# features as extensions. For these systems, we skip the definition of
# _XOPEN_SOURCE. Before adding a system to the list to gain access to
# some feature, make sure there is no alternative way to access this
# feature. Also, when using wildcards, make sure you have verified the
# need for not defining _XOPEN_SOURCE on all systems matching the
# wildcard, and that the wildcard does not include future systems
# (which may remove their limitations).
set(define_xopen_source 1)
if(CMAKE_SYSTEM MATCHES "Darwin\\-[6789]\\."
OR CMAKE_SYSTEM MATCHES "Darwin\\-1[0-9]\\.")
# Darwin/@<:@6789@:>@.*)
# Darwin/1@<:@0-9@:>@.*
# On MacOS X 10.2, a bug in ncurses.h means that it craps out if
# _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
# identifies itself as Darwin/7.*
# On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
# disables platform specific features beyond repair.
# On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
# has no effect, don't bother defining them
set(define_xopen_source 0)
endif()
if(define_xopen_source)
message(STATUS "Checking for XOPEN_SOURCE - yes")
set_required_def(_XOPEN_SOURCE 600) # Define to the level of X/Open that your system supports
set_required_def(_XOPEN_SOURCE_EXTENDED 1) # Define to activate Unix95-and-earlier features
set_required_def(_POSIX_C_SOURCE 200112L) # Define to activate features from IEEE Stds 1003.1-2001
else()
message(STATUS "Checking for XOPEN_SOURCE - no")
endif()
check_include_files(wchar.h HAVE_WCHAR_H)
find_library(HAVE_LIBM m)
find_library(HAVE_LIBINTL intl)
find_library(HAVE_LIBUTIL util)
set(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBM ${HAVE_LIBM})
add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBINTL ${HAVE_LIBINTL})
add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBUTIL ${HAVE_LIBUTIL})
add_cond(CMAKE_EXTRA_INCLUDE_FILES HAVE_WCHAR_H wchar.h)
set_required_def(_GNU_SOURCE 1) # Define on Linux to activate all library features
set_required_def(_NETBSD_SOURCE 1) # Define on NetBSD to activate all library features
set_required_def(__BSD_VISIBLE 1) # Define on FreeBSD to activate all library features
set_required_def(_BSD_TYPES 1) # Define on Irix to enable u_int
set_required_def(_DARWIN_C_SOURCE 1) # Define on Darwin to activate all library features
set_required_def(_ALL_SOURCE 1) # Enable extensions on AIX 3, Interix.
set_required_def(_POSIX_PTHREAD_SEMANTICS 1) # Enable threading extensions on Solaris.
set_required_def(_TANDEM_SOURCE 1) # Enable extensions on HP NonStop.
set_required_def(__EXTENSIONS__ 1) # Defined on Solaris to see additional function prototypes.
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment