Skip to content

Commit 43e454e

Browse files
committed
Build nanobind with cmake
1 parent 7003f2d commit 43e454e

File tree

4 files changed

+85
-84
lines changed

4 files changed

+85
-84
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
4848
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
4949
endif()
5050

51-
add_subdirectory(src/Core)
51+
add_subdirectory(src/cil)
5252

5353
cmake_policy(POP)

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ requires = [
33
"setuptools>=64",
44
"setuptools_scm>=8",
55
"scikit-build-core>=0.10",
6-
#"ipp-devel==2021.12.*", # PyPI conflicts with conda package
6+
"nanobind",
7+
"ipp-devel>=2022.1",
8+
"ipp-static>=2022.1",
9+
"intel-openmp",
710
]
811
build-backend = "scikit_build_core.build"
912

@@ -76,7 +79,7 @@ plugins = [
7679
#"tomophantom==2.0.0", # [linux] # missing from PyPI
7780
]
7881
gpu = [
79-
"astra-toolbox>=1.9.9.dev5,<=2.1", # [not osx]
82+
"astra-toolbox", # [not osx]
8083
#"tigre>=2.4,<=2.6", # missing from PyPI
8184
]
8285
[dependency-groups]

src/cil/CMakeLists.txt

Lines changed: 78 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,78 @@
1-
<<<<<<< Conflict 1 of 1
2-
+++++++ Contents of side #1
3-
%%%%%%% Changes from base to side #2
4-
# Copyright 2019 United Kingdom Research and Innovation
5-
# Copyright 2019 The University of Manchester
6-
#
7-
# Licensed under the Apache License, Version 2.0 (the "License");
8-
# you may not use this file except in compliance with the License.
9-
# You may obtain a copy of the License at
10-
#
11-
# http://www.apache.org/licenses/LICENSE-2.0
12-
#
13-
# Unless required by applicable law or agreed to in writing, software
14-
# distributed under the License is distributed on an "AS IS" BASIS,
15-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16-
# See the License for the specific language governing permissions and
17-
# limitations under the License.
18-
#
19-
# Authors:
20-
# CIL Developers, listed at: https://github.com/TomographicImaging/CIL/blob/master/NOTICE.txt
21-
set (CMAKE_CXX_STANDARD 11)
22-
set (CMAKE_CXX_STANDARD_REQUIRED ON)
23-
if(NOT DEFINED CMAKE_BUILD_TYPE)
24-
set(CMAKE_BUILD_TYPE RelWithDebInfo)
25-
endif()
26-
27-
message ("OpenMP_CXX_FLAGS ${OpenMP_CXX_FLAGS}")
28-
find_package(OpenMP REQUIRED)
29-
add_definitions(${OpenMP_CXX_FLAGS})
30-
31-
if (WIN32)
32-
add_definitions("/Ddll_EXPORTS")
33-
endif()
34-
+find_package(IPP REQUIRED CONFIG)
35-
+find_package(OpenMP REQUIRED)
36-
37-
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNUCC")
38-
# appends some flags
39-
add_compile_options(-ftree-vectorize -fopt-info-vec-optimized -fopt-info-vec)
40-
# add_compile_options(-march=native -mavx )
41-
endif()
42-
43-
message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
44-
message("CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}")
45-
message("CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}")
46-
message("CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS}")
47-
48-
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.9.0")
49-
set (OpenMP_EXE_LINKER_FLAGS OpenMP::OpenMP_CXX)
50-
else()
51-
message(WARNING "Your CMake version is old. OpenMP linking flags might be incorrect.")
52-
# need to explicitly set this. Definitely for gcc, hopefully also for other systems.
53-
# See https://gitlab.kitware.com/cmake/cmake/issues/15392
54-
set (OpenMP_EXE_LINKER_FLAGS ${OpenMP_C_FLAGS})
55-
endif()
56-
57-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
58-
find_package(IPP)
59-
60-
list(APPEND cilacc_SOURCES utilities.cpp axpby.cpp FiniteDifferenceLibrary.cpp)
61-
list(APPEND cilacc_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include)
62-
list(APPEND cilacc_LIBRARIES ${OpenMP_EXE_LINKER_FLAGS})
63-
64-
if(IPP_FOUND)
65-
list(APPEND cilacc_SOURCES FBP_filtering.cpp Binning.cpp)
66-
list(APPEND cilacc_INCLUDES ${IPP_INCLUDE_DIRS})
67-
list(APPEND cilacc_LIBRARIES ${IPP_LIBRARIES})
68-
else()
69-
message(WARNING "IPP libraries not found, FBP_filtering not in build")
70-
endif()
71-
72-
add_library(cilacc SHARED ${cilacc_SOURCES})
73-
target_link_libraries(cilacc ${cilacc_LIBRARIES})
74-
include_directories(cilacc PUBLIC ${cilacc_INCLUDES})
75-
76-
install(TARGETS cilacc
77-
LIBRARY DESTINATION ${SKBUILD_PROJECT_NAME}/lib
78-
RUNTIME DESTINATION ${SKBUILD_PROJECT_NAME}/lib)
79-
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
80-
DESTINATION ${SKBUILD_PROJECT_NAME}/include/${SKBUILD_PROJECT_NAME})
81-
>>>>>>> Conflict 1 of 1 ends
1+
# Copyright 2019 United Kingdom Research and Innovation
2+
# Copyright 2019 The University of Manchester
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, software
11+
# 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 and
14+
# limitations under the License.
15+
#
16+
# Authors:
17+
# CIL Developers, listed at: https://github.com/TomographicImaging/CIL/blob/master/NOTICE.txt
18+
set (CMAKE_CXX_STANDARD 11)
19+
set (CMAKE_CXX_STANDARD_REQUIRED ON)
20+
if(NOT DEFINED CMAKE_BUILD_TYPE)
21+
set(CMAKE_BUILD_TYPE RelWithDebInfo)
22+
endif()
23+
find_package(Python 3.8 COMPONENTS Interpreter Development.Module REQUIRED)
24+
25+
find_package(nanobind CONFIG REQUIRED)
26+
27+
find_package(IPP REQUIRED CONFIG)
28+
find_package(OpenMP REQUIRED)
29+
30+
31+
32+
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNUCC")
33+
# appends some flags
34+
add_compile_options(-ftree-vectorize -fopt-info-vec-optimized -fopt-info-vec)
35+
# add_compile_options(-march=native -mavx )
36+
endif()
37+
38+
message ("OpenMP_CXX_FLAGS ${OpenMP_CXX_FLAGS}")
39+
#add_definitions(${OpenMP_CXX_FLAGS})
40+
41+
message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
42+
message("CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}")
43+
message("CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}")
44+
message("CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS}")
45+
46+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.9.0")
47+
set (OpenMP_EXE_LINKER_FLAGS OpenMP::OpenMP_CXX)
48+
else()
49+
message(WARNING "Your CMake version is old. OpenMP linking flags might be incorrect.")
50+
# need to explicitly set this. Definitely for gcc, hopefully also for other systems.
51+
# See https://gitlab.kitware.com/cmake/cmake/issues/15392
52+
set (OpenMP_EXE_LINKER_FLAGS ${OpenMP_C_FLAGS})
53+
endif()
54+
55+
list(APPEND cilacc_SOURCES utilities.cpp axpby.cpp FiniteDifferenceLibrary.cpp nanobind.cpp)
56+
list(APPEND cilacc_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include)
57+
list(APPEND cilacc_LIBRARIES ${OpenMP_EXE_LINKER_FLAGS})
58+
59+
if(IPP_FOUND)
60+
list(APPEND cilacc_SOURCES FBP_filtering.cpp Binning.cpp)
61+
list(APPEND cilacc_INCLUDES ${IPP_INCLUDE_DIRS})
62+
list(APPEND cilacc_LIBRARIES ${IPP_LIBRARIES})
63+
message(STATUS "IPP Libraries Found")
64+
else()
65+
message(WARNING "IPP libraries not found, FBP_filtering not in build")
66+
endif()
67+
message(STATUS ${cilacc_INCLUDES})
68+
message(STATUS ${IPP_LIBRARIES})
69+
70+
nanobind_add_module(
71+
cilacc
72+
NB_STATIC
73+
${cilacc_SOURCES}
74+
)
75+
include_directories(cilacc PUBLIC ${cilacc_INCLUDES})
76+
target_link_libraries(cilacc PUBLIC ${cilacc_LIBRARIES})
77+
78+
install(TARGETS cilacc LIBRARY DESTINATION cil)

src/cil/include/FBP_filtering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <iostream>
2020
#include <stdio.h>
2121
#include "ipp.h"
22+
#include <ipp.h>
2223
#include <chrono>
2324
#include <omp.h>
2425
#include <random>

0 commit comments

Comments
 (0)