function(DefineImplementations prefix) FILE(GLOB children RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${prefix} ${CMAKE_CURRENT_SOURCE_DIR}/${prefix}/*) set(implementations "") foreach(child ${children}) IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${prefix}/${child}) LIST(APPEND implementations ${child}) ENDIF() ENDFOREACH() list(LENGTH implementations nr_implementations) if(nr_implementations EQUAL 0) message(FATAL_ERROR "Cannot call DefineImplementations with an empty implementations list.") endif() list(GET implementations 0 default) set(${prefix}_implementations ${implementations} PARENT_SCOPE) set(${prefix}_implementation "${default}" CACHE STRING "${prefix} implementation chosen at configure time") set_property(CACHE ${prefix}_implementation PROPERTY STRINGS ${implementations}) endfunction(DefineImplementations)