xref: /OK3568_Linux_fs/external/mpp/osal/CMakeLists.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1# vim: syntax=cmake
2cmake_minimum_required(VERSION 2.6.3)
3PROJECT(osal C CXX)
4INCLUDE(GNUInstallDirs)
5
6find_package(Threads)
7
8set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
9set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_GNU_SOURCE")
10set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64")
11set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
12
13if (HAVE_DRM)
14    add_definitions(-DHAVE_DRM)
15    set(DRM_FILES allocator/allocator_drm.c)
16    message(STATUS "compile with drm support")
17else()
18    message(STATUS "compile without drm support")
19endif()
20
21set(MPP_ALLOCATOR
22    allocator/allocator_std.c
23    allocator/allocator_ion.c
24    allocator/allocator_ext_dma.c
25    allocator/allocator_dma_heap.c
26    ${DRM_FILES}
27)
28
29set(MPP_DRIVER
30    driver/mpp_server.cpp
31    driver/mpp_device.c
32    driver/mpp_service.c
33    driver/vcodec_service.c
34)
35
36add_library(osal STATIC
37    mpp_soc.cpp
38    mpp_platform.cpp
39    mpp_runtime.cpp
40    mpp_allocator.cpp
41    mpp_mem_pool.cpp
42    mpp_callback.cpp
43    mpp_eventfd.cpp
44    mpp_thread.cpp
45    mpp_compat.cpp
46    mpp_common.cpp
47    mpp_queue.cpp
48    mpp_trace.cpp
49    mpp_lock.cpp
50    mpp_time.cpp
51    mpp_list.cpp
52    mpp_mem.cpp
53    mpp_env.cpp
54    mpp_log.cpp
55    osal_2str.c
56    # Those files have a compiler marco protection, so only target
57    # OS will be built
58    android/os_allocator.c
59    android/os_mem.c
60    android/os_env.c
61    android/os_log.c
62    linux/os_allocator.c
63    linux/os_mem.c
64    linux/os_env.c
65    linux/os_log.cpp
66    windows/os_allocator.c
67    windows/os_mem.c
68    windows/os_env.c
69    windows/os_log.c
70    ${MPP_ALLOCATOR}
71    ${MPP_DRIVER}
72)
73
74target_link_libraries(osal ${CMAKE_THREAD_LIBS_INIT})
75
76target_include_directories(osal PUBLIC
77    "${CMAKE_CURRENT_SOURCE_DIR}"
78    "${CMAKE_CURRENT_SOURCE_DIR}/inc"
79    "${CMAKE_CURRENT_SOURCE_DIR}/allocator"
80    "${CMAKE_CURRENT_SOURCE_DIR}/driver/inc"
81)
82
83set_target_properties(osal PROPERTIES FOLDER "osal")
84
85# leave those special platform here
86if(ANDROID)
87    add_definitions(-static)
88    # in Android pthread is in libc, also need liblog
89    target_link_libraries(osal log m)
90endif(ANDROID)
91
92# unit test
93add_subdirectory(test)
94