cmake: update handling of IPPICV/IPPIW

pull/8648/head
Alexander Alekhin 8 years ago
parent 3db496f677
commit f3eff00bf7
  1. 19
      cmake/OpenCVFindIPPIW.cmake
  2. 16
      cmake/OpenCVGenConfig.cmake
  3. 44
      cmake/OpenCVUtils.cmake
  4. 7
      cmake/templates/OpenCVConfig-IPPIW.cmake.in
  5. 1
      cmake/templates/OpenCVConfig.cmake.in

@ -68,6 +68,7 @@ macro(ippiw_setup PATH BUILD)
set(IPP_IW_LIBRARIES ${IPP_IW_LIBRARY}) set(IPP_IW_LIBRARIES ${IPP_IW_LIBRARY})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OpenCV_SOURCE_DIR}/3rdparty/ippicv/CMakeLists.txt" "${IPP_IW_PATH}/") execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OpenCV_SOURCE_DIR}/3rdparty/ippicv/CMakeLists.txt" "${IPP_IW_PATH}/")
add_subdirectory("${IPP_IW_PATH}/" ${OpenCV_BINARY_DIR}/3rdparty/ippiw) add_subdirectory("${IPP_IW_PATH}/" ${OpenCV_BINARY_DIR}/3rdparty/ippiw)
set(HAVE_IPP_IW 1) set(HAVE_IPP_IW 1)
return() return()
endif() endif()
@ -84,8 +85,22 @@ macro(ippiw_setup PATH BUILD)
message(STATUS "found Intel IPP IW binaries: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}") message(STATUS "found Intel IPP IW binaries: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}")
message(STATUS "at: ${IPP_IW_PATH}") message(STATUS "at: ${IPP_IW_PATH}")
add_library(ippiw STATIC IMPORTED)
set_target_properties(ippiw PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES ""
IMPORTED_LOCATION "${FILE}"
)
if (NOT BUILD_SHARED_LIBS)
# CMake doesn't support "install(TARGETS ${name} ...)" command with imported targets
install(FILES "${FILE}"
DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
set(IPPIW_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_3P_LIB_INSTALL_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE INTERNAL "" FORCE)
set(IPPIW_LOCATION_PATH "${FILE}" CACHE INTERNAL "" FORCE)
endif()
set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include") set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include")
set(IPP_IW_LIBRARIES ${FILE}) set(IPP_IW_LIBRARIES ippiw)
set(HAVE_IPP_IW 1) set(HAVE_IPP_IW 1)
set(BUILD_IPP_IW 0) set(BUILD_IPP_IW 0)
return() return()
@ -104,7 +119,7 @@ elseif((UNIX AND NOT ANDROID) OR (UNIX AND ANDROID_ABI MATCHES "x86"))
elseif(WIN32 AND NOT ARM) elseif(WIN32 AND NOT ARM)
set(IW_PACKAGE_SUBDIR "ippiw_win") set(IW_PACKAGE_SUBDIR "ippiw_win")
else() else()
message(SEND_ERROR "Improper system for Intel IPP Integrations Wrappers. This message shouldn't appera. Check Intel IPP configurations steps") message(SEND_ERROR "Improper system for Intel IPP Integrations Wrappers. This message shouldn't appear. Check Intel IPP configurations steps")
return() return()
endif() endif()

@ -45,12 +45,20 @@ export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules.
if(TARGET ippicv AND NOT BUILD_SHARED_LIBS) if(TARGET ippicv AND NOT BUILD_SHARED_LIBS)
set(USE_IPPICV TRUE) set(USE_IPPICV TRUE)
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE ${CMAKE_BINARY_DIR} ${IPPICV_LOCATION_PATH}) file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_BINARY_DIR}" "${IPPICV_LOCATION_PATH}")
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY) ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY)
else() else()
set(USE_IPPICV FALSE) set(USE_IPPICV FALSE)
endif() endif()
if(TARGET ippiw AND NOT BUILD_SHARED_LIBS AND IPPIW_INSTALL_PATH)
set(USE_IPPIW TRUE)
file(RELATIVE_PATH IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_BINARY_DIR}" "${IPPIW_LOCATION_PATH}")
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPIW.cmake.in" IPPIW_CONFIGCMAKE @ONLY)
else()
set(USE_IPPIW FALSE)
endif()
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" @ONLY) configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" @ONLY)
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work. #support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" @ONLY) configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" @ONLY)
@ -62,9 +70,13 @@ file(RELATIVE_PATH OpenCV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PRE
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\" \"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv\"") set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\" \"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv\"")
if(USE_IPPICV) if(USE_IPPICV)
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" ${IPPICV_INSTALL_PATH}) file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPICV_INSTALL_PATH}")
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY) ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY)
endif() endif()
if(USE_IPPIW)
file(RELATIVE_PATH IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPIW_INSTALL_PATH}")
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPIW.cmake.in" IPPIW_CONFIGCMAKE @ONLY)
endif()
function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME) function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME)
ocv_path_join(__install_nested "${OPENCV_CONFIG_INSTALL_PATH}" "${NESTED_PATH}") ocv_path_join(__install_nested "${OPENCV_CONFIG_INSTALL_PATH}" "${NESTED_PATH}")

