-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
86 lines (73 loc) · 2.6 KB
/
Copy pathCMakeLists.txt
File metadata and controls
86 lines (73 loc) · 2.6 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
cmake_minimum_required(VERSION 3.15)
file(READ "${PROJECT_VERSION_FILE}" VERSION_CONTENTS)
string(REGEX MATCH "__version__ *= *[\"']([^\"']+)[\"']" _ ${VERSION_CONTENTS})
set(PYTHON_VERSION_STRING "${CMAKE_MATCH_1}")
project(differintC VERSION ${PYTHON_VERSION_STRING} LANGUAGES CXX)
# Set compiler optimization flags
if(MSVC)
add_compile_options(/O2 /fp:fast /arch:AVX2)
else()
add_compile_options(-O3 -march=native -ffast-math)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Robust FFTW setup
# set(FFTW_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/fftw")
# set(FFTW_INCLUDE_DIRS "${FFTW_ROOT}/include")
#
# # Check if we're in a temporary build directory
# if(NOT EXISTS "${FFTW_ROOT}/lib/libfftw3-3.lib")
# # Try to find FFTW in the source directory
# set(FFTW_ROOT_SOURCE "${CMAKE_SOURCE_DIR}/thirdparty/fftw")
# if(EXISTS "${FFTW_ROOT_SOURCE}/lib/libfftw3-3.lib")
# set(FFTW_ROOT "${FFTW_ROOT_SOURCE}")
# set(FFTW_INCLUDE_DIRS "${FFTW_ROOT}/include")
# message(STATUS "Using source FFTW directory: ${FFTW_ROOT}")
# else()
# # Fallback to system FFTW
# find_package(FFTW)
# if(FFTW_FOUND)
# message(STATUS "Using system FFTW")
# set(FFTW_LIBRARIES ${FFTW_LIBRARIES})
# else()
# message(FATAL_ERROR "FFTW not found! Please install FFTW or check the thirdparty directory.")
# endif()
# endif()
# endif()
# Use bundled FFTW from thirdparty
set(FFTW_ROOT "${CMAKE_SOURCE_DIR}/thirdparty/fftw")
set(FFTW_INCLUDE_DIRS "${FFTW_ROOT}/include")
if(WIN32)
set(FFTW_LIBRARIES "${FFTW_ROOT}/lib/libfftw3-3.lib")
else()
set(FFTW_LIBRARIES "${FFTW_ROOT}/lib/libfftw3.so")
endif()
# Optional sanity check
if(NOT EXISTS "${FFTW_LIBRARIES}")
message(FATAL_ERROR "Missing FFTW library at: ${FFTW_LIBRARIES}")
endif()
##########################################
if(WIN32)
set(FFTW_LIBRARIES "${FFTW_ROOT}/lib/libfftw3-3.lib")
else()
set(FFTW_LIBRARIES "${FFTW_ROOT}/lib/libfftw3.so")
endif()
# Pybind11
include(FetchContent)
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.11.0
)
FetchContent_MakeAvailable(pybind11)
# Core C++ Library
add_library(differint_core src/differint.cpp)
target_include_directories(differint_core PUBLIC
${CMAKE_SOURCE_DIR}/include
${FFTW_INCLUDE_DIRS}
)
target_link_libraries(differint_core PRIVATE ${FFTW_LIBRARIES})
# Add Python bindings
add_subdirectory(python)
# Mark installation component for scikit-build
install(CODE "message(STATUS \"Installing differintC component\")" COMPONENT python)