CMakeLists.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. # ----------------------------------------------------------------------------
  2. # CMake file for openexr
  3. #
  4. # ----------------------------------------------------------------------------
  5. project(openexr CXX)
  6. if(NOT HAVE_CXX11)
  7. ocv_check_compiler_flag(CXX "-std=c++11" HAVE_STD_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp")
  8. if(HAVE_STD_CXX11)
  9. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  10. else()
  11. if(BUILD_OPENEXR)
  12. message(WARNING "OpenCV: builtin OpenEXR requires C++11 support. OpenEXR is disabled.")
  13. endif()
  14. return()
  15. endif()
  16. endif()
  17. set(ILMBASE_VERSION_MAJOR "2")
  18. set(ILMBASE_VERSION_MINOR "3")
  19. set(ILMBASE_VERSION_PATCH "0")
  20. set(ILMBASE_VERSION "${ILMBASE_VERSION_MAJOR}.${ILMBASE_VERSION_MINOR}.${ILMBASE_VERSION_PATCH}")
  21. set(ILMBASE_VERSION_API ${ILMBASE_VERSION_MAJOR}_${ILMBASE_VERSION_MINOR})
  22. set(OPENEXR_VERSION_MAJOR "2")
  23. set(OPENEXR_VERSION_MINOR "3")
  24. set(OPENEXR_VERSION_PATCH "0")
  25. set(OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH}")
  26. set(OPENEXR_VERSION_API ${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR})
  27. set(OPENEXR_VERSION "${OPENEXR_VERSION}" PARENT_SCOPE)
  28. if(WIN32)
  29. set(HAVE_COMPLETE_IOMANIP 1)
  30. set(OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1)
  31. set(PLATFORM_WINDOWS 1)
  32. elseif(APPLE)
  33. set(HAVE_POSIX_SEMAPHORES 0) # Unnamed semaphores are not supported: https://github.com/opencv/opencv/issues/9361
  34. if(DARWIN)
  35. set(OPENEXR_IMF_HAVE_DARWIN 1)
  36. endif()
  37. elseif(UNIX)
  38. include(CheckIncludeFile)
  39. check_include_file(semaphore.h HAVE_POSIX_SEMAPHORES)
  40. endif()
  41. set(ILMBASE_VERSION_API "opencv")
  42. set(ILMBASE_INTERNAL_NAMESPACE_CUSTOM 1)
  43. set(IMATH_INTERNAL_NAMESPACE "Imath_${ILMBASE_VERSION_API}")
  44. set(IEX_INTERNAL_NAMESPACE "Iex_${ILMBASE_VERSION_API}")
  45. set(ILMTHREAD_INTERNAL_NAMESPACE "IlmThread_${ILMBASE_VERSION_API}")
  46. set(ILMBASE_NAMESPACE_CUSTOM 0)
  47. set(IMATH_NAMESPACE "Imath")
  48. set(IEX_NAMESPACE "Iex")
  49. set(ILMTHREAD_NAMESPACE "IlmThread")
  50. set(ILMBASE_VERSION_STRING "\"${ILMBASE_VERSION}\"" )
  51. set(ILMBASE_PACKAGE_STRING "\"IlmBase ${ILMBASE_VERSION}\"" )
  52. set(OPENEXR_VERSION_API "opencv")
  53. set(OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 1)
  54. set(OPENEXR_IMF_INTERNAL_NAMESPACE "Imf_${ILMBASE_VERSION_API}")
  55. set(OPENEXR_IMF_NAMESPACE_CUSTOM 0)
  56. set(OPENEXR_IMF_NAMESPACE "Imf")
  57. set(OPENEXR_VERSION_STRING "\"${OPENEXR_VERSION}\"" )
  58. set(OPENEXR_PACKAGE_STRING "\"OpenEXR ${OPENEXR_VERSION}\"" )
  59. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/IlmBaseConfig.h.cmakein"
  60. "${CMAKE_CURRENT_BINARY_DIR}/IlmBaseConfig.h" @ONLY)
  61. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenEXRConfig.h.cmakein"
  62. "${CMAKE_CURRENT_BINARY_DIR}/OpenEXRConfig.h" @ONLY)
  63. set(OPENEXR_INCLUDE_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/Half"
  64. "${CMAKE_CURRENT_SOURCE_DIR}/Iex"
  65. "${CMAKE_CURRENT_SOURCE_DIR}/IlmThread"
  66. "${CMAKE_CURRENT_SOURCE_DIR}/Imath"
  67. "${CMAKE_CURRENT_SOURCE_DIR}/IlmImf"
  68. "${CMAKE_CURRENT_BINARY_DIR}")
  69. ocv_include_directories("${CMAKE_CURRENT_BINARY_DIR}" ${ZLIB_INCLUDE_DIRS} ${OPENEXR_INCLUDE_PATHS})
  70. file(GLOB lib_srcs Half/half.cpp Iex/*.cpp IlmThread/*.cpp Imath/*.cpp IlmImf/*.cpp)
  71. file(GLOB lib_hdrs Half/*.h Iex/Iex*.h IlmThread/IlmThread*.h Imath/Imath*.h IlmImf/*.h)
  72. list(APPEND lib_hdrs "${CMAKE_CURRENT_BINARY_DIR}/IlmBaseConfig.h" "${CMAKE_CURRENT_BINARY_DIR}/OpenEXRConfig.h")
  73. if(WIN32)
  74. ocv_list_filterout(lib_srcs Posix.*cpp)
  75. else()
  76. ocv_list_filterout(lib_srcs Win32.cpp)
  77. endif()
  78. source_group("Include" FILES ${lib_hdrs} )
  79. source_group("Src" FILES ${lib_srcs})
  80. ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -Wmissing-declarations -Wuninitialized -Wswitch -Wparentheses -Warray-bounds -Wextra
  81. -Wdeprecated-declarations -Wmisleading-indentation -Wdeprecated
  82. -Wsuggest-override -Winconsistent-missing-override
  83. -Wimplicit-fallthrough
  84. -Wtautological-compare # clang
  85. -Wmissing-prototypes # gcc/clang
  86. -Wreorder
  87. -Wunused-result
  88. -Wimplicit-const-int-float-conversion # clang
  89. )
  90. if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
  91. ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
  92. endif()
  93. ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
  94. ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64
  95. ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
  96. ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267) # vs2008 Win64
  97. ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4456) # vs2015
  98. if(MSVC AND CV_ICC)
  99. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qrestrict")
  100. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qrestrict")
  101. endif()
  102. add_library(IlmImf STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_hdrs} ${lib_srcs})
  103. target_link_libraries(IlmImf ${ZLIB_LIBRARIES})
  104. set_target_properties(IlmImf
  105. PROPERTIES
  106. OUTPUT_NAME "IlmImf"
  107. DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
  108. COMPILE_PDB_NAME "IlmImf"
  109. COMPILE_PDB_NAME_DEBUG "IlmImf${OPENCV_DEBUG_POSTFIX}"
  110. ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
  111. )
  112. if(ENABLE_SOLUTION_FOLDERS)
  113. set_target_properties(IlmImf PROPERTIES FOLDER "3rdparty")
  114. endif()
  115. if(NOT BUILD_SHARED_LIBS)
  116. ocv_install_target(IlmImf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
  117. endif()
  118. ocv_install_3rdparty_licenses(openexr LICENSE AUTHORS.ilmbase AUTHORS.openexr)
  119. set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATHS} PARENT_SCOPE)