cmake: openimageio discovery #453

This commit is contained in:
nick black 2020-04-24 00:05:01 -04:00 committed by Nick Black
parent ad0685aa1b
commit 6ffbef3d74
2 changed files with 42 additions and 0 deletions

View File

@ -40,6 +40,8 @@ pkg_check_modules(AVCODEC REQUIRED libavcodec>=57.0)
pkg_check_modules(AVFORMAT REQUIRED libavformat>=57.0)
pkg_check_modules(AVUTIL REQUIRED libavutil>=56.0)
pkg_check_modules(SWSCALE REQUIRED libswscale>=5.0)
elseif(${USE_OIIO})
pkg_check_modules(OIIO REQUIRED OpenImageIO>=2.0.7)
endif()
find_library(LIBRT rt)
if(${USE_TESTS})
@ -150,6 +152,13 @@ target_link_directories(notcurses-static
PUBLIC
"${AVUTIL_STATIC_LIBRARY_DIRS}"
)
elseif(${USE_OIIO})
target_include_directories(notcurses PUBLIC "${OIIO_INCLUDE_DIRS}")
target_include_directories(notcurses-static PUBLIC "${OIIO_STATIC_INCLUDE_DIRS}")
target_link_libraries(notcurses PRIVATE ${OIIO_LIBRARIES})
target_link_libraries(notcurses-static PRIVATE ${OIIO_STATIC_LIBRARIES})
target_link_directories(notcurses PRIVATE ${OIIO_LIBRARY_DIRS})
target_link_directories(notcurses-static PRIVATE ${OIIO_STATIC_LIBRARY_DIRS})
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug)

View File

@ -0,0 +1,33 @@
#ifndef NOTCURSES_NCERRS
#define NOTCURSES_NCERRS
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
// Error values for more granular problem indication. We map to POSIX error
// codes when possible. We need at least the union of POSIX (errno) and FFMpeg
// (AVERROR) codes that we might see.
typedef enum {
NCERR_SUCCESS = 0,
NCERR_NOMEM = ENOMEM,
NCERR_EOF = 0x464f45, // matches AVERROR_EOF
} nc_err_e;
static inline const char*
nc_strerror(nc_err_e ncerr){
switch(ncerr){
case NCERR_SUCCESS: return "success";
case NCERR_NOMEM: return strerror(ENOMEM);
case NCERR_EOF: return "end of file";
};
return "unknown error";
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif