summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--cmake/opentrack-variant.cmake72
-rw-r--r--variant/default/_variant.cmake27
-rw-r--r--variant/trackmouse/_variant.cmake19
4 files changed, 72 insertions, 49 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa1a63dd..8c408efc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,9 +63,6 @@ function(otr_add_subdirs)
get_property(_globs GLOBAL PROPERTY opentrack-subprojects)
otr_add_target_dirs(_globbed ${_globs})
- get_property(_variant GLOBAL PROPERTY opentrack-variant)
- add_subdirectory("variant/${_variant}")
-
foreach(k ${_globbed})
get_filename_component(k "${k}" DIRECTORY)
add_subdirectory("${k}")
diff --git a/cmake/opentrack-variant.cmake b/cmake/opentrack-variant.cmake
index 607aa441..bae5a451 100644
--- a/cmake/opentrack-variant.cmake
+++ b/cmake/opentrack-variant.cmake
@@ -1,51 +1,31 @@
-set(opentrack_variant "default" CACHE STRING "")
-set_property(CACHE opentrack_variant PROPERTY STRINGS "default;trackmouse")
-
# XXX that belongs in each variant's directory!
function(otr_dist_select_variant)
- if(opentrack_variant STREQUAL "trackmouse")
- set_property(GLOBAL PROPERTY opentrack-variant "trackmouse")
- set_property(GLOBAL PROPERTY opentrack-ident "trackmouse-prototype")
- set(subprojects
- "tracker-pt"
- "proto-mouse"
- "filter-accela"
- "options"
- "api"
- "compat"
- "logic"
- "dinput"
- "gui"
- "pose-widget"
- "spline"
- "cv"
- "migration")
- set_property(GLOBAL PROPERTY opentrack-subprojects "${subprojects}")
- else()
- set_property(GLOBAL PROPERTY opentrack-variant "default")
- set_property(GLOBAL PROPERTY opentrack-ident "opentrack-2.3")
- set(subprojects
- "tracker-*"
- "proto-*"
- "filter-*"
- "ext-*"
- "options"
- "api"
- "compat"
- "logic"
- "dinput"
- "gui"
- "main"
- "x-plane-plugin"
- "csv"
- "pose-widget"
- "spline"
- "qxt-mini"
- "macosx"
- "cv"
- "migration")
- set_property(GLOBAL PROPERTY opentrack-subprojects "${subprojects}")
+ file(GLOB variants "variant/*")
+
+ set(variant-list "")
+
+ foreach(k ${variants})
+ get_filename_component(name "${k}" NAME)
+ if(EXISTS "${k}/_variant.cmake" AND EXISTS "${k}/CMakeLists.txt")
+ list(APPEND variant-list "${name}")
+ else()
+ message(FATAL_ERROR "Stray item in variant dir '${name}'")
+ endif()
+ endforeach()
+
+ set(opentrack_variant "default" CACHE STRING "")
+ set(dir "${CMAKE_SOURCE_DIR}/variant/${opentrack_variant}")
+
+ if(NOT EXISTS "${dir}/_variant.cmake" OR NOT EXISTS "${dir}/CMakeLists.txt")
+ set(opentrack_variant "default" CACHE STRING "" FORCE)
+ set(dir "${CMAKE_SOURCE_DIR}/variant/${opentrack_variant}")
endif()
-endfunction()
+ set_property(CACHE opentrack_variant PROPERTY STRINGS "${variant-list}")
+
+ include("${dir}/_variant.cmake")
+ otr_init_variant()
+
+ add_subdirectory("${dir}")
+endfunction()
diff --git a/variant/default/_variant.cmake b/variant/default/_variant.cmake
new file mode 100644
index 00000000..cdf9da56
--- /dev/null
+++ b/variant/default/_variant.cmake
@@ -0,0 +1,27 @@
+function(otr_init_variant)
+ set_property(GLOBAL PROPERTY opentrack-variant "default")
+ set_property(GLOBAL PROPERTY opentrack-ident "opentrack-2.3")
+
+ set(subprojects
+ "tracker-*"
+ "proto-*"
+ "filter-*"
+ "ext-*"
+ "options"
+ "api"
+ "compat"
+ "logic"
+ "dinput"
+ "gui"
+ "main"
+ "x-plane-plugin"
+ "csv"
+ "pose-widget"
+ "spline"
+ "qxt-mini"
+ "macosx"
+ "cv"
+ "migration")
+
+ set_property(GLOBAL PROPERTY opentrack-subprojects "${subprojects}")
+endfunction()
diff --git a/variant/trackmouse/_variant.cmake b/variant/trackmouse/_variant.cmake
new file mode 100644
index 00000000..b54ecf52
--- /dev/null
+++ b/variant/trackmouse/_variant.cmake
@@ -0,0 +1,19 @@
+function(otr_init_variant)
+ set_property(GLOBAL PROPERTY opentrack-variant "trackmouse")
+ set_property(GLOBAL PROPERTY opentrack-ident "trackmouse-prototype")
+ set(subprojects
+ "tracker-pt"
+ "proto-mouse"
+ "filter-accela"
+ "options"
+ "api"
+ "compat"
+ "logic"
+ "dinput"
+ "gui"
+ "pose-widget"
+ "spline"
+ "cv"
+ "migration")
+ set_property(GLOBAL PROPERTY opentrack-subprojects "${subprojects}")
+endfunction()