From e7f4349cb61f7ef990d3b2c284409675b9acd839 Mon Sep 17 00:00:00 2001 From: Francois Carouge Date: Mon, 5 Sep 2022 16:55:06 -0700 Subject: [PATCH] [cmake] add strict compile options --- CMakeLists.txt | 32 +++++++++++++++++++++- sample/kf_8x4x0_deep_sort_bounding_box.cpp | 16 +++++------ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45fde75dba..39724c80c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" @@ -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() @@ -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() diff --git a/sample/kf_8x4x0_deep_sort_bounding_box.cpp b/sample/kf_8x4x0_deep_sort_bounding_box.cpp index 097eb8da91..80e0f1887f 100644 --- a/sample/kf_8x4x0_deep_sort_bounding_box.cpp +++ b/sample/kf_8x4x0_deep_sort_bounding_box.cpp @@ -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.");