Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake warnings, fix check for numpy #535

Merged
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
2 changes: 1 addition & 1 deletion PyIlmBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ project(PyIlmBase VERSION ${PYILMBASE_VERSION} LANGUAGES C CXX)
include(config/PyIlmBaseSetup.cmake)

# we have a strong dependence on IlmBase being an exact match
find_package(IlmBase ${OPENEXR_VERSION} EXACT REQUIRED CONFIG)
find_package(IlmBase ${PYILMBASE_VERSION} EXACT REQUIRED CONFIG)

# we are building a python extension, so of course we depend on
# python as well. Except we don't know which version...
Expand Down
2 changes: 1 addition & 1 deletion PyIlmBase/config/ModuleDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function(PYILMBASE_ADD_LIBRARY_PRIV libname)
)
endif()
set_target_properties(${libname} PROPERTIES
OUTPUT_NAME "${PYILMBASE_OUTPUT_OUTROOT}${libname}${PYILMBASE_LIB_SUFFIX}"
OUTPUT_NAME "${PYILMBASE_CURLIB_OUTROOT}${libname}${PYILMBASE_LIB_SUFFIX}"
)
target_compile_features(${libname} PUBLIC cxx_std_${OPENEXR_CXX_STANDARD})
if(PYILMBASE_CURLIB_PRIV_EXPORT AND BUILD_SHARED_LIBS)
Expand Down
24 changes: 12 additions & 12 deletions PyIlmBase/config/NumPyLocate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@
if(TARGET Python2::Interpreter)
execute_process(
COMMAND ${Python2_EXECUTABLE} -c
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n"
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept: import sys; sys.exit(1)\n"
RESULT_VARIABLE _NUMPY2_RESULT
OUTPUT_VARIABLE py_ilmbase_numpy2_path
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT _NUMPY2_RESULT MATCHES 0)
set(NumPy_Py2_FOUND 0 CACHE INTERNAL "Python2 numpy libraries not found")
set(NumPy_Py2_FOUND FALSE CACHE INTERNAL "Python2 numpy libraries not found")
message(WARNING "Unable to import numpy using python ${Python2_VERSION}")
else()
execute_process(
COMMAND ${Python2_EXECUTABLE} -c
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n"
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept: import sys; sys.exit(1)\n"
RESULT_VARIABLE _NUMPY2_RESULT
OUTPUT_VARIABLE py_ilmbase_numpy2_version
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT _NUMPY2_RESULT MATCHES 0)
set(NumPy_Py2_FOUND 0 CACHE INTERNAL "Python2 numpy libraries not found")
set(NumPy_Py2_FOUND FALSE CACHE INTERNAL "Python2 numpy libraries not found")
message(WARNING "Found numpy module in python ${Python2_VERSION}, but no version information")
else()
find_path(NumPy_Py2_INCLUDE_DIRS numpy/arrayobject.h
HINTS "${py_ilmbase_numpy2_path}" "${Python2_INCLUDE_DIRS}"
NO_DEFAULT_PATH
)
if(NumPy_Py2_INCLUDE_DIRS)
set(NumPy_Py2_FOUND 1 CACHE INTERNAL "Python2 numpy found")
set(NumPy_Py2_FOUND TRUE CACHE INTERNAL "Python2 numpy found")
set(NumPy_Py2_VERSION ${py_ilmbase_numpy2_version})
add_library(NumPy_Py2 INTERFACE IMPORTED GLOBAL)
target_include_directories(NumPy_Py2 INTERFACE ${NumPy_Py2_INCLUDE_DIRS})
add_library(Python2::IlmBaseNumPy ALIAS NumPy_Py2)
message(STATUS "Found NumPy ${NumPy_Py2_VERSION} for Python ${Python2_VERSION}: ${NumPy_Py2_INCLUDE_DIRS}")
else()
set(NumPy_Py2_FOUND 0 CACHE INTERNAL "Python2 numpy libraries not found")
set(NumPy_Py2_FOUND FALSE CACHE INTERNAL "Python2 numpy libraries not found")
message(WARNING "Found numpy version ${py_ilmbase_numpy2_version} in python ${Python2_VERSION}, but unable to locate header files")
endif()
endif()
Expand All @@ -46,39 +46,39 @@ endif()
if(TARGET Python3::Interpreter)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n"
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept: import sys; sys.exit(1)\n"
RESULT_VARIABLE _NUMPY3_RESULT
OUTPUT_VARIABLE py_ilmbase_numpy3_path
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT _NUMPY3_RESULT MATCHES 0)
set(NumPy_Py3_FOUND 0 CACHE INTERNAL "Python3 numpy libraries not found")
set(NumPy_Py3_FOUND FALSE CACHE INTERNAL "Python3 numpy libraries not found")
message(WARNING "Unable to import numpy using python ${Python3_VERSION}")
else()
execute_process(
COMMAND ${Python3_EXECUTABLE} -c
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n"
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept: import sys; sys.exit(1)\n"
RESULT_VARIABLE _NUMPY3_RESULT
OUTPUT_VARIABLE py_ilmbase_numpy3_version
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(NOT _NUMPY3_RESULT MATCHES 0)
set(NumPy_Py3_FOUND 0 CACHE INTERNAL "Python3 numpy libraries not found")
set(NumPy_Py3_FOUND FALSE CACHE INTERNAL "Python3 numpy libraries not found")
message(WARNING "Found numpy module in python ${Python3_VERSION}, but no version information")
else()
find_path(NumPy_Py3_INCLUDE_DIRS numpy/arrayobject.h
HINTS "${py_ilmbase_numpy3_path}" "${Python3_INCLUDE_DIRS}"
NO_DEFAULT_PATH
)
if(NumPy_Py3_INCLUDE_DIRS)
set(NumPy_Py3_FOUND 1 CACHE INTERNAL "Python3 numpy found")
set(NumPy_Py3_FOUND TRUE CACHE INTERNAL "Python3 numpy found")
set(NumPy_Py3_VERSION ${py_ilmbase_numpy3_version})
add_library(NumPy_Py3 INTERFACE IMPORTED GLOBAL)
target_include_directories(NumPy_Py3 INTERFACE ${NumPy_Py3_INCLUDE_DIRS})
add_library(Python3::IlmBaseNumPy ALIAS NumPy_Py3)
message(STATUS "Found NumPy ${NumPy_Py3_VERSION} for Python ${Python3_VERSION}: ${NumPy_Py3_INCLUDE_DIRS}")
else()
set(NumPy_Py3_FOUND 0 CACHE INTERNAL "Python3 numpy libraries not found")
set(NumPy_Py3_FOUND FALSE CACHE INTERNAL "Python3 numpy libraries not found")
message(WARNING "Found numpy version ${py_ilmbase_numpy3_version} in python ${Python3_VERSION}, but unable to locate header files")
endif()
endif()
Expand Down