CMakeLists.txt 3.2 KB

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