Skip to content

Commit

Permalink
Support using k2 by specifying its build path. (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Jul 4, 2022
1 parent 6e596dc commit 2101e0f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions cmake/k2.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# PYTHON_EXECUTABLE is set by cmake/pybind11.cmake
message(STATUS "Python executable: ${PYTHON_EXECUTABLE}")

execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "import k2; print(k2.cmake_prefix_path)"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE K2_CMAKE_PREFIX_PATH
)
if(DEFINED ENV{K2_INSTALL_PREFIX})
message(STATUS "Using environment variable K2_INSTALL_PREFIX: $ENV{K2_INSTALL_PREFIX}")
set(K2_CMAKE_PREFIX_PATH $ENV{K2_INSTALL_PREFIX})
else()
# PYTHON_EXECUTABLE is set by cmake/pybind11.cmake
message(STATUS "Python executable: ${PYTHON_EXECUTABLE}")

execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "import k2; print(k2.cmake_prefix_path)"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE K2_CMAKE_PREFIX_PATH
)
endif()

message(STATUS "K2_CMAKE_PREFIX_PATH: ${K2_CMAKE_PREFIX_PATH}")
list(APPEND CMAKE_PREFIX_PATH "${K2_CMAKE_PREFIX_PATH}")
Expand Down

0 comments on commit 2101e0f

Please sign in to comment.