Update to 2.0.0 tree from current Fremantle build
[opencv] / src / highgui / CMakeLists.txt
1 # ----------------------------------------------------------------------------
2 #  CMake file for highgui. See root CMakeLists.txt
3 #   Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
4 #   Jose Luis Blanco, 2008
5 # ----------------------------------------------------------------------------
6 project(highgui)
7
8 if(OPENCV_BUILD_3RDPARTY_LIBS)
9     include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/include")
10     add_definitions(-DHAVE_JPEG -DHAVE_PNG -DHAVE_TIFF -DHAVE_JASPER)
11 endif()
12
13 if(MSVC)
14     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libcmt.lib")
15 endif()
16
17 file(GLOB grfmt_hdrs grfmt*.h)
18 file(GLOB grfmt_srcs grfmt*.cpp)
19 set(grfmt_hdrs bitstrm.h ${grfmt_hdrs})
20 set(grfmt_srcs bitstrm.cpp ${grfmt_srcs})
21
22 source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
23
24 set(highgui_srcs
25     cvcap.cpp
26     cvcap_images.cpp
27     image.cpp
28     loadsave.cpp
29     precomp.cpp
30     utils.cpp
31     window.cpp
32     )
33
34 set(highgui_hdrs _highgui.h utils.h)
35
36 set(lib_hdr_names highgui.h highgui.hpp)
37 set(highgui_ext_hdrs)
38 foreach(h ${lib_hdr_names})
39     list(APPEND highgui_ext_hdrs "${CMAKE_CURRENT_SOURCE_DIR}/../../include/opencv/${h}")
40 endforeach()
41
42 if(WIN32)
43     set(highgui_srcs ${highgui_srcs} window_w32.cpp cvcap_vfw.cpp cvcap_cmu.cpp cvcap_w32.cpp cvcap_dshow.cpp)
44     if(HAVE_MIL)
45         set(highgui_srcs ${highgui_srcs} cvcap_mil.cpp)
46     endif()
47 endif()
48
49 if(UNIX)
50     if(HAVE_GTK)
51         set(highgui_srcs ${highgui_srcs} window_gtk.cpp)
52     endif()
53
54     if(HAVE_XINE)
55         set(highgui_srcs ${highgui_srcs} cvcap_xine.cpp)
56     endif()
57
58     if(HAVE_DC1394_2)
59         set(highgui_srcs ${highgui_srcs} cvcap_dc1394_v2.cpp)
60     endif()
61
62     if(HAVE_DC1394)
63         set(highgui_srcs ${highgui_srcs} cvcap_dc1394.cpp)
64     endif()
65
66     if(HAVE_FFMPEG)
67         set(highgui_srcs ${highgui_srcs} cvcap_ffmpeg.cpp)
68     endif()
69
70     if(HAVE_GSTREAMER)
71         set(highgui_srcs ${highgui_srcs} cvcap_gstreamer.cpp gstappsink.cpp)
72         set(highgui_hdrs ${highgui_hdrs} gstappsink.h)
73     endif()
74
75     if(HAVE_UNICAP)
76         set(highgui_srcs ${highgui_srcs} cvcap_unicap.cpp)
77     endif()
78
79         if(HAVE_LIBV4L)
80                 set(highgui_srcs ${highgui_srcs} cvcap_libv4l.cpp)
81         else()
82                 set(highgui_srcs ${highgui_srcs} cvcap_v4l.cpp)
83         endif()
84
85     if(NOT APPLE AND NOT OPENCV_BUILD_3RDPARTY_LIBS)
86         if(JPEG_FOUND)
87             add_definitions(-DHAVE_JPEG)
88             include_directories(${JPEG_INCLUDE_DIR})
89         endif()
90         if(PNG_FOUND)
91             add_definitions(-DHAVE_PNG)
92             add_definitions(${PNG_DEFINITIONS})
93             include_directories(${PNG_INCLUDE_DIR})
94         endif()
95         if(TIFF_FOUND)
96             add_definitions(-DHAVE_TIFF)
97             include_directories(${TIFF_INCLUDE_DIR})
98         endif()
99         if(JASPER_FOUND)
100             add_definitions(-DHAVE_JASPER)
101             include_directories(${JASPER_INCLUDE_DIR})
102         endif()
103     endif()
104
105     foreach(P ${HIGHGUI_INCLUDE_DIRS})
106         include_directories(${P})
107     endforeach()
108
109     foreach(P ${HIGHGUI_LIBRARY_DIRS})
110         link_directories(${P})
111     endforeach()
112 endif()
113
114 if(APPLE)
115     add_definitions(-DHAVE_QUICKTIME=1 -DHAVE_CARBON=1)
116     if(NOT OPENCV_BUILD_3RDPARTY_LIBS)
117         add_definitions(-DHAVE_IMAGEIO=1)
118     endif()
119     set(highgui_srcs ${highgui_srcs} window_carbon.cpp cvcap_qt.cpp)
120 endif(APPLE)
121
122 source_group("Src" FILES ${highgui_srcs} ${highgui_hdrs})
123 source_group("Include" FILES ${highgui_ext_hdrs})
124
125 if(OPENCV_BUILD_3RDPARTY_LIBS)
126     if(WIN32)
127         link_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/lib")
128     endif()
129     link_directories(
130         "${CMAKE_BINARY_DIR}/3rdparty/lib"
131         "${CMAKE_BINARY_DIR}/3rdparty/lib/${ConfigurationName}"
132         )
133 endif()
134
135 set(lib_srcs ${highgui_srcs} ${grfmt_srcs})
136
137 # ----------------------------------------------------------------------------------
138 #                               Define the library target:
139 # ----------------------------------------------------------------------------------
140 set(the_target "highgui")
141
142 add_definitions(-DHIGHGUI_EXPORTS -DCVAPI_EXPORTS)
143
144 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../include/opencv"
145                     "${CMAKE_CURRENT_SOURCE_DIR}"
146                     "${CMAKE_CURRENT_BINARY_DIR}")
147
148 add_library(${the_target} SHARED ${lib_srcs} ${highgui_hdrs} ${grfmt_hdrs} ${highgui_ext_hdrs})
149
150 if(PCHSupport_FOUND)
151     set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/_highgui.h)
152     if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*")
153         if(${CMAKE_GENERATOR} MATCHES "Visual*")
154             set(${the_target}_pch "precomp.cpp")
155         endif()            
156         add_native_precompiled_header(${the_target} ${pch_header})
157     elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles")
158         add_precompiled_header(${the_target} ${pch_header})
159     endif()
160 endif()
161
162 # For dynamic link numbering convenions
163 set_target_properties(${the_target} PROPERTIES
164     VERSION ${OPENCV_VERSION}
165     SOVERSION ${OPENCV_SOVERSION}
166     OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}"
167     )
168
169 # Additional target properties
170 set_target_properties(${the_target} PROPERTIES
171         DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
172         ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/"
173         RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
174         LINK_INTERFACE_LIBRARIES ""
175         )
176
177 if(MSVC)
178         set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib")
179 endif(MSVC)
180
181 # Dependencies of this target:
182 add_dependencies(${the_target} cv cxcore)
183
184 # Add the required libraries for linking:
185 target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} cxcore cv ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${TIFF_LIBRARIES} ${JASPER_LIBRARIES} ${HIGHGUI_LIBRARIES})
186
187 if(OPENCV_BUILD_3RDPARTY_LIBS)
188         add_dependencies(${the_target} libjasper libjpeg libpng libtiff zlib)
189         target_link_libraries(${the_target} libjasper libjpeg libpng libtiff zlib)
190 endif()
191 if(WIN32)
192         target_link_libraries(${the_target} comctl32 gdi32 ole32)
193         
194         if (MSVC)\r
195                 target_link_libraries(${the_target} vfw32)\r
196         endif()
197
198         if(MINGW)
199                 target_link_libraries(${the_target} vfw32 winmm videoInput strmiids)
200         endif()
201 endif()
202
203 if(APPLE)
204         target_link_libraries(${the_target} "-framework Carbon -framework CoreFoundation -framework QuickTime -framework QuartzCore")
205 endif()
206
207 install(TARGETS ${the_target}
208         RUNTIME DESTINATION bin COMPONENT main
209         LIBRARY DESTINATION lib COMPONENT main
210         ARCHIVE DESTINATION lib COMPONENT main)
211
212 install(FILES ${highgui_ext_hdrs}
213         DESTINATION include/opencv
214         COMPONENT main)