Commit d10f8050 authored by fbarchard@google.com's avatar fbarchard@google.com

Improve cmake build. Add unittests to cmake build and automatically detect jpeg…

Improve cmake build.  Add unittests to cmake build and automatically detect jpeg support. This change was originally generated to support the build of libyuv in naclports: https://chromium.googlesource.com/external/naclports/+/master/ports/libyuv/.  Also add cmake artifacts to .gitignore file.
BUG=366
TESTED=build and run unittests with cmake
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/27009004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1146 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 44b8fd36
...@@ -20,3 +20,12 @@ tools/python ...@@ -20,3 +20,12 @@ tools/python
tools/valgrind tools/valgrind
tools/win tools/win
# Files generated by CMake build
CMakeFiles/
CMakeCache.txt
Makefile
convert
libgtest.a
libyuv.a
libyuv_unittest
cmake_install.cmake
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
# Basic CMakeLists for libyuv, compiles w/o the jpeg library # CMakeLists for libyuv
# created for "roxlu build system" to compile libyuv on windows # Originally created for "roxlu build system" to compile libyuv on windows
# Run with -DTEST=ON to build unit tests
option(TEST "Built unit tests" OFF)
set(ly_base_dir ${CMAKE_CURRENT_LIST_DIR}) set(ly_base_dir ${CMAKE_CURRENT_LIST_DIR})
set(ly_src_dir ${ly_base_dir}/source/) set(ly_src_dir ${ly_base_dir}/source/)
...@@ -18,6 +20,7 @@ set(ly_source_files ...@@ -18,6 +20,7 @@ set(ly_source_files
${ly_src_dir}/convert_argb.cc ${ly_src_dir}/convert_argb.cc
${ly_src_dir}/convert_from.cc ${ly_src_dir}/convert_from.cc
${ly_src_dir}/convert_from_argb.cc ${ly_src_dir}/convert_from_argb.cc
${ly_src_dir}/convert_jpeg.cc
${ly_src_dir}/convert_to_argb.cc ${ly_src_dir}/convert_to_argb.cc
${ly_src_dir}/convert_to_i420.cc ${ly_src_dir}/convert_to_i420.cc
${ly_src_dir}/cpu_id.cc ${ly_src_dir}/cpu_id.cc
...@@ -40,16 +43,26 @@ set(ly_source_files ...@@ -40,16 +43,26 @@ set(ly_source_files
${ly_src_dir}/scale_common.cc ${ly_src_dir}/scale_common.cc
${ly_src_dir}/scale_mips.cc ${ly_src_dir}/scale_mips.cc
${ly_src_dir}/scale_neon.cc ${ly_src_dir}/scale_neon.cc
${ly_src_dir}/scale_posix.cc
${ly_src_dir}/scale_win.cc ${ly_src_dir}/scale_win.cc
${ly_src_dir}/video_common.cc ${ly_src_dir}/video_common.cc
# ${ly_src_dir}/convert_jpeg.cc
) )
if (WIN32) set(ly_unittest_sources
list(APPEND ly_source_files ${ly_base_dir}/unit_test/basictypes_test.cc
${ly_src_dir}/scale_win.cc ${ly_base_dir}/unit_test/compare_test.cc
) ${ly_base_dir}/unit_test/convert_test.cc
endif() ${ly_base_dir}/unit_test/cpu_test.cc
${ly_base_dir}/unit_test/math_test.cc
${ly_base_dir}/unit_test/planar_test.cc
${ly_base_dir}/unit_test/rotate_argb_test.cc
${ly_base_dir}/unit_test/rotate_test.cc
${ly_base_dir}/unit_test/scale_argb_test.cc
${ly_base_dir}/unit_test/scale_test.cc
${ly_base_dir}/unit_test/unit_test.cc
${ly_base_dir}/unit_test/video_common_test.cc
${ly_base_dir}/unit_test/version_test.cc
)
set(ly_header_files set(ly_header_files
${ly_inc_dir}/libyuv/basic_types.h ${ly_inc_dir}/libyuv/basic_types.h
...@@ -76,7 +89,42 @@ include_directories(${ly_inc_dir}) ...@@ -76,7 +89,42 @@ include_directories(${ly_inc_dir})
add_library(${ly_lib_name} STATIC ${ly_source_files}) add_library(${ly_lib_name} STATIC ${ly_source_files})
add_executable(convert ${ly_base_dir}/util/convert.cc)
target_link_libraries(convert ${ly_lib_name})
include(FindJPEG)
if (JPEG_FOUND)
include_directories(${JPEG_INCLUDE_DIR})
target_link_libraries(convert ${JPEG_LIBRARY})
add_definitions(-DHAVE_JPEG)
endif()
if(TEST)
find_library(GTEST_LIBRARY gtest)
if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND")
set(GTEST_SRC_DIR /usr/src/gtest)
if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc)
message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}")
set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc)
add_library(gtest STATIC ${gtest_sources})
include_directories(${GTEST_SRC_DIR})
set(GTEST_LIBRARY gtest)
else()
message(FATAL_ERROR "TEST is set but unable to find gtest library")
endif()
endif()
add_executable(libyuv_unittest ${ly_unittest_sources})
target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY} pthread)
if (JPEG_FOUND)
target_link_libraries(libyuv_unittest ${JPEG_LIBRARY})
endif()
endif()
if(NACL AND NACL_LIBC STREQUAL "newlib")
target_link_libraries(libyuv_unittest glibc-compat)
endif()
install(TARGETS ${ly_lib_name} DESTINATION lib) install(TARGETS ${ly_lib_name} DESTINATION lib)
install(FILES ${ly_header_files} DESTINATION include/libyuv) install(FILES ${ly_header_files} DESTINATION include/libyuv)
install(FILES ${ly_inc_dir}/libyuv.h DESTINATION include/) install(FILES ${ly_inc_dir}/libyuv.h DESTINATION include/)
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1145 Version: 1146
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1145 #define LIBYUV_VERSION 1146
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h>
#include "libyuv/basic_types.h" #include "libyuv/basic_types.h"
#include "libyuv/cpu_id.h" #include "libyuv/cpu_id.h"
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <time.h>
#include "libyuv/cpu_id.h" #include "libyuv/cpu_id.h"
#include "libyuv/rotate_argb.h" #include "libyuv/rotate_argb.h"
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <time.h>
#include "libyuv/cpu_id.h" #include "libyuv/cpu_id.h"
#include "libyuv/rotate.h" #include "libyuv/rotate.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment