Skip to content

Commit cb50477

Browse files
[python] Initial push of the python wrapper
1 parent bb067c3 commit cb50477

5 files changed

Lines changed: 865 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ option(OPENPGL_BUILD_STATIC "Build OpenPGL as static library." OFF)
4949
option(OPENPGL_BUILD_TOOLS "Build tool applications." OFF)
5050
option(OPENPGL_BUILD_CHECK_TOOL "Build check tool application." OFF)
5151

52+
option(OPENPGL_BUILD_PYTHON "Build tool applications." ON)
53+
5254
try_compile(COMPILER_SUPPORTS_ARM_NEON "${CMAKE_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/cmake/check_arm_neon.cpp")
5355

5456
OPTION(OPENPGL_EF_RADIANCE_CACHES "Enables experimental feature (ir)radiance caches." OFF)
@@ -109,6 +111,10 @@ add_subdirectory(openpgl)
109111

110112
add_subdirectory(tools)
111113

114+
if(OPENPGL_BUILD_PYTHON)
115+
add_subdirectory(python)
116+
endif()
117+
112118
## Configure CMake find_package() config files ##
113119

114120
include(CMakePackageConfigHelpers)

python/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.4...3.18)
2+
3+
add_subdirectory(pyopengl)

python/pyopengl/CMakeLists.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
cmake_minimum_required(VERSION 3.4...3.18)
2+
project(pyopenpgl)
3+
set(CMAKE_CXX_STANDARD 14)
4+
5+
set(CMAKE_MODULE_PATH
6+
${CMAKE_MODULE_PATH}
7+
${CMAKE_CURRENT_SOURCE_DIR}/cmake
8+
)
9+
10+
set(PYOPENPGL_OPTIONS -msse2 -msse4.1 -O3 -Wall -ffp-model=precise -Wformat -Wformat-security -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-aliasing -fno-tree-vectorize)
11+
12+
add_subdirectory(../ext/pybind11 build)
13+
14+
pybind11_add_module(pyopenpgl
15+
python.cpp
16+
)
17+
18+
set_source_files_properties(python.cpp PROPERTIES COMPILE_FLAGS ${PYOPENPGL_OPTIONS})
19+
20+
#target_include_directories(libguiding PUBLIC include)
21+
target_include_directories(pyopenpgl PRIVATE ${CMAKE_INSTALL_PREFIX}/include)
22+
23+
message(STATUS "openpgl_DIR = ${openpgl_DIR}")
24+
25+
26+
27+
if (NOT ${OPENPGL_TBB_ROOT} STREQUAL "")
28+
set(TBB_FIND_PACKAGE_OPTION "NO_DEFAULT_PATH")
29+
set(TBB_ROOT ${OPENPGL_TBB_ROOT})
30+
list(APPEND CMAKE_PREFIX_PATH ${OPENPGL_TBB_ROOT})
31+
endif()
32+
33+
#find_package(TBB REQUIRED)
34+
#find_package(openpgl REQUIRED)
35+
36+
message(STATUS "TBB_INCLUDE_DIRS = ${TBB_INCLUDE_DIRS}")
37+
message(STATUS "TBB_FOUND = ${TBB_FOUND}")
38+
39+
target_link_libraries(pyopenpgl PRIVATE openpgl)
40+
target_link_libraries(pyopenpgl PRIVATE TBB::tbb)
41+
42+
set (PYOPENPGL_RPATH
43+
"$ORIGIN:$ORIGIN/..")
44+
45+
set_target_properties(pyopenpgl PROPERTIES
46+
PREFIX ""
47+
INSTALL_RPATH ${PYOPENPGL_RPATH}
48+
)
49+
50+
install(TARGETS pyopenpgl DESTINATION lib/python)
51+
52+
53+
pybind11_add_module(pyopenpgldebug
54+
pyopenpgldebug.cpp
55+
)
56+
57+
set_source_files_properties(pyopenpgldebug.cpp PROPERTIES COMPILE_FLAGS ${PYOPENPGL_OPTIONS})
58+
#target_include_directories(libguiding PUBLIC include)
59+
60+
message(STATUS "TEST=${CMAKE_CURRENT_SOURCE_DIR}/../../")
61+
62+
target_include_directories(pyopenpgldebug PRIVATE ${CMAKE_INSTALL_PREFIX}/include)
63+
target_include_directories(pyopenpgldebug PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../)
64+
target_include_directories(pyopenpgldebug PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party)
65+
66+
target_link_libraries(pyopenpgldebug PRIVATE openpgl)
67+
target_link_libraries(pyopenpgldebug PRIVATE TBB::tbb)
68+
69+
set (PYOPENPGLDEBUG_RPATH
70+
"$ORIGIN:$ORIGIN/..")
71+
72+
set_target_properties(pyopenpgldebug PROPERTIES
73+
PREFIX ""
74+
INSTALL_RPATH ${PYOPENPGLDEBUG_RPATH}
75+
)
76+
77+
install(TARGETS pyopenpgldebug DESTINATION lib/python)

0 commit comments

Comments
 (0)