• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# CMakeLists for libyuv
2# Originally created for "roxlu build system" to compile libyuv on windows
3# Run with -DTEST=ON to build unit tests
4
5PROJECT ( YUV C CXX )	# "C" is required even for C++ projects
6CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
7OPTION( TEST "Built unit tests" OFF )
8
9SET ( ly_base_dir	${PROJECT_SOURCE_DIR} )
10SET ( ly_src_dir	${ly_base_dir}/source )
11SET ( ly_inc_dir	${ly_base_dir}/include )
12SET ( ly_tst_dir	${ly_base_dir}/unit_test )
13SET ( ly_lib_name	yuv )
14SET ( ly_lib_static	${ly_lib_name} )
15SET ( ly_lib_shared	${ly_lib_name}_shared )
16
17FILE ( GLOB_RECURSE	ly_source_files ${ly_src_dir}/*.cc )
18LIST ( SORT			ly_source_files )
19
20FILE ( GLOB_RECURSE	ly_unittest_sources ${ly_tst_dir}/*.cc )
21LIST ( SORT			ly_unittest_sources )
22
23INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} )
24
25# this creates the static library (.a)
26ADD_LIBRARY				( ${ly_lib_static} STATIC ${ly_source_files} )
27
28# this creates the shared library (.so)
29ADD_LIBRARY				( ${ly_lib_shared} SHARED ${ly_source_files} )
30SET_TARGET_PROPERTIES	( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
31SET_TARGET_PROPERTIES	( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
32
33# this creates the conversion tool
34ADD_EXECUTABLE			( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
35TARGET_LINK_LIBRARIES	( yuvconvert ${ly_lib_static} )
36
37
38INCLUDE ( FindJPEG )
39if (JPEG_FOUND)
40  include_directories( ${JPEG_INCLUDE_DIR} )
41  target_link_libraries( yuvconvert ${JPEG_LIBRARY} )
42  add_definitions( -DHAVE_JPEG )
43endif()
44
45if(TEST)
46  find_library(GTEST_LIBRARY gtest)
47  if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND")
48    set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources")
49    if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc)
50      message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}")
51      set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc)
52      add_library(gtest STATIC ${gtest_sources})
53      include_directories(${GTEST_SRC_DIR})
54      include_directories(${GTEST_SRC_DIR}/include)
55      set(GTEST_LIBRARY gtest)
56    else()
57      message(FATAL_ERROR "TEST is set but unable to find gtest library")
58    endif()
59  endif()
60
61  add_executable(libyuv_unittest ${ly_unittest_sources})
62  target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY} pthread)
63  if (JPEG_FOUND)
64    target_link_libraries(libyuv_unittest ${JPEG_LIBRARY})
65  endif()
66
67  if(NACL AND NACL_LIBC STREQUAL "newlib")
68    target_link_libraries(libyuv_unittest glibc-compat)
69  endif()
70
71  target_link_libraries(libyuv_unittest gflags)
72endif()
73
74
75# install the conversion tool, .so, .a, and all the header files
76INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert			DESTINATION bin )
77INSTALL ( TARGETS ${ly_lib_static}						DESTINATION lib )
78INSTALL ( TARGETS ${ly_lib_shared} LIBRARY				DESTINATION lib )
79INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/		DESTINATION include )
80
81# create the .deb and .rpm packages using cpack
82INCLUDE ( CM_linux_packages.cmake )
83
84