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