cmake_minimum_required(VERSION 2.6)
#Module name, cmake will add lib prefix if the build result is libary.
#"LOCAL_MODULE" in Makefile
project(mtkcutils)

#add complie options
#"CFLAGS" & "CCFLAGS" in Makefile
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fPIC -O2 -Wall -std=gnu99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 -std=c++11")

#add header files (-I -L), CMAKE_CURRENT_SOURCE_DIR is the path this CMakeLists.txt located.
#"-I" & "-L" in Makefile
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../include/")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../include/log/")

#add source file, and gen shared lib.
#Replace "SHARED" as "STATIC" to gen static lib; And use add_executable() to gen bin.
set(src_fils
    sockets.cpp
    sockets_unix.cpp 
    native_handle.c 
    sched_policy.c 
    android_get_control_file.cpp 
    socket_local_client_unix.c
    socket_local_server_unix.c
    strdup16to8.c
    strdup8to16.c)
add_library(mtkcutils SHARED ${src_fils})

#add dependency to this module
#set(link_libs mtklog)
#target_link_libraries(mtkcutils ${link_libs})

#install results to certain folder;
install(TARGETS mtkcutils
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})



