diff --git a/CMakeLists.txt b/CMakeLists.txt index 1114643a5..ccbe7ccb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,8 @@ set(CMAKE_CXX_STANDARD 17) # Project options #------------------------------------------------------------------------------- +option(TORCH_MLIR_USE_INSTALLED_PYTORCH "If depending on PyTorch use it as installed in the current Python environment" ON) + option(TORCH_MLIR_ENABLE_REFBACKEND "Enable reference backend" ON) if(TORCH_MLIR_ENABLE_REFBACKEND) add_definitions(-DTORCH_MLIR_ENABLE_REFBACKEND) diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 2838570a8..4b54be65a 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -12,6 +12,9 @@ if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OR TORCH_MLIR_ENABLE_LTC) # Assume it is a sibling to the overall project. set(Torch_DIR "${PROJECT_SOURCE_DIR}/../libtorch/share/cmake/Torch") message(STATUS "Attempting to locate libtorch as a sibling to the project: ${Torch_DIR}") + if(NOT EXISTS "${Torch_DIR}") + message(FATAL_ERROR "Without TORCH_MLIR_USE_INSTALLED_PYTORCH, expected to find Torch configuration at ${Torch_DIR}, which does not exist") + endif() endif() find_package(Torch 1.11 REQUIRED) @@ -23,7 +26,13 @@ if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OR TORCH_MLIR_ENABLE_LTC) ${Python3_INCLUDE_DIRS} ) link_directories("${TORCH_INSTALL_PREFIX}/lib") - message(STATUS "libtorch_python CXXFLAGS is ...${TORCH_CXXFLAGS}") + message(STATUS "TORCH_CXXFLAGS is = ${TORCH_CXXFLAGS}") + if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT TORCH_CXXFLAGS) + message(WARNING + "When building on Linux TORCH_CXXFLAGS are almost always required but were not detected. " + "It is very likely this this will produce a non-functional installation. " + "See notes in build_tools/cmake/TorchMLIRPyTorch.cmake.") + endif() message(STATUS "TORCH_LIBRARIES = ${TORCH_LIBRARIES}") endif() diff --git a/projects/pt1/python/CMakeLists.txt b/projects/pt1/python/CMakeLists.txt index 23dd5be40..e951772df 100644 --- a/projects/pt1/python/CMakeLists.txt +++ b/projects/pt1/python/CMakeLists.txt @@ -15,8 +15,6 @@ add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=torch_mlir.") # PyTorch ################################################################################ -option(TORCH_MLIR_USE_INSTALLED_PYTORCH "Build from local PyTorch in environment" ON) - if (NOT TORCH_MLIR_USE_INSTALLED_PYTORCH) # Source builds set(ENV{TORCH_MLIR_SRC_PYTORCH_REPO} ${TORCH_MLIR_SRC_PYTORCH_REPO})