diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index e3168a41f..d11c9a5ee 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -36,42 +36,12 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to ]] -foreach(SAMPLE "kf_1x1x0_building_height.cpp" "kf_1x1x0_liquid_temperature.cpp" - "kf_1x1x1_dog_position.cpp") - get_filename_component(NAME ${SAMPLE} NAME_WE) - add_executable(kalman_sample_${NAME}_driver ${SAMPLE}) - target_link_libraries(kalman_sample_${NAME}_driver PRIVATE kalman kalman_main - kalman_options) - separate_arguments(TEST_COMMAND UNIX_COMMAND $ENV{COMMAND}) - add_test(NAME kalman_sample_${NAME} - COMMAND ${TEST_COMMAND} $) -endforeach() - -foreach(BACKEND IN ITEMS "eigen" "naive") - foreach(SAMPLE "ekf_4x1x0_soaring.cpp" "kf_2x1x1_rocket_altitude.cpp") - get_filename_component(NAME ${SAMPLE} NAME_WE) - add_executable(kalman_sample_${BACKEND}_${NAME}_driver ${SAMPLE}) - target_link_libraries( - kalman_sample_${BACKEND}_${NAME}_driver - PRIVATE kalman kalman_main kalman_linalg_${BACKEND} kalman_options) - separate_arguments(TEST_COMMAND UNIX_COMMAND $ENV{COMMAND}) - add_test(NAME kalman_sample_${BACKEND}_${NAME} - COMMAND ${TEST_COMMAND} - $) - endforeach() -endforeach() - -foreach(BACKEND IN ITEMS "eigen") - foreach(SAMPLE "kf_6x2x0_vehicle_location.cpp" - "kf_8x4x0_deep_sort_bounding_box.cpp") - get_filename_component(NAME ${SAMPLE} NAME_WE) - add_executable(kalman_sample_${BACKEND}_${NAME}_driver ${SAMPLE}) - target_link_libraries( - kalman_sample_${BACKEND}_${NAME}_driver - PRIVATE kalman kalman_main kalman_linalg_${BACKEND} kalman_options) - separate_arguments(TEST_COMMAND UNIX_COMMAND $ENV{COMMAND}) - add_test(NAME kalman_sample_${BACKEND}_${NAME} - COMMAND ${TEST_COMMAND} - $) - endforeach() -endforeach() +include(sample.cmake) + +sample(NAME "ekf_4x1x0_soaring" BACKENDS "eigen" "naive") +sample(NAME "kf_1x1x0_building_height") +sample(NAME "kf_1x1x0_liquid_temperature") +sample(NAME "kf_1x1x1_dog_position") +sample(NAME "kf_2x1x1_rocket_altitude" BACKENDS "eigen" "naive") +sample(NAME "kf_6x2x0_vehicle_location" BACKENDS "eigen") +sample(NAME "kf_8x4x0_deep_sort_bounding_box" BACKENDS "eigen") diff --git a/sample/sample.cmake b/sample/sample.cmake new file mode 100644 index 000000000..349cb01c7 --- /dev/null +++ b/sample/sample.cmake @@ -0,0 +1,73 @@ +#[[ __ _ __ __ _ _ +| |/ / /\ | | | \/ | /\ | \ | | +| ' / / \ | | | \ / | / \ | \| | +| < / /\ \ | | | |\/| | / /\ \ | . ` | +| . \ / ____ \| |____| | | |/ ____ \| |\ | +|_|\_\/_/ \_\______|_| |_/_/ \_\_| \_| + +Kalman Filter +Version 0.4.0 +https://github.com/FrancoisCarouge/Kalman + +SPDX-License-Identifier: Unlicense + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to ]] + +# Add a given sample. +# +# * NAME The name of the sample file without extension. +# * BACKENDS Optional list of backends to use against the sample. +function(sample) + set(oneValueArgs NAME) + set(multiValueArgs BACKENDS) + cmake_parse_arguments(PARSE_ARGV 0 SAMPLE "" "${oneValueArgs}" + "${multiValueArgs}") + + if(NOT SAMPLE_BACKENDS) + add_executable(kalman_sample_${SAMPLE_NAME}_driver "${SAMPLE_NAME}.cpp") + target_link_libraries( + kalman_sample_${SAMPLE_NAME}_driver + PRIVATE kalman kalman_main kalman_options kalman_unit_mp_units) + separate_arguments(SAMPLE_COMMAND UNIX_COMMAND $ENV{COMMAND}) + add_test(NAME kalman_sample_${SAMPLE_NAME} + COMMAND ${SAMPLE_COMMAND} + $) + else() + foreach(BACKEND IN ITEMS ${SAMPLE_BACKENDS}) + add_executable(kalman_sample_${BACKEND}_${SAMPLE_NAME}_driver + "${SAMPLE_NAME}.cpp") + target_link_libraries( + kalman_sample_${BACKEND}_${SAMPLE_NAME}_driver + PRIVATE kalman kalman_main kalman_linalg_${BACKEND} kalman_options + kalman_unit_mp_units) + separate_arguments(SAMPLE_COMMAND UNIX_COMMAND $ENV{COMMAND}) + add_test( + NAME kalman_sample_${BACKEND}_${SAMPLE_NAME} + COMMAND ${SAMPLE_COMMAND} + $) + endforeach() + endif() +endfunction(sample) diff --git a/test/test.cmake b/test/test.cmake index 50098069b..a5caac94a 100644 --- a/test/test.cmake +++ b/test/test.cmake @@ -36,8 +36,10 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to ]] -# Add a given test NAME The name of the test file without extension. BACKENDS -# Optional list of backend to use against the test. +# Add a given test. +# +# * NAME The name of the test file without extension. +# * BACKENDS Optional list of backends to use against the test. function(test) set(oneValueArgs NAME) set(multiValueArgs BACKENDS)