Skip to content

Commit

Permalink
[BOLT][CMAKE] Use IN_LIST check
Browse files Browse the repository at this point in the history
Summary:
Address @smeenai feedback https://reviews.llvm.org/D117061#inline-1122106:
>CMake has if(IN_LIST) now, which you can use instead of the string(FIND)

IN_LIST is available since CMake 3.3 released in 2015.

Reviewed By: smeenai

FBD33590959
  • Loading branch information
aaupov committed Jan 14, 2022
1 parent bde1032 commit c34adaa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions bolt/CMakeLists.txt
Expand Up @@ -11,10 +11,8 @@ endif()

set(BOLT_INCLUDE_TESTS OFF)
if (LLVM_INCLUDE_TESTS)
string(FIND "${LLVM_ENABLE_PROJECTS}" "clang" POSITION)
if (NOT ${POSITION} EQUAL -1)
string(FIND "${LLVM_ENABLE_PROJECTS}" "lld" POSITION)
if (NOT ${POSITION} EQUAL -1)
if ("clang" IN_LIST LLVM_ENABLE_PROJECTS)
if ("lld" IN_LIST LLVM_ENABLE_PROJECTS)
set(BOLT_INCLUDE_TESTS ON)
else()
message(WARNING "Not including BOLT tests since lld is disabled")
Expand Down
6 changes: 2 additions & 4 deletions bolt/lib/Rewrite/CMakeLists.txt
Expand Up @@ -12,14 +12,12 @@ set(LLVM_LINK_COMPONENTS
Support
)

string(FIND "${LLVM_TARGETS_TO_BUILD}" "AArch64" POSITION)
if (NOT ${POSITION} EQUAL -1)
if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
list(APPEND LLVM_LINK_COMPONENTS BOLTTargetAArch64)
set(BOLT_AArch64 On)
endif()

string(FIND "${LLVM_TARGETS_TO_BUILD}" "X86" POSITION)
if (NOT ${POSITION} EQUAL -1)
if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
list(APPEND LLVM_LINK_COMPONENTS BOLTTargetX86)
set(BOLT_X64 On)
endif()
Expand Down
6 changes: 2 additions & 4 deletions bolt/lib/Target/CMakeLists.txt
@@ -1,11 +1,9 @@
string(FIND "${LLVM_TARGETS_TO_BUILD}" "X86" POSITION)
if (NOT ${POSITION} EQUAL -1)
if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
message(STATUS "Targeting X86 in llvm-bolt")
add_subdirectory(X86)
endif()

string(FIND "${LLVM_TARGETS_TO_BUILD}" "AArch64" POSITION)
if (NOT ${POSITION} EQUAL -1)
if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
message(STATUS "Targeting AArch64 in llvm-bolt")
add_subdirectory(AArch64)
endif()

0 comments on commit c34adaa

Please sign in to comment.