Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 66 additions & 66 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
set(CMAKE_OSX_ARCHITECTURES x86_64;arm64 CACHE INTERNAL "archs for osx")
cmake_minimum_required(VERSION 3.16)
project(ChebTools)
# Set the standard for C++ to c++17
set(CMAKE_CXX_STANDARD 17)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/externals/Eigen")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/externals/Catch")
set(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/ChebTools.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/speed_tests.cpp")
if (MSVC)
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/externals/Eigen/debug/msvc/eigen.natvis")
endif()
option(CHEBTOOLS_NANOBIND False "")
option(CHEBTOOLS_PYBIND11 False "")
set(OPENMP_NEEDED False)
if (OPENMP_NEEDED)
# Check for the existence of OpenMP and enable it as needed
set(CMAKE_OSX_ARCHITECTURES x86_64;arm64 CACHE INTERNAL "archs for osx")
cmake_minimum_required(VERSION 3.16)

project(ChebTools)

# Set the standard for C++ to c++17
set(CMAKE_CXX_STANDARD 17)

include_directories("${CMAKE_CURRENT_SOURCE_DIR}/externals/Eigen")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/externals/Catch")

set(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/ChebTools.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/speed_tests.cpp")

if (MSVC)
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/externals/Eigen/debug/msvc/eigen.natvis")
endif()

option(CHEBTOOLS_NANOBIND False "")
option(CHEBTOOLS_PYBIND11 False "")

set(OPENMP_NEEDED False)
if (OPENMP_NEEDED)
# Check for the existence of OpenMP and enable it as needed
# see also http://stackoverflow.com/a/12404666/1360263
find_package(OpenMP)
endif()
Expand All @@ -44,23 +44,23 @@ endif()

if (CHEBTOOLS_STATIC_LIBRARY OR NISTFIT_PYBIND11)
add_library(ChebTools STATIC ${SOURCES})
# Add target include directories for easy linking with other applications
target_include_directories(ChebTools PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
if (OPENMP_NEEDED)
target_link_libraries(ChebTools PUBLIC OpenMP::OpenMP_CXX)
endif()
else()
if (CHEBTOOLS_PYBIND11)
if (CHEBTOOLS_NANOBIND)
message(FATAL_ERROR "only one python binding can be enabled")
endif()
# Build pybind11 python module
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/externals/pybind11")
pybind11_add_module(ChebTools "${CMAKE_CURRENT_SOURCE_DIR}/src/pybind11_wrapper.cpp" ${SOURCES})
target_compile_definitions(ChebTools PUBLIC -DPYBIND11)
if (OPENMP_NEEDED)
target_link_libraries(ChebTools PUBLIC OpenMP::OpenMP_CXX)
endif()
# Add target include directories for easy linking with other applications
target_include_directories(ChebTools PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
if (OPENMP_NEEDED)
target_link_libraries(ChebTools PUBLIC OpenMP::OpenMP_CXX)
endif()
else()
if (CHEBTOOLS_PYBIND11)
if (CHEBTOOLS_NANOBIND)
message(FATAL_ERROR "only one python binding can be enabled")
endif()
# Build pybind11 python module
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/externals/pybind11")
pybind11_add_module(ChebTools "${CMAKE_CURRENT_SOURCE_DIR}/src/pybind11_wrapper.cpp" ${SOURCES})
target_compile_definitions(ChebTools PUBLIC -DPYBIND11)
if (OPENMP_NEEDED)
target_link_libraries(ChebTools PUBLIC OpenMP::OpenMP_CXX)
endif()
endif()

if (CHEBTOOLS_NANOBIND)
Expand All @@ -70,14 +70,14 @@ else()
endif()
# Build nanobind python module
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/externals/nanobind")
nanobind_add_module(ChebTools "${CMAKE_CURRENT_SOURCE_DIR}/src/nanobind_wrapper.cpp" ${SOURCES})
nanobind_add_module(ChebTools_ext "${CMAKE_CURRENT_SOURCE_DIR}/src/nanobind_wrapper.cpp" ${SOURCES})
set(NAME ChebTools)
nanobind_add_stub(
ChebTools_stub
MODULE ChebTools
MODULE ChebTools_ext
OUTPUT "${CMAKE_SOURCE_DIR}/src/ChebTools/ChebTools.pyi"
PYTHON_PATH $<TARGET_FILE_DIR:ChebTools>
DEPENDS ChebTools
PYTHON_PATH $<TARGET_FILE_DIR:ChebTools_ext>
DEPENDS ChebTools_ext
MARKER_FILE py.typed
VERBOSE
)
Expand All @@ -90,27 +90,27 @@ else()
target_link_libraries(ChebTools PUBLIC OpenMP::OpenMP_CXX)
endif()
message(STATUS "Added nanobind interface")
install(TARGETS ChebTools LIBRARY DESTINATION ChebTools)
install(TARGETS ChebTools_ext LIBRARY DESTINATION ChebTools)
endif()

if (NOT CHEBTOOLS_NO_MONOLITH)
# Also build monolithic exe
add_executable(ChebToolsMonolith "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ${SOURCES})
if (OPENMP_NEEDED)
target_link_libraries(ChebToolsMonolith PUBLIC OpenMP::OpenMP_CXX)
endif()
endif()
if (NOT CHEBTOOLS_NO_CATCH)
# Also build Catch testing module
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/externals/Catch")
add_executable(ChebToolsCatchTests "${CMAKE_CURRENT_SOURCE_DIR}/tests/tests.cpp" ${SOURCES})
if (OPENMP_NEEDED)
target_link_libraries(ChebToolsCatchTests PUBLIC OpenMP::OpenMP_CXX)
endif()
target_link_libraries(ChebToolsCatchTests PUBLIC Catch2WithMain)
endif()
endif()
add_subdirectory("scripts/Basu")
# Also build monolithic exe
add_executable(ChebToolsMonolith "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ${SOURCES})
if (OPENMP_NEEDED)
target_link_libraries(ChebToolsMonolith PUBLIC OpenMP::OpenMP_CXX)
endif()
endif()

if (NOT CHEBTOOLS_NO_CATCH)
# Also build Catch testing module
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/externals/Catch")
add_executable(ChebToolsCatchTests "${CMAKE_CURRENT_SOURCE_DIR}/tests/tests.cpp" ${SOURCES})
if (OPENMP_NEEDED)
target_link_libraries(ChebToolsCatchTests PUBLIC OpenMP::OpenMP_CXX)
endif()
target_link_libraries(ChebToolsCatchTests PUBLIC Catch2WithMain)
endif()

endif()

add_subdirectory("scripts/Basu")
17 changes: 11 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["scikit-build-core >=0.4.3", "nanobind >=1.3.2", "typing_extensions"]
requires = ["scikit-build-core >=0.10", "nanobind >=1.3.2", "typing_extensions"]
build-backend = "scikit_build_core.build"

[project]
Expand All @@ -11,27 +11,32 @@ version = "1.13.0"
authors = [
{ name = "Ian Bell", email = "ian.bell@nist.gov" },
]
dependencies = [
"numpy>=1.24.4",
]
#classifiers = [
# "License :: BSD",
#]

[project.urls]
Homepage = "https://github.com/usnistgov/teqpflsh"
Homepage = "https://github.com/usnistgov/ChebTools"

[tool.scikit-build]
# Protect the configuration against future changes in scikit-build-core
minimum-version = "0.4"
minimum-version = "build-system.requires"

# Setuptools-style build caching in a local directory
build-dir = "build/{wheel_tag}"

# Build stable ABI wheels for CPython 3.12+
wheel.py-api = "cp312"

cmake.verbose = true
build.verbose = true
#cmake.build-type = "Debug"
#cmake.args = ["-G Xcode", "-DXCODE_DEBUG_PYTHON=ON"]
#cmake.args = ["-DVERBOSE=ON"]

cmake.args = ["-DCHEBTOOLS_NO_MONOLITH=ON","-DCHEBTOOLS_NO_CATCH=ON", "-DCHEBTOOLS_NANOBIND=ON"]

[tool.scikit-build.cmake.define]
CHEBTOOLS_NO_MONOLITH = true
CHEBTOOLS_NO_CATCH = true
CHEBTOOLS_NANOBIND = true
4 changes: 2 additions & 2 deletions src/ChebTools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .ChebTools import *
from .ChebTools import __version__, __doc__ # the __doc__ is required to get the .doc() to work properly
from .ChebTools_ext import *
from .ChebTools_ext import __version__, __doc__ # the __doc__ is required to get the .doc() to work properly
2 changes: 1 addition & 1 deletion src/nanobind_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void init_ChebTools(nb::module_ &m){
m.def("Clenshaw2DEigencomplex", &Clenshaw2DEigen<Eigen::Ref<const Eigen::ArrayXXcd>>, "cmat"_a.noconvert(), "x"_a, "y"_a);
}

NB_MODULE(ChebTools, m) {
NB_MODULE(ChebTools_ext, m) {
m.doc() = "C++ tools for working with Chebyshev expansions";
m.attr("__version__") = CHEBTOOLSVERSION;
init_ChebTools(m);
Expand Down
Loading
Loading