3 cmake_minimum_required(VERSION 3.20.0)
5 include(CheckCCompilerFlag)
6 check_c_compiler_flag("-std=c99" C99_SUPPORTED)
8 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
11 include(CheckFunctionExists)
12 include(CheckSymbolExists)
14 add_definitions(-D_GNU_SOURCE)
15 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
17 check_function_exists(execve HAVE_EXECVE)
18 check_function_exists(execv HAVE_EXECV)
19 check_function_exists(execvpe HAVE_EXECVPE)
20 check_function_exists(execvp HAVE_EXECVP)
21 check_function_exists(execvP HAVE_EXECVP2)
22 check_function_exists(exect HAVE_EXECT)
23 check_function_exists(execl HAVE_EXECL)
24 check_function_exists(execlp HAVE_EXECLP)
25 check_function_exists(execle HAVE_EXECLE)
26 check_function_exists(posix_spawn HAVE_POSIX_SPAWN)
27 check_function_exists(posix_spawnp HAVE_POSIX_SPAWNP)
29 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
30 include_directories(${CMAKE_CURRENT_BINARY_DIR})
32 add_executable(exec main.c)