Use <stdlib.h> for alloca on FreeBSD.

https://www.freebsd.org/cgi/man.cgi?alloca

If stdlib.h does not define alloca, and we're using GCC (or Clang), we
define the macro ourselves in terms of a GCC builtin.
This commit is contained in:
iphydf
2018-01-22 09:37:31 +00:00
parent e6c04ef028
commit 8f1bbcf83e
10 changed files with 58 additions and 68 deletions
-24
View File
@@ -1,6 +1,5 @@
option(ENABLE_SHARED "Build shared (dynamic) libraries for all modules" ON)
option(ENABLE_STATIC "Build static libraries for all modules" ON)
option(COMPILE_AS_CXX "Compile all C code as C++ code" OFF)
if(NOT ENABLE_SHARED AND NOT ENABLE_STATIC)
message(WARNING
@@ -12,28 +11,6 @@ endif()
find_package(PkgConfig)
if(COMPILE_AS_CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_LIMIT_MACROS=1")
endif()
macro(set_source_language)
if(COMPILE_AS_CXX)
foreach(srcfile ${ARGN})
get_filename_component(srcext ${srcfile} EXT)
if(${srcext} STREQUAL ".c")
set_source_files_properties(${srcfile} PROPERTIES LANGUAGE CXX)
endif()
endforeach()
endif()
endmacro()
function(add_binary exec)
set_source_language(${ARGN})
add_executable(${exec} ${ARGN})
endfunction()
function(pkg_use_module mod pkg)
if(PKG_CONFIG_FOUND)
pkg_search_module(${mod} ${pkg})
@@ -58,7 +35,6 @@ macro(add_submodule super lib)
endmacro()
function(add_module lib)
set_source_language(${ARGN})
set(${lib}_SOURCES ${ARGN} PARENT_SCOPE)
if(ENABLE_SHARED)