Skip to content

Commit

Permalink
Make build tree look more like install tree
Browse files Browse the repository at this point in the history
Also adds python version and init.py to build tree such that windows has
a chance of working with the DLL loading

Signed-off-by: Kimball Thurston <[email protected]>
  • Loading branch information
kdt3rd committed Sep 14, 2024
1 parent 4e08f52 commit 1340c90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/cmake/pythonutils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,20 @@ macro (setup_python_module)
# non-python libraries of the same name (which aren't prefixed by "lib"
# on Windows).
set_target_properties (${target_name} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python/site-packages
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python/site-packages
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$<CONFIG>/OpenImageIO
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$<CONFIG>/OpenImageIO
)

install (TARGETS ${target_name}
RUNTIME DESTINATION ${PYTHON_SITE_DIR} COMPONENT user
LIBRARY DESTINATION ${PYTHON_SITE_DIR} COMPONENT user)

add_custom_command (
TARGET ${target_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$<CONFIG>/OpenImageIO/__init__.py)

install(FILES __init__.py DESTINATION ${PYTHON_SITE_DIR})

endmacro ()
Expand Down
15 changes: 14 additions & 1 deletion src/cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,21 @@ macro (oiio_add_tests)
"OIIO_TESTSUITE_ROOT=${_testsuite}"
"OIIO_TESTSUITE_SRC=${_testsrcdir}"
"OIIO_TESTSUITE_CUR=${_testdir}"
"PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/lib/python/site-packages;$ENV{PYTHONPATH}>"
${_ats_ENVIRONMENT})
if (NOT DEFINED ENV{GITHUB_ACTIONS})
# the github actions run all the tests from the dist tree
# and do an install prior to running the tests so skip
# setting these here
if (NOT DEFINED ENV{OpenImageIO_ROOT})
# this will ensure the appropriate fonts are found
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT
"OpenImageIO_ROOT=${CMAKE_SOURCE_DIR}/src")
endif()
if (USE_PYTHON)
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT
"PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/lib/python${PYTHON_VERSION}/site-packages/$<CONFIG>;$ENV{PYTHONPATH}>")
endif()
endif()
if (NOT ${_ats_testdir} STREQUAL "")
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT
"OIIO_TESTSUITE_IMAGEDIR=${_ats_testdir}")
Expand Down

0 comments on commit 1340c90

Please sign in to comment.