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