summaryrefslogtreecommitdiff
path: root/flang/CMakeLists.txt
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-01-19 06:45:07 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-01-20 18:59:17 +0000
commitdf31ff1b29bc4c2308ec5df8a7ff0ec2ab0942d4 (patch)
tree159a5c483a888749edd6e0840429ba43e7d73b5c /flang/CMakeLists.txt
parentc65186c89f35b7b599c41183def666a2bde62ddd (diff)
downloadllvm-df31ff1b29bc4c2308ec5df8a7ff0ec2ab0942d4.tar.gz
[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
Diffstat (limited to 'flang/CMakeLists.txt')
-rw-r--r--flang/CMakeLists.txt10
1 files changed, 7 insertions, 3 deletions
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index abb9a47d3abb..5caa79e8da47 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -7,8 +7,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF)
-include(GNUInstallDirs)
-
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
@@ -27,7 +25,14 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message("Building Flang as a standalone project.")
project(Flang)
set(FLANG_STANDALONE_BUILD ON)
+else()
+ set(FLANG_STANDALONE_BUILD OFF)
+endif()
+
+# Must go below project(..)
+include(GNUInstallDirs)
+if (FLANG_STANDALONE_BUILD)
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
if (NOT MSVC_IDE)
set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
@@ -179,7 +184,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
else()
- set(FLANG_STANDALONE_BUILD OFF)
option(FLANG_INCLUDE_TESTS
"Generate build targets for the Flang unit tests."
${LLVM_INCLUDE_TESTS})