1*b50261e2SCy Schubertinclude(CheckCSourceCompiles) 2*b50261e2SCy Schubert 3*b50261e2SCy Schubertmacro(check_const_exists CONST FILES VARIABLE) 4*b50261e2SCy Schubert if (NOT DEFINED ${VARIABLE}) 5*b50261e2SCy Schubert set(check_const_exists_source "") 6*b50261e2SCy Schubert foreach(file ${FILES}) 7*b50261e2SCy Schubert set(check_const_exists_source 8*b50261e2SCy Schubert "${check_const_exists_source} 9*b50261e2SCy Schubert #include <${file}>") 10*b50261e2SCy Schubert endforeach() 11*b50261e2SCy Schubert set(check_const_exists_source 12*b50261e2SCy Schubert "${check_const_exists_source} 13*b50261e2SCy Schubert int main() { (void)${CONST}; return 0; }") 14*b50261e2SCy Schubert 15*b50261e2SCy Schubert check_c_source_compiles("${check_const_exists_source}" ${VARIABLE}) 16*b50261e2SCy Schubert 17*b50261e2SCy Schubert if (${${VARIABLE}}) 18*b50261e2SCy Schubert set(${VARIABLE} 1 CACHE INTERNAL "Have const ${CONST}") 19*b50261e2SCy Schubert message(STATUS "Looking for ${CONST} - found") 20*b50261e2SCy Schubert else() 21*b50261e2SCy Schubert set(${VARIABLE} 0 CACHE INTERNAL "Have const ${CONST}") 22*b50261e2SCy Schubert message(STATUS "Looking for ${CONST} - not found") 23*b50261e2SCy Schubert endif() 24*b50261e2SCy Schubert endif() 25*b50261e2SCy Schubertendmacro(check_const_exists) 26