1+ ################################################################################
2+ # Copyright (C) 2024 Intel Corporation
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing,
11+ # software distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions
14+ # and limitations under the License.
15+ # SPDX-License-Identifier: Apache-2.0
16+ ################################################################################
17+
118cmake_minimum_required (VERSION 3.20)
219project (GraphCompiler VERSION "0.1.0" LANGUAGES C CXX)
320
@@ -10,6 +27,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
1027
1128option (GC_LEGACY_ENABLE ON )
1229option (GC_TEST_ENABLE "Build the tests" ON )
30+ option (GC_ENABLE_BINDINGS_PYTHON "Enable Graph Complier Python Binding" ON )
1331option (GC_DEV_LINK_LLVM_DYLIB "Link dynamic libraries of LLVM and MLIR. For developers only. Do not use it in packing the library." OFF )
1432
1533if (GC_LEGACY_ENABLE)
@@ -33,6 +51,16 @@ include(AddLLVM)
3351include (AddMLIR)
3452include (HandleLLVMOptions)
3553
54+ if (GC_ENABLE_BINDINGS_PYTHON AND NOT MLIR_ENABLE_BINDINGS_PYTHON)
55+ message (STATUS "Failed to enable Python API due to the 'MLIR_ENABLE_BINDINGS_PYTHON' for LLVM is not ON." )
56+ set (GC_ENABLE_BINDINGS_PYTHON OFF CACHE BOOL "" FORCE)
57+ endif ()
58+
59+ if (GC_ENABLE_BINDINGS_PYTHON)
60+ include (MLIRDetectPythonEnv)
61+ mlir_configure_python_dev_packages()
62+ endif ()
63+
3664include_directories (
3765 ${LLVM_INCLUDE_DIRS}
3866 ${MLIR_INCLUDE_DIRS}
@@ -61,6 +89,10 @@ include("cmake/version.cmake")
6189add_subdirectory (include )
6290add_subdirectory (lib)
6391add_subdirectory (src)
92+ if (GC_ENABLE_BINDINGS_PYTHON)
93+ message (STATUS "Enabling Python API" )
94+ add_subdirectory (python)
95+ endif ()
6496
6597set (GC_LIB_LINKED_LIBS
6698 MLIRLinalgx
0 commit comments