summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorVitaliy Kirsanov <krokoziabla@yandex-team.ru>2019-03-31 23:04:45 +0300
committerErik de Castro Lopo <erikd@mega-nerd.com>2019-05-04 11:41:48 +1000
commitc39718d7a36405114f9ed0b1a7acaef64ea88131 (patch)
tree3d3633d0af41f00ccb6f0ec4dc48f9b018d5ff7c /cmake
parent12ec86c6188aef9ebd4b9bd0393eab7326e185fc (diff)
downloadflac-c39718d7a36405114f9ed0b1a7acaef64ea88131.tar.gz
CMake support added
Diffstat (limited to 'cmake')
-rw-r--r--cmake/UseSystemExtensions.cmake81
1 files changed, 81 insertions, 0 deletions
diff --git a/cmake/UseSystemExtensions.cmake b/cmake/UseSystemExtensions.cmake
new file mode 100644
index 00000000..4a33fd4b
--- /dev/null
+++ b/cmake/UseSystemExtensions.cmake
@@ -0,0 +1,81 @@
+cmake_minimum_required(VERSION 3.12)
+
+include(CheckCSourceCompiles)
+
+check_c_source_compiles("
+ int main()
+ {
+ #ifndef _FORTIFY_SOURCE
+ return 0;
+ #else
+ this_is_an_error;
+ #endif
+ }"
+ DODEFINE_FORTIFY_SOURCE)
+check_c_source_compiles("
+ #include <wchar.h>
+ mbstate_t x;
+ int main() { return 0; }"
+ HAVE_MBSTATE)
+if(NOT HAVE_MBSTATE)
+ check_c_source_compiles("
+ #define _XOPEN_SOURCE 500
+ #include <wchar.h>
+ mbstate_t x;
+ int main() { return 0; }"
+ DODEFINE_XOPEN_SOURCE)
+endif()
+check_c_source_compiles("
+ #define __EXTENSIONS__ 1
+ #include <stdio.h>
+ #ifdef HAVE_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
+ #ifdef HAVE_SYS_STAT_H
+ # include <sys/stat.h>
+ #endif
+ #ifdef STDC_HEADERS
+ # include <stdlib.h>
+ # include <stddef.h>
+ #else
+ # ifdef HAVE_STDLIB_H
+ # include <stdlib.h>
+ # endif
+ #endif
+ #ifdef HAVE_STRING_H
+ # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+ # include <memory.h>
+ # endif
+ # include <string.h>
+ #endif
+ #ifdef HAVE_STRINGS_H
+ # include <strings.h>
+ #endif
+ #ifdef HAVE_INTTYPES_H
+ # include <inttypes.h>
+ #endif
+ #ifdef HAVE_STDINT_H
+ # include <stdint.h>
+ #endif
+ #ifdef HAVE_UNISTD_H
+ # include <unistd.h>
+ #endif
+ int main() { return 0; }"
+ DODEFINE_EXTENSIONS)
+
+add_compile_definitions(
+ _ALL_SOURCE
+ _DARWIN_C_SOURCE
+ _GNU_SOURCE
+ _POSIX_PTHREAD_SEMANTICS
+ __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+ __STDC_WANT_IEC_60559_BFP_EXT__
+ __STDC_WANT_IEC_60559_DFP_EXT__
+ __STDC_WANT_IEC_60559_FUNCS_EXT__
+ __STDC_WANT_IEC_60559_TYPES_EXT__
+ __STDC_WANT_LIB_EXT2__
+ __STDC_WANT_MATH_SPEC_FUNCS__
+ _TANDEM_SOURCE
+ $<$<AND:$<BOOL:${DODEFINE_FORTIFY_SOURCE}>,$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>>:_FORTIFY_SOURCE=2>
+ $<$<BOOL:${DODEFINE_XOPEN_SOURCE}>:_XOPEN_SOURCE=500>
+ $<$<BOOL:${DODEFINE_EXTENTIONS}>:__EXTENSIONS__>)