~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/cmake/OpenCVGenPkgconfig.cmake

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# --------------------------------------------------------------------------------------------
 
2
# according to man pkg-config
 
3
#  The package name specified on the pkg-config command line is defined to
 
4
#      be the name of the metadata file, minus the .pc extension. If a library
 
5
#      can install multiple versions simultaneously, it must give each version
 
6
#      its own name (for example, GTK 1.2 might have the package  name  "gtk+"
 
7
#      while GTK 2.0 has "gtk+-2.0").
 
8
#
 
9
# ${BIN_DIR}/unix-install/opencv.pc -> For use *with* "make install"
 
10
# -------------------------------------------------------------------------------------------
 
11
 
 
12
macro(fix_prefix lst isown)
 
13
  set(_lst)
 
14
  foreach(item ${${lst}})
 
15
    if(TARGET ${item})
 
16
      get_target_property(item "${item}" LOCATION_${CMAKE_BUILD_TYPE})
 
17
      if("${isown}")
 
18
        get_filename_component(item "${item}" NAME_WE)
 
19
        string(REGEX REPLACE "^lib(.*)" "\\1" item "${item}")
 
20
      endif()
 
21
    endif()
 
22
    if(item MATCHES "^-l")
 
23
      list(APPEND _lst "${item}")
 
24
    elseif(item MATCHES "^-framework") # MacOS framework (assume single entry "-framework OpenCL")
 
25
      list(APPEND _lst "${item}")
 
26
    elseif(item MATCHES "[\\/]")
 
27
      get_filename_component(libdir "${item}" PATH)
 
28
      get_filename_component(libname "${item}" NAME_WE)
 
29
      string(REGEX REPLACE "^lib(.*)" "\\1" libname "${libname}")
 
30
      list(APPEND _lst "-L${libdir}" "-l${libname}")
 
31
    else()
 
32
      list(APPEND _lst "-l${item}")
 
33
    endif()
 
34
  endforeach()
 
35
  set(${lst} ${_lst})
 
36
  unset(_lst)
 
37
endmacro()
 
38
 
 
39
# build the list of opencv libs and dependencies for all modules
 
40
ocv_get_all_libs(_modules _extra _3rdparty)
 
41
 
 
42
#build the list of components
 
43
 
 
44
# Note:
 
45
#   when linking against static libraries, if libfoo depends on libbar, then
 
46
#   libfoo must come first in the linker flags.
 
47
 
 
48
# world and contrib_world are special targets whose library should come first,
 
49
# especially for static link.
 
50
if(_modules MATCHES "opencv_world")
 
51
  set(_modules "opencv_world")
 
52
endif()
 
53
 
 
54
if(_modules MATCHES "opencv_contrib_world")
 
55
  list(REMOVE_ITEM _modules "opencv_contrib_world")
 
56
  list(INSERT _modules 0 "opencv_contrib_world")
 
57
endif()
 
58
 
 
59
fix_prefix(_modules TRUE)
 
60
fix_prefix(_extra FALSE)
 
61
fix_prefix(_3rdparty TRUE)
 
62
 
 
63
ocv_list_unique(_modules)
 
64
ocv_list_unique(_extra)
 
65
ocv_list_unique(_3rdparty)
 
66
 
 
67
set(OPENCV_PC_LIBS
 
68
  "-L\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}"
 
69
  "${_modules}"
 
70
)
 
71
if (BUILD_SHARED_LIBS)
 
72
  set(OPENCV_PC_LIBS_PRIVATE "${_extra}")
 
73
else()
 
74
  set(OPENCV_PC_LIBS_PRIVATE
 
75
    "-L\${exec_prefix}/${OPENCV_3P_LIB_INSTALL_PATH}"
 
76
    "${_3rdparty}"
 
77
    "${_extra}"
 
78
  )
 
79
endif()
 
80
string(REPLACE ";" " " OPENCV_PC_LIBS "${OPENCV_PC_LIBS}")
 
81
string(REPLACE ";" " " OPENCV_PC_LIBS_PRIVATE "${OPENCV_PC_LIBS_PRIVATE}")
 
82
 
 
83
#generate the .pc file
 
84
set(prefix      "${CMAKE_INSTALL_PREFIX}")
 
85
set(exec_prefix "\${prefix}")
 
86
set(libdir      "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}")
 
87
set(includedir  "\${prefix}/${OPENCV_INCLUDE_INSTALL_PATH}")
 
88
 
 
89
if(INSTALL_TO_MANGLED_PATHS)
 
90
  set(OPENCV_PC_FILE_NAME "opencv-${OPENCV_VERSION}.pc")
 
91
else()
 
92
  set(OPENCV_PC_FILE_NAME opencv.pc)
 
93
endif()
 
94
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/opencv-XXX.pc.in"
 
95
               "${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME}"
 
96
               @ONLY)
 
97
 
 
98
if(UNIX AND NOT ANDROID)
 
99
  install(FILES ${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME} DESTINATION ${OPENCV_LIB_INSTALL_PATH}/pkgconfig COMPONENT dev)
 
100
endif()