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").
9 # ${BIN_DIR}/unix-install/opencv.pc -> For use *with* "make install"
10 # -------------------------------------------------------------------------------------------
11 set(prefix "${CMAKE_INSTALL_PREFIX}")
12 set(exec_prefix "\${prefix}")
13 set(libdir "") #TODO: need link paths for OpenCV_EXTRA_COMPONENTS
14 set(includedir "\${prefix}/${OPENCV_INCLUDE_INSTALL_PATH}")
16 if(CMAKE_BUILD_TYPE MATCHES "Release")
22 #build the list of opencv libs and dependencies for all modules
23 set(OpenCV_LIB_COMPONENTS "")
24 set(OpenCV_EXTRA_COMPONENTS "")
25 foreach(m ${OPENCV_MODULES_PUBLIC})
26 list(INSERT OpenCV_LIB_COMPONENTS 0 ${${m}_MODULE_DEPS_${ocv_optkind}} ${m})
27 if(${m}_EXTRA_DEPS_${ocv_optkind})
28 list(INSERT OpenCV_EXTRA_COMPONENTS 0 ${${m}_EXTRA_DEPS_${ocv_optkind}})
32 ocv_list_unique(OpenCV_LIB_COMPONENTS)
33 ocv_list_unique(OpenCV_EXTRA_COMPONENTS)
34 ocv_list_reverse(OpenCV_LIB_COMPONENTS)
35 ocv_list_reverse(OpenCV_EXTRA_COMPONENTS)
37 #build the list of components
38 set(OpenCV_LIB_COMPONENTS_ "")
39 foreach(CVLib ${OpenCV_LIB_COMPONENTS})
40 get_target_property(libpath ${CVLib} LOCATION_${CMAKE_BUILD_TYPE})
41 get_filename_component(libname "${libpath}" NAME)
43 if(INSTALL_TO_MANGLED_PATHS)
44 set(libname "${libname}.${OPENCV_VERSION}")
47 #need better solution....
48 if(libpath MATCHES "3rdparty")
49 set(installDir "share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}")
51 set(installDir "${OPENCV_LIB_INSTALL_PATH}")
54 set(OpenCV_LIB_COMPONENTS_ "${OpenCV_LIB_COMPONENTS_} \${exec_prefix}/${installDir}/${libname}")
57 # add extra dependencies required for OpenCV
58 set(OpenCV_LIB_COMPONENTS ${OpenCV_LIB_COMPONENTS_})
59 if(OpenCV_EXTRA_COMPONENTS)
60 foreach(extra_component ${OpenCV_EXTRA_COMPONENTS})
62 if(extra_component MATCHES "^-[lL]" OR extra_component MATCHES "[\\/]")
63 set(maybe_l_prefix "")
65 set(maybe_l_prefix "-l")
68 set(OpenCV_LIB_COMPONENTS "${OpenCV_LIB_COMPONENTS} ${maybe_l_prefix}${extra_component}")
73 #generate the .pc file
74 if(INSTALL_TO_MANGLED_PATHS)
75 set(OPENCV_PC_FILE_NAME "opencv-${OPENCV_VERSION}.pc")
77 set(OPENCV_PC_FILE_NAME opencv.pc)
79 configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/opencv-XXX.pc.in"
80 "${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME}"
83 if(UNIX AND NOT ANDROID)
84 install(FILES ${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME} DESTINATION ${OPENCV_LIB_INSTALL_PATH}/pkgconfig)