Skip to content

[llvm][CMake] Introduce LLVM_RUNTIME_<project>_BUILD in CMake #88934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions llvm/runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,36 @@ foreach(entry ${runtimes})
list(APPEND RUNTIME_NAMES ${name})
endforeach()

# Set LLVM_RUNTIME_<project>_BUILD variables if a sub-project is enabled to be built as
# a runtime. As with LLVM_TOOL_<project>_BUILD, the LLVM_RUNTIME_<project>_BUILD variables
# should be not directly used from the CMake configuration command line.
foreach(proj ${LLVM_SUPPORTED_RUNTIMES})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to check for each LLVM_RUNTIME_TARGETS if RUNTIMES_<triple>_LLVM_ENABLE_RUNTIMES is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I'm not qualified to answer it, though.

set(SHOULD_ENABLE_RUNTIME FALSE)
string(TOUPPER "${proj}" upper_proj)
string(REGEX REPLACE "-" "_" upper_proj ${upper_proj})
if ("${proj}" IN_LIST LLVM_ENABLE_RUNTIMES)
message(STATUS "${proj} runtime is enabled for bootstrap build")
set(SHOULD_ENABLE_RUNTIME TRUE)
set(PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}")
if(NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}")
message(FATAL_ERROR "LLVM_ENABLE_RUNTIMES requests ${proj} but directory not found: ${PROJ_DIR}")
endif()
if(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR STREQUAL "" )
set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}" CACHE PATH "" FORCE)
else()
set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}" CACHE PATH "")
endif()
else()
message(STATUS "${proj} runtime is disabled")
set(SHOULD_ENABLE_RUNTIME FALSE)
endif()
set(LLVM_BOOTSTRAP_RUNTIME_${upper_proj}_BUILD
${SHOULD_ENABLE_RUNTIME}
CACHE
BOOL "Whether to build runtime ${upper_proj} as part of LLVM" FORCE)
endforeach()
unset(SHOULD_ENABLE_RUNTIME)

function(runtime_default_target)
cmake_parse_arguments(ARG "" "" "DEPENDS;CMAKE_ARGS;PREFIXES" ${ARGN})

Expand Down
21 changes: 21 additions & 0 deletions runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@ foreach(proj ${LLVM_ENABLE_RUNTIMES})
set(LLVM_EXTERNAL_${canon_name}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
endforeach()

# Set LLVM_RUNTIME_<project>_BUILD variables if a sub-project is enabled to be built as
# a runtime. As with LLVM_TOOL_<project>_BUILD, the LLVM_RUNTIME_<project>_BUILD variables
# should be not directly used from the CMake configuration command line.
foreach(proj ${LLVM_SUPPORTED_RUNTIMES})
set(SHOULD_ENABLE_RUNTIME FALSE)
string(TOUPPER "${proj}" upper_proj)
string(REGEX REPLACE "-" "_" upper_proj ${upper_proj})
if ("${proj}" IN_LIST LLVM_ENABLE_RUNTIMES)
message(STATUS "${proj} runtime is enabled")
set(SHOULD_ENABLE_RUNTIME TRUE)
else()
message(STATUS "${proj} runtime is disabled")
set(SHOULD_ENABLE_RUNTIME FALSE)
endif()
set(LLVM_RUNTIME_${upper_proj}_BUILD
${SHOULD_ENABLE_RUNTIME}
CACHE
BOOL "Whether to build runtime ${upper_proj} as part of LLVM" FORCE)
endforeach()
unset(SHOULD_ENABLE_RUNTIME)

function(runtime_register_component name)
set_property(GLOBAL APPEND PROPERTY SUB_COMPONENTS ${name})
endfunction()
Expand Down