diff --git a/cmake/adjust_global_compile_flags.cmake b/cmake/adjust_global_compile_flags.cmake index 2aa83e9e3ee96..f9839ba7ed483 100644 --- a/cmake/adjust_global_compile_flags.cmake +++ b/cmake/adjust_global_compile_flags.cmake @@ -99,10 +99,21 @@ if (onnxruntime_ENABLE_LTO) include(CheckIPOSupported) check_ipo_supported(RESULT ipo_enabled OUTPUT ipo_output) if (NOT ipo_enabled) - message(WARNING "IPO is not supported by this compiler") + message(WARNING "Interprocedural optimization (IPO) is not supported by this compiler. ${ipo_output}") set(onnxruntime_ENABLE_LTO OFF) else() set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) + + # See https://cmake.org/cmake/help/latest/policy/CMP0069.html. + # + # "The OLD behavior for this policy is to add IPO flags only for Intel compiler on Linux. + # The NEW behavior for this policy is to add IPO flags for the current compiler or produce an error if CMake does + # not know the flags." + # + # CMake versions 3.8 and lower use the OLD behavior. This project requires CMake version > 3.8. + # However, some dependencies may specify a lower required CMake version and default to the OLD behavior. + # Ensure that CMake also uses the NEW behavior for such dependencies. + set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) endif() endif() @@ -342,4 +353,4 @@ endif() if (onnxruntime_USE_EXTENSIONS) include_directories(${REPO_ROOT}/include/onnxruntime/core/session) -endif() \ No newline at end of file +endif()