Skip to content

Commit

Permalink
change the build command to remove the requirement of llvm-config pat…
Browse files Browse the repository at this point in the history
…h, and support using CUDA_PATH from environment variable
  • Loading branch information
drcut committed Aug 6, 2024
1 parent 70168ce commit 6bf0075
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ project(CuPBoP)
set(CMAKE_PROJECT_DESCRIPTION "Executing CUDA on non-NVIDIA architecture.")
set(CMAKE_CXX_STANDARD "14")

if(DEFINED LLVM_CONFIG_PATH)
if(EXISTS "${LLVM_CONFIG_PATH}")
set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
else()
message(FATAL_ERROR "llvm-config is not found in ${LLVM_CONFIG_PATH}")
endif()
message(STATUS "Using llvm-config: ${LLVM_CONFIG}")
find_program(LLVM_CONFIG llvm-config)
if(NOT LLVM_CONFIG)
message(FATAL_ERROR "llvm-config not found. Please install LLVM.")
else()
message(STATUS "Found llvm-config: ${LLVM_CONFIG}")
execute_process(
COMMAND "${LLVM_CONFIG}" "--cxxflags"
OUTPUT_VARIABLE LLVM_CXX_FLAG
Expand All @@ -23,14 +21,16 @@ if(DEFINED LLVM_CONFIG_PATH)
COMMAND "${LLVM_CONFIG}" "--libs"
OUTPUT_VARIABLE LLVM_LINK_FLAG
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
message(FATAL_ERROR "llvm-config is required")
endif()

if(DEFINED CUDA_PATH)
message(STATUS "Using CUDA: ${CUDA_PATH}")
message(STATUS "CUDA_PATH provided: ${CUDA_PATH}")
elseif(DEFINED ENV{CUDA_PATH})
set(CUDA_PATH $ENV{CUDA_PATH})
message(STATUS "CUDA_PATH from environment: ${CUDA_PATH}")
else()
message(FATAL_ERROR "CUDA_PATH is required")
message(FATAL_ERROR "CUDA_PATH is not provided. Please set CUDA_PATH or
define it as an environment variable.")
endif()

option(DEBUG "Print debug information." OFF)
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ For building CUDA toolkit, please refer to <https://developer.nvidia.com/cuda-do
```bash
mkdir build && cd build
#set -DDEBUG=ON for debugging
cmake .. \
-DLLVM_CONFIG_PATH=`which llvm-config` \
-DCUDA_PATH=$CUDA_PATH
cmake ..
make
```

Expand Down

0 comments on commit 6bf0075

Please sign in to comment.