use FindZLIB(), FindJPEG() etc. on MacOSX as well to avoid possible conflicts with MacPorts.

This commit is contained in:
Vadim Pisarevsky 2011-05-27 13:47:18 +00:00
parent 0b0baa0cf5
commit 9336b700ba
2 changed files with 140 additions and 142 deletions

View File

@ -215,7 +215,7 @@ set(BUILD_TESTS ON CACHE BOOL "Build tests")
# Build 3rdparty libraries under unix
# ===================================================
if(WIN32 OR APPLE)
if(WIN32)
set(OPENCV_BUILD_3RDPARTY_LIBS TRUE CACHE BOOL "Build 3rd party libraries")
else()
set(OPENCV_BUILD_3RDPARTY_LIBS FALSE CACHE BOOL "Build 3rd party libraries")
@ -425,6 +425,34 @@ if(UNIX)
set(HAVE_DC1394 FALSE)
endif()
if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
include(FindZLIB)
if(WITH_PNG)
include(FindPNG)
if(PNG_FOUND)
CHECK_INCLUDE_FILE(${PNG_PNG_INCLUDE_DIR}/png.h HAVE_PNG_H)
CHECK_INCLUDE_FILE(${PNG_PNG_INCLUDE_DIR}/libpng/png.h HAVE_LIBPNG_PNG_H)
endif()
else()
set(PNG_FOUND FALSE)
endif()
if(WITH_TIFF)
include(FindTIFF)
else()
set(TIFF_FOUND FALSE)
endif()
if(WITH_JASPER)
include(FindJasper)
else()
set(JASPER_FOUND FALSE)
endif()
if(WITH_JPEG)
include(FindJPEG)
else()
set(JPEG_FOUND FALSE)
endif()
endif()
if(NOT APPLE)
CHECK_INCLUDE_FILE(alloca.h HAVE_ALLOCA_H)
CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA)
@ -437,8 +465,6 @@ if(UNIX)
set(HAVE_XINE FALSE)
endif()
if(WITH_V4L)
CHECK_MODULE(libv4l1 HAVE_LIBV4L)
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
@ -448,34 +474,6 @@ if(UNIX)
set(HAVE_CAMV4L2 FALSE)
endif()
if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
include(FindZLIB)
if(WITH_PNG)
include(FindPNG)
if(PNG_FOUND)
CHECK_INCLUDE_FILE(${PNG_PNG_INCLUDE_DIR}/png.h HAVE_PNG_H)
CHECK_INCLUDE_FILE(${PNG_PNG_INCLUDE_DIR}/libpng/png.h HAVE_LIBPNG_PNG_H)
endif()
else()
set(PNG_FOUND FALSE)
endif()
if(WITH_TIFF)
include(FindTIFF)
else()
set(TIFF_FOUND FALSE)
endif()
if(WITH_JASPER)
include(FindJasper)
else()
set(JASPER_FOUND FALSE)
endif()
if(WITH_JPEG)
include(FindJPEG)
else()
set(JPEG_FOUND FALSE)
endif()
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD" AND NOT ANDROID)
set(OPENCV_LINKER_LIBS m pthread)
elseif(ANDROID)
@ -603,12 +601,12 @@ if (WITH_QT)
#if (NOT WIN32)
if (WITH_QT_OPENGL)
if (QT_QTOPENGL_FOUND AND OPENGL_FOUND)
set(HAVE_QT_OPENGL 1)
add_definitions(-DHAVE_QT_OPENGL)
#link_directories("${OPENGL_LIBRARIES}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
endif()
if (QT_QTOPENGL_FOUND AND OPENGL_FOUND)
set(HAVE_QT_OPENGL 1)
add_definitions(-DHAVE_QT_OPENGL)
#link_directories("${OPENGL_LIBRARIES}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${OPENGL_LIBRARIES})
endif()
endif()
#endif()
@ -633,9 +631,9 @@ if (WITH_TBB)
endif()
if (NOT HAVE_TBB)
set(TBB_DEFAULT_INCLUDE_DIRS "/opt/intel/tbb" "/usr/local/include" "/usr/include" "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB")
find_path(TBB_INCLUDE_DIR "tbb/tbb.h" PATHS ${TBB_DEFAULT_INCLUDE_DIRS} DOC "The path to TBB headers")
set(TBB_DEFAULT_INCLUDE_DIRS "/opt/intel/tbb" "/usr/local/include" "/usr/include" "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB")
find_path(TBB_INCLUDE_DIR "tbb/tbb.h" PATHS ${TBB_DEFAULT_INCLUDE_DIRS} DOC "The path to TBB headers")
if (TBB_INCLUDE_DIR)
if (UNIX)
set(TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory")
@ -646,47 +644,47 @@ if (WITH_TBB)
elseif (UNIX)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
elseif (WIN32)
if (CMAKE_COMPILER_IS_GNUCXX)
set(TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
else()
get_filename_component(_TBB_LIB_PATH "${TBB_INCLUDE_DIR}/../lib" ABSOLUTE)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64*|x86_64*)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/intel64")
if (CMAKE_COMPILER_IS_GNUCXX)
set(TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
else()
get_filename_component(_TBB_LIB_PATH "${TBB_INCLUDE_DIR}/../lib" ABSOLUTE)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64*|x86_64*)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/intel64")
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES x86*|i386*|i686*)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/ia32")
endif()
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/ia32")
endif()
if (MSVC80)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc8")
elseif(MSVC90)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc9")
elseif(MSVC10)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc10")
endif()
set(TBB_LIB_DIR "${_TBB_LIB_PATH}" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
endif()
endif()
if (MSVC80)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc8")
elseif(MSVC90)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc9")
elseif(MSVC10)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc10")
endif()
set(TBB_LIB_DIR "${_TBB_LIB_PATH}" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
endif()
endif()
set(HAVE_TBB 1)
if(NOT "${TBB_INCLUDE_DIR}" STREQUAL "")
include_directories("${TBB_INCLUDE_DIR}")
endif()
endif()
endif()
set(HAVE_TBB 1)
if(NOT "${TBB_INCLUDE_DIR}" STREQUAL "")
include_directories("${TBB_INCLUDE_DIR}")
endif()
endif()
endif()
endif(WITH_TBB)
#Threading Framework -- temporary decision for ARM-s instead of TBB
if (NOT HAVE_TBB)
file(GLOB THREADING_FRAMEWORK_HEADER "${CMAKE_SOURCE_DIR}/modules/core/include/opencv2/core/threading_framework.hpp")
file(GLOB THREADING_FRAMEWORK_SOURCE "${CMAKE_SOURCE_DIR}/modules/core/src/threading_framework.cpp")
if(THREADING_FRAMEWORK_HEADER AND THREADING_FRAMEWORK_SOURCE)
set(HAVE_THREADING_FRAMEWORK 1)
endif()
file(GLOB THREADING_FRAMEWORK_HEADER "${CMAKE_SOURCE_DIR}/modules/core/include/opencv2/core/threading_framework.hpp")
file(GLOB THREADING_FRAMEWORK_SOURCE "${CMAKE_SOURCE_DIR}/modules/core/src/threading_framework.cpp")
if(THREADING_FRAMEWORK_HEADER AND THREADING_FRAMEWORK_SOURCE)
set(HAVE_THREADING_FRAMEWORK 1)
endif()
endif()
############################ Intel IPP #############################
@ -770,12 +768,12 @@ endif()
############################### VideoInput ################################
if (WIN32 AND WITH_VIDEOINPUT)
if(CMAKE_CXX_COMPILER MATCHES "dw2")
else()
if(NOT MINGW64)
set(HAVE_VIDEOINPUT 1)
endif()
endif()
if(CMAKE_CXX_COMPILER MATCHES "dw2")
else()
if(NOT MINGW64)
set(HAVE_VIDEOINPUT 1)
endif()
endif()
endif()
############################### OpenNI ################################
@ -1111,13 +1109,13 @@ set(CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE "\"${CMAKE_CURRENT_SOURCE_DIR}\"")
set(CMAKE_LIB_DIRS_CONFIGCMAKE "${LIBRARY_OUTPUT_PATH}")
if (ANDROID)
if (NOT BUILD_SHARED_LIBS)
set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_LIB_DIRS_CONFIGCMAKE} "${CMAKE_BINARY_DIR}/lib")
endif()
if (NOT BUILD_SHARED_LIBS)
set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_LIB_DIRS_CONFIGCMAKE} "${CMAKE_BINARY_DIR}/lib")
endif()
if( HAVE_ANDROID_NATIVE_CAMERA )
set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_LIB_DIRS_CONFIGCMAKE} ${NativeCamera_LIB_DIR})
endif()
if( HAVE_ANDROID_NATIVE_CAMERA )
set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_LIB_DIRS_CONFIGCMAKE} ${NativeCamera_LIB_DIR})
endif()
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY)
@ -1278,7 +1276,7 @@ endif()
#-----------------------------------
if(${CMAKE_VERSION} VERSION_GREATER "2.8.0")
set(ENABLE_SOLUTION_FOLDERS OFF CACHE BOOL "Solution folder in Visual Studio or in other IDEs")
set(ENABLE_SOLUTION_FOLDERS OFF CACHE BOOL "Solution folder in Visual Studio or in other IDEs")
endif()
if(ENABLE_SOLUTION_FOLDERS)

