-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
125 lines (106 loc) · 5.39 KB
/
CMakeLists.txt
File metadata and controls
125 lines (106 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# ==============================================================================
# KortexDL Python Bindings - Standalone CMake Configuration
# ==============================================================================
# This CMakeLists.txt allows building Python bindings independently.
# It looks for kortexdl-cpp in these locations (in order):
# 1. ./kortexdl-cpp (submodule)
# 2. ../kortexdl-cpp (sibling directory)
# 3. KORTEXDL_CPP_DIR environment variable
# ==============================================================================
cmake_minimum_required(VERSION 3.20)
project(KortexDL_Python LANGUAGES CXX)
# ==============================================================================
# Find KortexDL C++ Library
# ==============================================================================
# Check possible locations for kortexdl-cpp
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/kortexdl-cpp/CMakeLists.txt")
set(KORTEXDL_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/kortexdl-cpp")
message(STATUS "Found kortexdl-cpp as submodule: ${KORTEXDL_CPP_DIR}")
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../kortexdl-cpp/CMakeLists.txt")
set(KORTEXDL_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../kortexdl-cpp")
message(STATUS "Found kortexdl-cpp as sibling: ${KORTEXDL_CPP_DIR}")
elseif(DEFINED ENV{KORTEXDL_CPP_DIR})
set(KORTEXDL_CPP_DIR $ENV{KORTEXDL_CPP_DIR})
message(STATUS "Found kortexdl-cpp from env: ${KORTEXDL_CPP_DIR}")
else()
message(FATAL_ERROR
"Cannot find kortexdl-cpp!\n"
"Please either:\n"
" 1. Clone as submodule: git submodule add <url> kortexdl-cpp\n"
" 2. Place kortexdl-cpp as sibling directory\n"
" 3. Set KORTEXDL_CPP_DIR environment variable")
endif()
# ==============================================================================
# Environment Verification
# ==============================================================================
# Check for Intel MKL environment
if(NOT DEFINED ENV{MKLROOT})
message(FATAL_ERROR
"\n\n❌ Intel MKL not found! MKLROOT environment variable is undefined.\n"
"Please initialize the Intel oneAPI environment before building:\n"
" source /opt/intel/oneapi/setvars.sh (Linux)\n"
" source ~/intel/oneapi/setvars.sh (User install)\n"
"\n")
else()
message(STATUS "Found Intel MKL: $ENV{MKLROOT}")
endif()
# ==============================================================================
# Build C++ Core Library
# ==============================================================================
# Add the C++ project as a subdirectory
add_subdirectory(${KORTEXDL_CPP_DIR} kortexdl-cpp-build EXCLUDE_FROM_ALL)
# ==============================================================================
# Python Configuration
# ==============================================================================
find_package(Python COMPONENTS Interpreter Development REQUIRED)
find_package(pybind11 REQUIRED)
# ==============================================================================
# Python Bindings Module
# ==============================================================================
pybind11_add_module(_kortexdl_core
src/bindings/main_module.cpp
src/bindings/enums_bindings.cpp
src/bindings/exceptions_bindings.cpp
src/bindings/core_bindings.cpp
src/bindings/optimization_bindings.cpp
src/bindings/utils_bindings.cpp
src/bindings/dataframe_bindings.cpp
src/bindings/accuracy_bindings.cpp
src/bindings/diagnostics_bindings.cpp
src/bindings/layer_bindings.cpp
src/bindings/performance_bindings.cpp
src/bindings/cnn_bindings.cpp
)
# Link against nn_common from kortexdl-cpp
target_link_libraries(_kortexdl_core PRIVATE nn_common)
# Include directories
target_include_directories(_kortexdl_core PRIVATE
${KORTEXDL_CPP_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# C++20
target_compile_features(_kortexdl_core PRIVATE cxx_std_20)
# DataFrame library directory (if exists)
if(EXISTS ${KORTEXDL_CPP_DIR}/deps/DataFrame/build)
target_link_directories(_kortexdl_core PRIVATE ${KORTEXDL_CPP_DIR}/deps/DataFrame/build)
endif()
# OpenMP
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(_kortexdl_core PRIVATE OpenMP::OpenMP_CXX)
endif()
# Output location
set_target_properties(_kortexdl_core PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
# ==============================================================================
# Info
# ==============================================================================
message(STATUS "══════════════════════════════════════════════════════════════════")
message(STATUS "KortexDL Python Bindings Configuration")
message(STATUS "══════════════════════════════════════════════════════════════════")
message(STATUS "C++ Core: ${KORTEXDL_CPP_DIR}")
message(STATUS "Python: ${Python_EXECUTABLE}")
message(STATUS "pybind11: ${pybind11_VERSION}")
message(STATUS "Output: ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "══════════════════════════════════════════════════════════════════")