Skip to content

Commit

Permalink
[cmake] add strict compile options
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge committed Sep 5, 2022
1 parent 7ef936d commit e7f4349
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
32 changes: 31 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ add_library(kalman_main "source/main.cpp")
target_include_directories(kalman INTERFACE "include"
"support/include/fcarouge")

set(KALMAN_COMPILE_OPTIONS
"-ansi"
"-fno-check-new"
"-fno-common"
"-fstrict-aliasing"
"-pedantic"
"-Wall"
"-Wcast-align"
"-Wchar-subscripts"
"-Wdouble-promotion"
"-Wenum-conversion"
"-Werror"
"-Wextra"
"-Wformat-security"
"-Wlogical-op"
"-Wno-long-long"
"-Wno-psabi"
"-Wno-variadic-macros"
"-Wnon-virtual-dtor"
"-Wpointer-arith"
"-Wshadow"
"-Wundef"
"-Wunused-local-typedefs"
"-Wwrite-strings")

set(KALMAN_TEST_LIST
"test/eigen_f.cpp"
"test/eigen_h.cpp"
Expand All @@ -47,6 +72,8 @@ foreach(test ${KALMAN_TEST_LIST})
add_executable(kalman_${test_name}_driver ${test})
target_link_libraries(kalman_${test_name}_driver PRIVATE eigen fmt kalman
kalman_main)
target_compile_options(kalman_${test_name}_driver
PRIVATE ${KALMAN_COMPILE_OPTIONS})
add_test(kalman_test_${test_name} kalman_${test_name}_driver)
endforeach()

Expand All @@ -56,12 +83,15 @@ set(KALMAN_SAMPLE_LIST
"sample/kf_1x1x0_liquid_temperature.cpp"
"sample/kf_1x1x1_dog_position.cpp"
"sample/kf_2x1x1_rocket_altitude.cpp"
"sample/kf_6x2x0_vehicle_location.cpp")
"sample/kf_6x2x0_vehicle_location.cpp"
"sample/kf_8x4x0_deep_sort_bounding_box.cpp")

foreach(sample ${KALMAN_SAMPLE_LIST})
get_filename_component(sample_name ${sample} NAME_WE)
add_executable(kalman_${sample_name}_driver ${sample})
target_link_libraries(kalman_${sample_name}_driver PRIVATE eigen fmt kalman
kalman_main)
target_compile_options(kalman_${sample_name}_driver
PRIVATE ${KALMAN_COMPILE_OPTIONS})
add_test(kalman_sample_${sample_name} kalman_${sample_name}_driver)
endforeach()
16 changes: 8 additions & 8 deletions sample/kf_8x4x0_deep_sort_bounding_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,17 @@ namespace {
k(output);
}

assert(std::abs(1 - k.x()[0] / 370.932041394761) < 0.001 &&
std::abs(1 - k.x()[1] / 251.173174229878) < 0.001 &&
std::abs(1 - k.x()[2] / 0.314757138075364) < 0.001 &&
std::abs(1 - k.x()[3] / 287.859996019444) < 0.001 &&
std::abs(1 - k.x()[4] / 1.95865368159518) < 0.001 &&
std::abs(1 - k.x()[5] / 0.229282868701086) < 0.001 &&
assert(std::abs(1 - k.x()[0] / 370.932041394761f) < 0.001f &&
std::abs(1 - k.x()[1] / 251.173174229878f) < 0.001f &&
std::abs(1 - k.x()[2] / 0.314757138075364f) < 0.001f &&
std::abs(1 - k.x()[3] / 287.859996019444f) < 0.001f &&
std::abs(1 - k.x()[4] / 1.95865368159518f) < 0.001f &&
std::abs(1 - k.x()[5] / 0.229282868701086f) < 0.001f &&
// The precision of the velocity appears to saturate early on in the
// original example. The parameter could be scaled or larger types used
// to improve comparison accuracy.
std::abs(1 - k.x()[6] / 2.46138628550094E-06) < 0.5 &&
std::abs(1 - k.x()[7] / 0.81402529074969) < 0.001 &&
std::abs(1 - k.x()[6] / 2.46138628550094E-06f) < 0.5f &&
std::abs(1 - k.x()[7] / 0.81402529074969f) < 0.001f &&
"The estimated states expected to meet Nwojke's Deep SORT filter's "
"MOT16 sample tracker #201 dataset at 0.1% accuracy.");

Expand Down

0 comments on commit e7f4349

Please sign in to comment.