cmake/test_restrict.cmake
Danny Robson 54f0855312 Use CMAKE_CURRENT_LIST_DIR for local includes to simplify usage
This means that we no longer need to modify the module path for CMake
before including the root script.
2022-06-15 10:46:52 +10:00

23 lines
1.0 KiB
CMake

macro(test_restrict VARIABLE)
if (NOT DEFINED TEST_${VARIABLE})
message (STATUS "checking for restrict keyword")
FOREACH(KEYWORD "restrict" "__restrict" "__restrict__" "_Restrict")
IF (NOT TEST_${VARIABLE})
TRY_COMPILE(
TEST_${VARIABLE}
"${CMAKE_BINARY_DIR}/CMakeTmp"
SOURCES "${CMAKE_CURRENT_LIST_DIR}/test_restrict.cpp"
COMPILE_DEFINITIONS "-DKEYWORD=${KEYWORD}")
set(__test_restrict_last ${KEYWORD})
ENDIF (NOT TEST_${VARIABLE})
endforeach(KEYWORD)
if (TEST_${VARIABLE})
message (STATUS "checking for restrict keyword - ${__test_restrict_last}")
set(${VARIABLE} ${__test_restrict_last} CACHE INTERNAL "restrict keyword" FORCE)
else (TEST_${VARIABLE})
message (STATUS "checking for restrict keyword - not found")
endif(TEST_${VARIABLE})
endif(NOT DEFINED TEST_${VARIABLE})
endmacro(test_restrict)