[cmake] Make include(GNUInstallDirs) always below project(..)
Its defaulting logic must go after `project(..)` to work correctly, but `project(..)` is often in a standalone condition making this
awkward, since the rest of the condition code may also need GNUInstallDirs.
The good thing is there are the various standalone booleans, which I had missed before. This makes splitting the conditional blocks less awkward.
Reviewed By: arichardson, phosek, beanz, ldionne, #libunwind, #libc, #libc_abi
Differential Revision: https://reviews.llvm.org/D117639
GitOrigin-RevId: df31ff1b29bc4c2308ec5df8a7ff0ec2ab0942d4
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 78f4864..ecbc709 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,8 +10,6 @@
cmake_minimum_required(VERSION 3.13.4)
-include(GNUInstallDirs)
-
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
# Add path for custom modules
@@ -37,17 +35,21 @@
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
+ set(LIBCXXABI_STANDALONE_BUILD TRUE)
+
# In a standalone build, we don't have llvm to automatically generate the
# llvm-lit script for us. So we need to provide an explicit directory that
# the configurator should write the script into.
- set(LIBCXXABI_STANDALONE_BUILD 1)
set(LLVM_LIT_OUTPUT_DIR "${LIBCXXABI_BINARY_DIR}/bin")
-
- # Find the LLVM sources and simulate LLVM CMake options.
- include(HandleOutOfTreeLLVM)
endif()
+# Must go below project(..)
+include(GNUInstallDirs)
+
if (LIBCXXABI_STANDALONE_BUILD)
+ # Find the LLVM sources and simulate LLVM CMake options.
+ include(HandleOutOfTreeLLVM)
+
find_package(Python3 COMPONENTS Interpreter)
if(NOT Python3_Interpreter_FOUND)
message(WARNING "Python3 not found, using python2 as a fallback")