diff --git a/Meta/CMake/lagom_compile_options.cmake b/Meta/CMake/lagom_compile_options.cmake index 7fec47ac843..64ddf53a379 100644 --- a/Meta/CMake/lagom_compile_options.cmake +++ b/Meta/CMake/lagom_compile_options.cmake @@ -29,9 +29,17 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (NOT MSVC) add_cxx_compile_options(-ggdb3) endif() - add_cxx_compile_options(-Og) + if ("$ENV{CXXFLAGS}" MATCHES "(^| )(-O(fast|.?))( |$)") + add_cxx_compile_options(${CMAKE_MATCH_0}) + else () + add_cxx_compile_options(-Og) + endif() else() - add_cxx_compile_options(-O2) + if ("$ENV{CXXFLAGS}" MATCHES "(^| )(-O(fast|.?))( |$)") + add_cxx_compile_options(${CMAKE_MATCH_0}) + else () + add_cxx_compile_options(-O2) + endif() if (NOT MSVC) add_cxx_compile_options(-g1) endif()