@ -1003,6 +1003,13 @@ function(ocv_add_library target)
_ocv_append_target_includes(${target}) _ocv_append_target_includes(${target})
endfunction() endfunction()
macro(ocv_get_libname var_name)
get_filename_component(__libname "${ARGN}" NAME)
string(REGEX REPLACE "^lib(.+).(a|so)(.[.0-9]+)?$" "\\1" __libname "${__libname}")
set(${var_name} "${__libname}")
endmacro()
# build the list of opencv libs and dependencies for all modules # build the list of opencv libs and dependencies for all modules
# _modules - variable to hold list of all modules # _modules - variable to hold list of all modules
# _extra - variable to hold list of extra dependencies # _extra - variable to hold list of extra dependencies
@ -1030,11 +1037,31 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
foreach (dep ${deps} ${OPENCV_LINKER_LIBS}) foreach (dep ${deps} ${OPENCV_LINKER_LIBS})
if (NOT DEFINED OPENCV_MODULE_${dep}_LOCATION) if (NOT DEFINED OPENCV_MODULE_${dep}_LOCATION)
if (TARGET ${dep}) if (TARGET ${dep})
get_target_property(_output ${dep} ARCHIVE_OUTPUT_DIRECTORY) get_target_property(_type ${dep} TYPE)
if ("${_output}" STREQUAL "${3P_LIBRARY_OUTPUT_PATH}") if(_type STREQUAL "STATIC_LIBRARY" AND BUILD_SHARED_LIBS)
list(INSERT ${_3rdparty} 0 ${dep}) # nothing
else() else()
list(INSERT ${_extra} 0 ${dep}) get_target_property(_output ${dep} IMPORTED_LOCATION)
if(NOT _output)
get_target_property(_output ${dep} ARCHIVE_OUTPUT_DIRECTORY)
get_target_property(_output_name ${dep} OUTPUT_NAME)
if(NOT _output_name)
set(_output_name "${dep}")
endif()
else()
get_filename_component(_output_name "${_output}" NAME)
endif()
string(FIND "${_output}" "${CMAKE_BINARY_DIR}" _POS)
if (_POS EQUAL 0)
ocv_get_libname(_libname "${_output_name}")
list(INSERT ${_3rdparty} 0 ${_libname})
else()
if(_output)
list(INSERT ${_extra} 0 ${_output})
else()
list(INSERT ${_extra} 0 ${dep})
endif()
endif()
endif() endif()
else() else()
list(INSERT ${_extra} 0 ${dep}) list(INSERT ${_extra} 0 ${dep})
@ -1043,15 +1070,6 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
endforeach() endforeach()
endforeach() endforeach()
# ippicv specific handling
list(FIND ${_extra} "ippicv" ippicv_idx)
if (${ippicv_idx} GREATER -1)
list(REMOVE_ITEM ${_extra} "ippicv")
if(NOT BUILD_SHARED_LIBS)
list(INSERT ${_3rdparty} 0 "ippicv")
endif()
endif()
ocv_list_filterout(${_modules} "^[\$]<") ocv_list_filterout(${_modules} "^[\$]<")
ocv_list_filterout(${_3rdparty} "^[\$]<") ocv_list_filterout(${_3rdparty} "^[\$]<")
ocv_list_filterout(${_extra} "^[\$]<") ocv_list_filterout(${_extra} "^[\$]<")

@ -0,0 +1,7 @@
if(NOT TARGET ippiw)
add_library(ippiw STATIC IMPORTED)
set_target_properties(ippiw PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES ""
IMPORTED_LOCATION "${OpenCV_INSTALL_PATH}/@IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE@"
)
endif()

@ -97,6 +97,7 @@ endif()
@ANDROID_CONFIGCMAKE@ @ANDROID_CONFIGCMAKE@
@IPPICV_CONFIGCMAKE@ @IPPICV_CONFIGCMAKE@
@IPPIW_CONFIGCMAKE@
# Some additional settings are required if OpenCV is built as static libs # Some additional settings are required if OpenCV is built as static libs
set(OpenCV_SHARED @BUILD_SHARED_LIBS@) set(OpenCV_SHARED @BUILD_SHARED_LIBS@)

Loading…
Cancel
Save