From e13dd7770e53eb8ac6be4022ff85e3835257aa21 Mon Sep 17 00:00:00 2001 From: Tony Najjar Date: Fri, 17 Mar 2023 19:35:25 +0100 Subject: [PATCH] Check compile options (#3487) (cherry picked from commit e7259030f834ff19599206ae80a1ed5d05cd32d2) --- nav2_mppi_controller/CMakeLists.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nav2_mppi_controller/CMakeLists.txt b/nav2_mppi_controller/CMakeLists.txt index 2b496d3d58..4abc9c7454 100644 --- a/nav2_mppi_controller/CMakeLists.txt +++ b/nav2_mppi_controller/CMakeLists.txt @@ -32,7 +32,21 @@ foreach(pkg IN LISTS dependencies_pkgs) endforeach() nav2_package() -add_compile_options(-O3 -mavx2 -mfma -finline-limit=1000000 -ffp-contract=fast -ffast-math) + +include(CheckCXXCompilerFlag) + +check_cxx_compiler_flag("-mavx2" COMPILER_SUPPORTS_AVX2) +check_cxx_compiler_flag("-mfma" COMPILER_SUPPORTS_FMA) + +if(COMPILER_SUPPORTS_AVX2) + add_compile_options(-mavx2) +endif() + +if(COMPILER_SUPPORTS_FMA) + add_compile_options(-mfma) +endif() + +add_compile_options(-O3 -finline-limit=1000000 -ffp-contract=fast -ffast-math) add_library(mppi_controller SHARED src/controller.cpp