crb912
3/3/2020 - 8:40 AM

cmake example

一个cmake的范例

cmake_minimum_required (VERSION 2.8)
# cmake_minimum_required (VERSION 2.8 FATAL_ERROR)

# set your project name and version number.
PROJECT (silkdecode LANGUAGES C)
set(CMAKE_BUILD_TYPE Release)


# Set the project source dir (just convention)
set( SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
set( BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )


# Bring the headers, add .h files into the project
include_directories(./thirdparty/silk-v3-decoder/silk/src)
include_directories(./thirdparty/silk-v3-decoder/silk/interface)
include_directories(./thirdparty/lame)


# 编译解码库
#add_subdirectory(./thirdparty/silk-v3-decoder)


# use thirdparty static library
if (UNIX)
    link_directories(${CMAKE_SOURCE_DIR}/thirdparty/libs/linux)
    set ( PROJECT_LINK_LIBS SKP_SILK_SDK)
else()
    link_directories(${CMAKE_SOURCE_DIR}/thirdparty/libs/windows)
    set ( PROJECT_LINK_LIBS silk-v3.lib mpghip.lib)
endif()


#  add the sources
file(GLOB SILK_SOURCES "./thirdparty/silk-v3-decoder/silk/src/*.c")
set(SOURCES entry.c ${SILK_SOURCES})

# Generate the static library from the sources
add_library(silkv3topcm SHARED ${SOURCES})
#add_executable(silkv3topcm ${SOURCES})

#target_link_libraries(silkv3topcm ${PROJECT_LINK_LIBS})
install(TARGETS silkv3topcm DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)