freebsd-src/contrib/libevent/cmake/CheckConstExists.cmake
Cy Schubert b50261e21f libevent: Import libevent 2.1.12
MFC after:	2 weeks

Merge commit '5223d1d95fddcef6f9a36e264a5800bd907ade8b' into main
2023-11-14 17:13:02 -08:00

26 lines
815 B
CMake

include(CheckCSourceCompiles)
macro(check_const_exists CONST FILES VARIABLE)
if (NOT DEFINED ${VARIABLE})
set(check_const_exists_source "")
foreach(file ${FILES})
set(check_const_exists_source
"${check_const_exists_source}
#include <${file}>")
endforeach()
set(check_const_exists_source
"${check_const_exists_source}
int main() { (void)${CONST}; return 0; }")
check_c_source_compiles("${check_const_exists_source}" ${VARIABLE})
if (${${VARIABLE}})
set(${VARIABLE} 1 CACHE INTERNAL "Have const ${CONST}")
message(STATUS "Looking for ${CONST} - found")
else()
set(${VARIABLE} 0 CACHE INTERNAL "Have const ${CONST}")
message(STATUS "Looking for ${CONST} - not found")
endif()
endif()
endmacro(check_const_exists)