Home | History | Annotate | Download | only in files
      1 cmake_minimum_required(VERSION 2.8)
      2 
      3 # CMakeLists for libyuv
      4 # Originally created for "roxlu build system" to compile libyuv on windows
      5 # Run with -DTEST=ON to build unit tests
      6 option(TEST "Built unit tests" OFF)
      7 
      8 set(ly_base_dir ${CMAKE_CURRENT_LIST_DIR})
      9 set(ly_src_dir ${ly_base_dir}/source/)
     10 set(ly_inc_dir ${ly_base_dir}/include)
     11 set(ly_lib_name "yuv")
     12 
     13 set(ly_source_files
     14   ${ly_src_dir}/compare.cc
     15   ${ly_src_dir}/compare_common.cc
     16   ${ly_src_dir}/compare_neon.cc
     17   ${ly_src_dir}/compare_neon64.cc
     18   ${ly_src_dir}/compare_gcc.cc
     19   ${ly_src_dir}/compare_win.cc
     20   ${ly_src_dir}/convert.cc
     21   ${ly_src_dir}/convert_argb.cc
     22   ${ly_src_dir}/convert_from.cc
     23   ${ly_src_dir}/convert_from_argb.cc
     24   ${ly_src_dir}/convert_jpeg.cc
     25   ${ly_src_dir}/convert_to_argb.cc
     26   ${ly_src_dir}/convert_to_i420.cc
     27   ${ly_src_dir}/cpu_id.cc
     28   ${ly_src_dir}/mjpeg_decoder.cc
     29   ${ly_src_dir}/mjpeg_validate.cc
     30   ${ly_src_dir}/planar_functions.cc
     31   ${ly_src_dir}/rotate.cc
     32   ${ly_src_dir}/rotate_any.cc
     33   ${ly_src_dir}/rotate_argb.cc
     34   ${ly_src_dir}/rotate_common.cc
     35   ${ly_src_dir}/rotate_mips.cc
     36   ${ly_src_dir}/rotate_neon.cc
     37   ${ly_src_dir}/rotate_neon64.cc
     38   ${ly_src_dir}/rotate_gcc.cc
     39   ${ly_src_dir}/rotate_win.cc
     40   ${ly_src_dir}/row_any.cc
     41   ${ly_src_dir}/row_common.cc
     42   ${ly_src_dir}/row_mips.cc
     43   ${ly_src_dir}/row_neon.cc
     44   ${ly_src_dir}/row_neon64.cc
     45   ${ly_src_dir}/row_gcc.cc
     46   ${ly_src_dir}/row_win.cc
     47   ${ly_src_dir}/scale.cc
     48   ${ly_src_dir}/scale_any.cc
     49   ${ly_src_dir}/scale_argb.cc
     50   ${ly_src_dir}/scale_common.cc
     51   ${ly_src_dir}/scale_mips.cc
     52   ${ly_src_dir}/scale_neon.cc
     53   ${ly_src_dir}/scale_neon64.cc
     54   ${ly_src_dir}/scale_gcc.cc
     55   ${ly_src_dir}/scale_win.cc
     56   ${ly_src_dir}/video_common.cc
     57 )
     58 
     59 set(ly_unittest_sources
     60   ${ly_base_dir}/unit_test/basictypes_test.cc
     61   ${ly_base_dir}/unit_test/color_test.cc
     62   ${ly_base_dir}/unit_test/compare_test.cc
     63   ${ly_base_dir}/unit_test/convert_test.cc
     64   ${ly_base_dir}/unit_test/cpu_test.cc
     65   ${ly_base_dir}/unit_test/math_test.cc
     66   ${ly_base_dir}/unit_test/planar_test.cc
     67   ${ly_base_dir}/unit_test/rotate_argb_test.cc
     68   ${ly_base_dir}/unit_test/rotate_test.cc
     69   ${ly_base_dir}/unit_test/scale_argb_test.cc
     70   ${ly_base_dir}/unit_test/scale_test.cc
     71   ${ly_base_dir}/unit_test/unit_test.cc
     72   ${ly_base_dir}/unit_test/video_common_test.cc
     73 )
     74 
     75 set(ly_header_files
     76   ${ly_inc_dir}/libyuv/basic_types.h
     77   ${ly_inc_dir}/libyuv/compare.h
     78   ${ly_inc_dir}/libyuv/convert.h
     79   ${ly_inc_dir}/libyuv/convert_argb.h
     80   ${ly_inc_dir}/libyuv/convert_from.h
     81   ${ly_inc_dir}/libyuv/convert_from_argb.h
     82   ${ly_inc_dir}/libyuv/cpu_id.h
     83   ${ly_inc_dir}/libyuv/planar_functions.h
     84   ${ly_inc_dir}/libyuv/rotate.h
     85   ${ly_inc_dir}/libyuv/rotate_argb.h
     86   ${ly_inc_dir}/libyuv/rotate_row.h
     87   ${ly_inc_dir}/libyuv/row.h
     88   ${ly_inc_dir}/libyuv/scale.h
     89   ${ly_inc_dir}/libyuv/scale_argb.h
     90   ${ly_inc_dir}/libyuv/scale_row.h
     91   ${ly_inc_dir}/libyuv/version.h
     92   ${ly_inc_dir}/libyuv/video_common.h
     93   ${ly_inc_dir}/libyuv/mjpeg_decoder.h
     94 )
     95 
     96 include_directories(${ly_inc_dir})
     97 
     98 add_library(${ly_lib_name} STATIC ${ly_source_files})
     99 
    100 add_executable(convert ${ly_base_dir}/util/convert.cc)
    101 target_link_libraries(convert ${ly_lib_name})
    102 
    103 include(FindJPEG)
    104 if (JPEG_FOUND)
    105   include_directories(${JPEG_INCLUDE_DIR})
    106   target_link_libraries(convert ${JPEG_LIBRARY})
    107   add_definitions(-DHAVE_JPEG)
    108 endif()
    109 
    110 if(TEST)
    111   find_library(GTEST_LIBRARY gtest)
    112   if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND")
    113     set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources")
    114     if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc)
    115       message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}")
    116       set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc)
    117       add_library(gtest STATIC ${gtest_sources})
    118       include_directories(${GTEST_SRC_DIR})
    119       include_directories(${GTEST_SRC_DIR}/include)
    120       set(GTEST_LIBRARY gtest)
    121     else()
    122       message(FATAL_ERROR "TEST is set but unable to find gtest library")
    123     endif()
    124   endif()
    125 
    126   add_executable(libyuv_unittest ${ly_unittest_sources})
    127   target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY} pthread)
    128   if (JPEG_FOUND)
    129     target_link_libraries(libyuv_unittest ${JPEG_LIBRARY})
    130   endif()
    131   
    132   if(NACL AND NACL_LIBC STREQUAL "newlib")
    133     target_link_libraries(libyuv_unittest glibc-compat)
    134   endif()
    135 
    136   target_link_libraries(libyuv_unittest gflags)
    137   
    138 endif()
    139 
    140 install(TARGETS ${ly_lib_name} DESTINATION lib)
    141 install(FILES ${ly_header_files} DESTINATION include/libyuv)
    142 install(FILES ${ly_inc_dir}/libyuv.h DESTINATION include/)
    143