-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
121 lines (98 loc) · 3.97 KB
/
CMakeLists.txt
File metadata and controls
121 lines (98 loc) · 3.97 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
cmake_minimum_required(VERSION 3.19)
project(actionet_python VERSION 0.1.0 LANGUAGES CXX)
# ==============================================================================
# Build Configuration
# ==============================================================================
# C++ standard (must match libactionet)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Export compile commands for IDE integration
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# ==============================================================================
# Platform-Specific Configuration
# ==============================================================================
if(APPLE)
# macOS: Support macOS >= 11.0 for both x86_64 and arm64
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_INSTALL_RPATH "@loader_path")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS version")
endif()
# Architecture is typically set by scikit-build-core
if(NOT CMAKE_OSX_ARCHITECTURES)
execute_process(
COMMAND uname -m
OUTPUT_VARIABLE NATIVE_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CMAKE_OSX_ARCHITECTURES ${NATIVE_ARCH} CACHE STRING "macOS architectures")
endif()
message(STATUS "Building for macOS ${CMAKE_OSX_DEPLOYMENT_TARGET}, arch: ${CMAKE_OSX_ARCHITECTURES}")
elseif(UNIX AND NOT APPLE)
# Linux: manylinux2014 compatibility (glibc 2.17+)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# Ensure compatibility with older glibc
add_compile_options(-fno-gnu-unique)
message(STATUS "Building for Linux (manylinux2014 compatible)")
endif()
# ==============================================================================
# Dependencies
# ==============================================================================
# Python and pybind11
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)
# Validate libactionet submodule
set(LIBACTIONET_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/libactionet")
if(NOT EXISTS "${LIBACTIONET_DIR}/include/libactionet.hpp")
message(FATAL_ERROR
"libactionet submodule not initialized. Run:\n"
" git submodule update --init --recursive"
)
endif()
# Build libactionet static library
# This configures BLAS, LAPACK, OpenMP, and Armadillo
add_subdirectory("${LIBACTIONET_DIR}")
# ==============================================================================
# Python Extension Module
# ==============================================================================
# Define Python wrapper sources
set(WRAPPER_SOURCES
src/actionet/_core.cpp
src/actionet/wp_utils.cpp
src/actionet/wp_action.cpp
src/actionet/wp_network.cpp
src/actionet/wp_annotation.cpp
src/actionet/wp_decomposition.cpp
src/actionet/wp_io.cpp
src/actionet/wp_tools.cpp
src/actionet/wp_visualization.cpp
)
# Create pybind11 extension module
pybind11_add_module(_core MODULE ${WRAPPER_SOURCES})
# Set target properties
set_target_properties(_core PROPERTIES
CXX_VISIBILITY_PRESET hidden
INTERPROCEDURAL_OPTIMIZATION TRUE
)
# Include directories
# Must include libactionet headers and its external dependencies (Armadillo, etc.)
target_include_directories(_core PRIVATE
${LIBACTIONET_DIR}/include
${LIBACTIONET_DIR}/include/extern
${LIBACTIONET_DIR}/include/extern/armadillo
)
# Link against libactionet
# This provides access to all libactionet functions and transitively links
# BLAS, LAPACK, and OpenMP (required)
target_link_libraries(_core PRIVATE actionet)
# ==============================================================================
# Installation
# ==============================================================================
install(TARGETS _core
LIBRARY DESTINATION actionet
COMPONENT python_module
)