View File

@ -18,53 +18,53 @@ if(WITH_PNG OR WITH_TIFF OR WITH_OPENEXR)
endif()
if(WITH_JPEG)
add_definitions(-DHAVE_JPEG)
if(JPEG_FOUND)
add_definitions(-DHAVE_JPEG)
if(JPEG_FOUND)
include_directories(${JPEG_INCLUDE_DIR})
set(GRFMT_LIBS ${GRFMT_LIBS} ${JPEG_LIBRARIES})
else()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/libjpeg")
set(GRFMT_LIBS ${GRFMT_LIBS} libjpeg)
endif()
endif()
endif()
if(WITH_PNG)
add_definitions(-DHAVE_PNG)
if(PNG_FOUND)
add_definitions(-DHAVE_PNG)
if(PNG_FOUND)
add_definitions(${PNG_DEFINITIONS})
include_directories(${PNG_INCLUDE_DIR})
set(GRFMT_LIBS ${GRFMT_LIBS} ${PNG_LIBRARIES})
else()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/libpng")
set(GRFMT_LIBS ${GRFMT_LIBS} libpng)
endif()
endif()
endif()
if(WITH_TIFF)
add_definitions(-DHAVE_TIFF)
if(TIFF_FOUND)
add_definitions(-DHAVE_TIFF)
if(TIFF_FOUND)
include_directories(${TIFF_INCLUDE_DIR})
set(GRFMT_LIBS ${GRFMT_LIBS} ${TIFF_LIBRARIES})
else()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/libtiff")
set(GRFMT_LIBS ${GRFMT_LIBS} libtiff)
endif()
endif()
endif()
if(WITH_JASPER)
add_definitions(-DHAVE_JASPER)
if(JPEG_FOUND)
add_definitions(-DHAVE_JASPER)
if(JASPER_FOUND)
include_directories(${JASPER_INCLUDE_DIR})
set(GRFMT_LIBS ${GRFMT_LIBS} ${JASPER_LIBRARIES})
else()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/libjasper")
set(GRFMT_LIBS ${GRFMT_LIBS} libjasper)
endif()
endif()
endif()
if(WITH_OPENEXR AND OPENEXR_FOUND)
add_definitions(-DHAVE_OPENEXR)
include_directories(${OPENEXR_INCLUDE_PATHS})
add_definitions(-DHAVE_OPENEXR)
include_directories(${OPENEXR_INCLUDE_PATHS})
set(GRFMT_LIBS ${GRFMT_LIBS} ${OPENEXR_LIBRARIES})
endif()
@ -105,7 +105,7 @@ if (HAVE_QT)
INCLUDE(${QT_USE_FILE})
SET(_RCCS_FILES src/window_QT.qrc)
QT4_ADD_RESOURCES(_RCC_OUTFILES ${_RCCS_FILES})
QT4_ADD_RESOURCES(_RCC_OUTFILES ${_RCCS_FILES})
SET(_MOC_HEADERS src/window_QT.h )
QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS})
@ -126,9 +126,9 @@ endif()
if(UNIX)
if(NOT HAVE_QT)
if(HAVE_GTK)
if(HAVE_GTK)
set(highgui_srcs ${highgui_srcs} src/window_gtk.cpp)
endif()
endif()
endif()
if(HAVE_XINE)
@ -164,13 +164,13 @@ if(UNIX)
set(highgui_srcs ${highgui_srcs} src/cap_unicap.cpp)
endif()
if(HAVE_LIBV4L)
set(highgui_srcs ${highgui_srcs} src/cap_libv4l.cpp)
else()
if(HAVE_CAMV4L OR HAVE_CAMV4L2)
set(highgui_srcs ${highgui_srcs} src/cap_v4l.cpp)
endif()
endif()
if(HAVE_LIBV4L)
set(highgui_srcs ${highgui_srcs} src/cap_libv4l.cpp)
else()
if(HAVE_CAMV4L OR HAVE_CAMV4L2)
set(highgui_srcs ${highgui_srcs} src/cap_v4l.cpp)
endif()
endif()
foreach(P ${HIGHGUI_INCLUDE_DIRS})
include_directories(${P})
@ -204,11 +204,11 @@ if(APPLE)
endif()
endif()
if(WITH_QUICKTIME)
set(highgui_srcs ${highgui_srcs} src/cap_qt.cpp)
else()
set(highgui_srcs ${highgui_srcs} src/cap_qtkit.mm)
endif()
if(WITH_QUICKTIME)
set(highgui_srcs ${highgui_srcs} src/cap_qt.cpp)
else()
set(highgui_srcs ${highgui_srcs} src/cap_qtkit.mm)
endif()
endif(APPLE)
if(HAVE_ANDROID_NATIVE_CAMERA)
@ -240,7 +240,7 @@ endif()
set(lib_srcs ${highgui_srcs} ${grfmt_srcs})
# ----------------------------------------------------------------------------------
# Define the library target:
# Define the library target:
# ----------------------------------------------------------------------------------
set(the_target "opencv_highgui")
@ -249,8 +249,8 @@ if (OPENCV_BUILD_SHARED_LIB)
endif()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../core/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../imgproc/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../core/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../imgproc/include"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_BINARY_DIR}")
@ -281,20 +281,20 @@ set_target_properties(${the_target} PROPERTIES
# Additional target properties
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
LINK_INTERFACE_LIBRARIES ""
)
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
LINK_INTERFACE_LIBRARIES ""
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "modules")
endif()
set_target_properties(${the_target} PROPERTIES FOLDER "modules")
endif()
if(MSVC)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif(MSVC)
# Dependencies of this target:
@ -303,19 +303,19 @@ add_dependencies(${the_target} opencv_core opencv_imgproc)
# Add the required libraries for linking:
if(WITH_JASPER AND NOT JASPER_FOUND)
add_dependencies(${the_target} libjasper)
add_dependencies(${the_target} libjasper)
endif()
if(WITH_JPEG AND NOT JPEG_FOUND)
add_dependencies(${the_target} libjpeg)
add_dependencies(${the_target} libjpeg)
endif()
if(WITH_PNG AND NOT PNG_FOUND)
add_dependencies(${the_target} libpng)
add_dependencies(${the_target} libpng)
endif()
if(WITH_TIFF AND NOT TIFF_FOUND)
add_dependencies(${the_target} libtiff)
add_dependencies(${the_target} libtiff)
endif()
if(NOT ZLIB_FOUND)
@ -333,22 +333,22 @@ if( OPENNI_LIBRARY )
endif()
if(APPLE)
target_link_libraries(${the_target} "-lbz2 -framework Cocoa -framework QuartzCore")
if(WITH_CARBON)
target_link_libraries(${the_target} "-framework Carbon")
endif()
if(NOT WITH_QUICKTIME)
target_link_libraries(${the_target} "-framework QTKit")
target_link_libraries(${the_target} "-lbz2 -framework Cocoa -framework QuartzCore")
if(WITH_CARBON)
target_link_libraries(${the_target} "-framework Carbon")
endif()
if(WITH_CARBON OR WITH_QUICKTIME)
if(NOT WITH_QUICKTIME)
target_link_libraries(${the_target} "-framework QTKit")
endif()
if(WITH_CARBON OR WITH_QUICKTIME)
target_link_libraries(${the_target} "-framework QuickTime -framework CoreFoundation")
endif()
endif()
endif()
install(TARGETS ${the_target}
RUNTIME DESTINATION bin COMPONENT main
LIBRARY DESTINATION lib COMPONENT main
ARCHIVE DESTINATION lib COMPONENT main)
RUNTIME DESTINATION bin COMPONENT main
LIBRARY DESTINATION lib COMPONENT main
ARCHIVE DESTINATION lib COMPONENT main)
install(FILES ${highgui_ext_hdrs}
DESTINATION include/opencv2/highgui