Skip to content

Commit

Permalink
Fix issues with rpath, message cleanup, checkpoint better python layer
Browse files Browse the repository at this point in the history
Signed-off-by: Kimball Thurston <[email protected]>
  • Loading branch information
kdt3rd committed Jul 17, 2019
1 parent 6e3ba4e commit 9781367
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 89 deletions.
4 changes: 2 additions & 2 deletions IlmBase/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ install(
install(TARGETS IlmBaseConfig EXPORT ${PROJECT_NAME})
add_library(IlmBase::Config ALIAS IlmBaseConfig)

cmake_dependent_option(INSTALL_PKG_CONFIG "Install IlmBase.pc file" ON "WIN32" OFF)
if(INSTALL_PKG_CONFIG)
cmake_dependent_option(ILMBASE_INSTALL_PKG_CONFIG "Install IlmBase.pc file" ON "WIN32" OFF)
if(ILMBASE_INSTALL_PKG_CONFIG)
# use a helper function to avoid variable pollution, but pretty simple
function(ilmbase_pkg_config_help pcinfile)
set(prefix ${CMAKE_INSTALL_PREFIX})
Expand Down
21 changes: 19 additions & 2 deletions IlmBase/config/IlmBaseSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,29 @@ set(ILMBASE_LIB_SUFFIX "-${ILMBASE_VERSION_API}" CACHE STRING "string added to t
# would use -lImath_static (or target_link_libraries(xxx IlmBase::Imath_static))
set(ILMBASE_STATIC_LIB_SUFFIX "_static" CACHE STRING "When building both static and shared, name to append to static library (in addition to normal suffix)")

# rpath related setup - if the user sets an install rpath
# rpath related setup
# make sure we force an rpath to the rpath we're compiling
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# adds the automatically determined parts of the rpath
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# if the user sets an install rpath
# then just use that, or otherwise set one for them
if(NOT CMAKE_INSTALL_RPATH)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
if("${CMAKE_SYSTEM}" MATCHES "Linux")
get_filename_component(tmpSysPath "${CMAKE_INSTALL_FULL_LIBDIR}" NAME)
if(NOT tmpSysPath)
set(tmpSysPath "lib")
endif()
set(CMAKE_INSTALL_RPATH "\\\$ORIGIN/../${tmpSysPath}:${CMAKE_INSTALL_FULL_LIBDIR}")
elseif(APPLE)
set(CMAKE_INSTALL_RPATH "@rpath:${CMAKE_INSTALL_FULL_LIBDIR}")
else()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
endif()
set(isSystemDir)
endif()
Expand Down
9 changes: 5 additions & 4 deletions IlmBase/config/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ function(ILMBASE_DEFINE_LIBRARY libname)
if(ILMBASE_CURLIB_PRIVATE_DEPS)
target_link_libraries(${objlib} PRIVATE ${ILMBASE_CURLIB_PRIVATE_DEPS})
endif()
set_property(TARGET ${objlib} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${objlib} PROPERTY CXX_EXTENSIONS OFF)
set_property(TARGET ${objlib} PROPERTY POSITION_INDEPENDENT_CODE ON)

set_target_properties(${objlib} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
set_property(TARGET ${objlib} PROPERTY PUBLIC_HEADER ${ILMBASE_CURLIB_HEADERS})

install(TARGETS ${objlib}
Expand Down
2 changes: 1 addition & 1 deletion IlmBase/config/ParseConfigure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ string(REGEX MATCH "LIBTOOL_AGE=([0-9]+)" DUMMY ${CONFIGURE_AC_CONTENTS})
set(ILMBASE_SOAGE ${CMAKE_MATCH_1})
math(EXPR ILMBASE_SOVERSION "${ILMBASE_SOCURRENT} - ${ILMBASE_SOAGE}")
set(ILMBASE_LIB_VERSION "${ILMBASE_SOVERSION}.${ILMBASE_SOAGE}.${ILMBASE_SOREVISION}")
message(NOTICE ": Configure ILMBASE Version: ${ILMBASE_VERSION} Lib API: ${ILMBASE_LIB_VERSION}")
message(STATUS "Configure ILMBASE Version: ${ILMBASE_VERSION} Lib API: ${ILMBASE_LIB_VERSION}")
unset(CONFIGURE_AC_CONTENTS)
39 changes: 25 additions & 14 deletions PyIlmBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ include(config/PyIlmBaseSetup.cmake)
find_package(IlmBase ${OPENEXR_VERSION} EXACT REQUIRED CONFIG)

# we are building a python extension, so of course we depend on
# python as well. Excepth we don't know which version...
# python as well. Except we don't know which version...
# cmake 3.14 can also search for numpy, but we only depend on 3.12
# in the rest of OpenEXR right now...
#find_package(Python2 COMPONENTS Development NumPy)

# first make sure we find *some* python
find_package(Python REQUIRED)

# now determine which (or both), and compile for both
find_package(Python2 COMPONENTS Interpreter Development)
find_package(Python3 COMPONENTS Interpreter Development)
if(TARGET Python2::Python AND TARGET Python3::Python)
Expand All @@ -46,18 +50,25 @@ endif()
# Boost Python has some .. annoyances in that the python module
# has version names attached to it
if (TARGET Python2::Python)
set(PYILMBASE_BOOST_PY2_COMPONENT "python${Python2_VERSION_MAJOR}${Python2_VERSION_MINOR}")
set(PYILMBASE_BOOST_NUMPY2_COMPONENT "numpy${Python2_VERSION_MAJOR}${Python2_VERSION_MINOR}")
message(": Python2 site lib: ${Python2_SITELIB}")
set(PYILMBASE_BOOST_PY2_COMPONENT "python${Python2_VERSION_MAJOR}${Python2_VERSION_MINOR}")
set(PYILMBASE_BOOST_NUMPY2_COMPONENT "numpy${Python2_VERSION_MAJOR}${Python2_VERSION_MINOR}")
message(STATUS "Found Python2 libraries: ${Python2_VERSION_MAJOR}${Python2_VERSION_MINOR}")
# ${Python2_SITELIB}
endif()
if (TARGET Python3::Python)
set(PYILMBASE_BOOST_PY3_COMPONENT "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
set(PYILMBASE_BOOST_NUMPY3_COMPONENT "numpy${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
message(": Python3 site lib: ${Python3_SITELIB}")
set(PYILMBASE_BOOST_PY3_COMPONENT "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
set(PYILMBASE_BOOST_NUMPY3_COMPONENT "numpy${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
message(STATUS "Found Python3 libraries: ${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
endif()

find_package(Boost COMPONENTS ${PYILMBASE_BOOST_PY2_COMPONENT} ${PYILMBASE_BOOST_NUMPY2_COMPONENT} ${PYILMBASE_BOOST_PY3_COMPONENT} ${PYILMBASE_BOOST_NUMPY3_COMPONENT})
find_package(Boost REQUIRED COMPONENTS ${PYILMBASE_BOOST_PY2_COMPONENT} ${PYILMBASE_BOOST_NUMPY2_COMPONENT} ${PYILMBASE_BOOST_PY3_COMPONENT} ${PYILMBASE_BOOST_NUMPY3_COMPONENT})

# utility function for the repeated boilerplate of defining
# the libraries and/or python modules
include(config/ModuleDefine.cmake)

##########################
add_subdirectory(config)

add_subdirectory( PyIex )
#add_subdirectory( PyImath )
Expand All @@ -66,10 +77,10 @@ add_subdirectory( PyIex )
##########################
# Tests
##########################
#include(CTest)
#if(BUILD_TESTING)
# enable_testing()
# add_subdirectory( PyIexTest )
include(CTest)
if(BUILD_TESTING)
enable_testing()
add_subdirectory( PyIexTest )
# add_subdirectory( PyImathTest )
# add_subdirectory( PyImathNumpyTest )
#endif()
endif()
115 changes: 49 additions & 66 deletions PyIlmBase/PyImath/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

ADD_LIBRARY ( PyImath ${LIB_TYPE}
pyilmbase_define_module(imath
LIBNAME PyImath
PRIV_EXPORT PYIMATH_BUILD
CURDIR ${CMAKE_CURRENT_SOURCE_DIR}
LIBSOURCE
PyImath.cpp
PyImathAutovectorize.cpp
PyImathBox2Array.cpp
Expand Down Expand Up @@ -30,70 +33,50 @@ ADD_LIBRARY ( PyImath ${LIB_TYPE}
PyImathVec4fd.cpp
PyImathVec4siArray.cpp
PyImathVec4si.cpp
)

target_compile_definitions( PyImath PRIVATE -DPYIMATH_BUILD )

IF (WIN32)
target_compile_definitions( PyImath
PRIVATE OPENEXR_DLL)
ENDIF()



SET_ILMBASE_INCLUDE_DIRS( PyImath )

# IlmBase::Iex${OPENEXR_TARGET_SUFFIX}
TARGET_LINK_LIBRARIES ( PyImath
IlmBase::IexMath${OPENEXR_TARGET_SUFFIX}
IlmBase::Imath${OPENEXR_TARGET_SUFFIX}
PyIex
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)

INSTALL ( TARGETS PyImath
DESTINATION
lib
)

INSTALL (DIRECTORY ./
DESTINATION include/OpenEXR
FILES_MATCHING PATTERN "*.h"
)

# must be shared
ADD_LIBRARY ( imathmodule SHARED
MODSOURCE
imathmodule.cpp
PyImathFun.cpp
PyImathBasicTypes.cpp
)

IF (WIN32)
SET_TARGET_PROPERTIES ( imathmodule
PROPERTIES
PREFIX ""
OUTPUT_NAME "imath"
SUFFIX ".pyd"
)
ELSE ()
SET_TARGET_PROPERTIES ( imathmodule
PROPERTIES PREFIX "" SUFFIX ".so" BUILD_WITH_INSTALL_RPATH ON
)
ENDIF ()

SET_ILMBASE_INCLUDE_DIRS( imathmodule )

# IlmBase::Imath${OPENEXR_TARGET_SUFFIX}
# IlmBase::Iex${OPENEXR_TARGET_SUFFIX}
TARGET_LINK_LIBRARIES ( imathmodule
PyImath
PyIex
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)

INSTALL ( TARGETS imathmodule
DESTINATION lib/python${OPENEXR_PYTHON_MAJOR}.${OPENEXR_PYTHON_MINOR}/site-packages
)

HEADERS
PyImath.h
PyImathAutovectorize.h
PyImathBasicTypes.h
PyImathBox.h
PyImathBoxArrayImpl.h
PyImathColor.h
PyImathColor3ArrayImpl.h
PyImathColor4Array2DImpl.h
PyImathColor4ArrayImpl.h
PyImathDecorators.h
PyImathEuler.h
PyImathExport.h
PyImathFixedArray.h
PyImathFixedArray2D.h
PyImathFixedMatrix.h
PyImathFixedVArray.h
PyImathFrustum.h
PyImathFun.h
PyImathLine.h
PyImathM44Array.h
PyImathMathExc.h
PyImathMatrix.h
PyImathOperators.h
PyImathPlane.h
PyImathQuat.h
PyImathRandom.h
PyImathShear.h
PyImathStringArray.h
PyImathStringArrayRegister.h
PyImathStringTable.h
PyImathTask.h
PyImathUtil.h
PyImathVec.h
PyImathVec2Impl.h
PyImathVec3ArrayImpl.h
PyImathVec3Impl.h
PyImathVec4ArrayImpl.h
PyImathVec4Impl.h
PyImathVecOperators.h
DEPENDENCIES
IlmBase::Iex IlmBase::IexMath IlmBase::Imath
)
23 changes: 23 additions & 0 deletions PyIlmBase/config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

### The autoconf setup for this folder generates a PyIlmBaseConfig.h file
### but no source actually uses that, so let's elide that for now

# The main export of the configuration - This is the
# moral equivalent of a pkg-config file for cmake
# and replaces the Find*.cmake of the "old" cmake
if(PYILMBASE_BUILD_SUPPORT_LIBRARIES)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PYILMBASE_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(EXPORT ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
FILE ${PROJECT_NAME}Config.cmake
NAMESPACE ${PROJECT_NAME}::
EXPORT_LINK_INTERFACE_LIBRARIES
)
endif()
Loading

0 comments on commit 9781367

Please sign in to comment.