aboutsummaryrefslogtreecommitdiff
path: root/CMakeModules/implementations.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeModules/implementations.cmake')
-rw-r--r--CMakeModules/implementations.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/CMakeModules/implementations.cmake b/CMakeModules/implementations.cmake
new file mode 100644
index 0000000..aa6a8bf
--- /dev/null
+++ b/CMakeModules/implementations.cmake
@@ -0,0 +1,23 @@
+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)