Commit 1e0a94a7 authored by Linshizhi's avatar Linshizhi

Init

parents
Pipeline #17582 failed with stages
cmake_minimum_required(VERSION 3.16)
enable_testing()
include(ExternalProject)
project(SharedMemoryProtocol VERSION 0.1 DESCRIPTION "...")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -g -I..")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(ROOT .)
set(INCLUDE ${ROOT}/src ${ROOT}/lib/include)
# Google Test
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
set(LIBAV libav)
ExternalProject_Add(
libav
GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git
GIT_TAG n4.3.3
PREFIX ${PROJECT_SOURCE_DIR}/lib/.build/${LIBAV}
CONFIGURE_COMMAND ../${LIBAV}/configure --disable-x86asm --enable-libx264 --enable-debug --extra-cflags=-g
--extra-ldflags=-g --enable-gpl --shlibdir=${PROJECT_SOURCE_DIR}/lib/
--disable-ffmpeg --disable-ffprobe --disable-ffplay --prefix=${PROJECT_SOURCE_DIR}/lib/
BUILD_COMMAND make -j
INSTALL_COMMAND make install
)
set(SRC ${ROOT}/src)
set(CMAKE_CXX_STANDARD 20)
set(SRC_Files
${SRC}/ioctx.cc)
add_library(smp ${SRC_Files})
# Tests
set(Tests ${ROOT}/tests)
set(TestCases
${Tests}/ioctxTestCases.cc)
add_executable(unittest ${TestCases} ${SRC_Files})
add_dependencies(unittest libav)
include_directories(${INCLUDE})
add_custom_command(TARGET unittest PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/resources/ $<TARGET_FILE_DIR:unittest>/resources)
add_test(
NAME UNITTEST_DIRECTLY
COMMAND ./unittest)
# Link Google Test
target_link_libraries(unittest gtest_main)
target_link_libraries(unittest
${CMAKE_SOURCE_DIR}/lib/lib/libavformat.a
${CMAKE_SOURCE_DIR}/lib/lib/libavcodec.a
${CMAKE_SOURCE_DIR}/lib/lib/libavdevice.a
${CMAKE_SOURCE_DIR}/lib/lib/libavfilter.a
${CMAKE_SOURCE_DIR}/lib/lib/libavutil.a
${CMAKE_SOURCE_DIR}/lib/lib/libswresample.a
${CMAKE_SOURCE_DIR}/lib/lib/libswscale.a
${CMAKE_SOURCE_DIR}/lib/lib/libpostproc.a
)
target_link_libraries(unittest z)
target_link_libraries(unittest x264)
target_link_libraries(unittest lzma)
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