[llvm] b816895 - [LLVM] Fix GetErrcMessages.cmake module for WoA
Muhammad Omair Javaid via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 28 02:41:40 PDT 2022
Author: Muhammad Omair Javaid
Date: 2022-09-28T14:41:09+05:00
New Revision: b816895b0efc8f13138301d0a981a13d5fb86854
URL: https://github.com/llvm/llvm-project/commit/b816895b0efc8f13138301d0a981a13d5fb86854
DIFF: https://github.com/llvm/llvm-project/commit/b816895b0efc8f13138301d0a981a13d5fb86854.diff
LOG: [LLVM] Fix GetErrcMessages.cmake module for WoA
GetErrcMessages.cmake module makes use of cmake's try_run which by
default builds its sources in debug mode unless configured with
CMAKE_TRY_COMPILE_CONFIGURATION. Debug builds on Windows sometimes fail
when appropraite DLLs are not included in path. Also on Windows on Arm
machines debug builds sometimes fail to link the correct debug DLLs.
To fix this I am setting CMAKE_TRY_COMPILE_CONFIGURATION to active build
configuration of currently configured LLVM project. This makes sure we
select same build type for try_run/try_compile cmake modules as
currently configured LLVM project.
Reviewed By: zero9178
Differential Revision: https://reviews.llvm.org/D133482
Added:
Modified:
llvm/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index df4b945a2301..d9987dca43de 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -105,6 +105,20 @@ Learn more about these options in our documentation at https://llvm.org/docs/CMa
")
endif()
+# Set default build type for cmake's try_compile module.
+# CMake 3.17 or newer sets CMAKE_DEFAULT_BUILD_TYPE to one of the
+# items from CMAKE_CONFIGURATION_TYPES. Logic below can be further
+# simplified once LLVM's minimum CMake version is updated to 3.17.
+if(CMAKE_DEFAULT_BUILD_TYPE)
+ set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_DEFAULT_BUILD_TYPE})
+else()
+ if(CMAKE_CONFIGURATION_TYPES)
+ list(GET CMAKE_CONFIGURATION_TYPES 0 CMAKE_TRY_COMPILE_CONFIGURATION)
+ elseif(CMAKE_BUILD_TYPE)
+ set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
+ endif()
+endif()
+
# Side-by-side subprojects layout: automatically set the
# LLVM_EXTERNAL_${project}_SOURCE_DIR using LLVM_ALL_PROJECTS
# This allows an easy way of setting up a build directory for llvm and another
More information about the llvm-commits
mailing list