Commit a169bcf4 authored by NzSN's avatar NzSN

CMakeLists.txt update.

parent 50376482
...@@ -12,12 +12,14 @@ set(INCLUDE ${ROOT}/src ${ROOT}/lib/include) ...@@ -12,12 +12,14 @@ set(INCLUDE ${ROOT}/src ${ROOT}/lib/include)
option(enable_trmem "Enable/Disable TransientMemProto" ON) option(enable_trmem "Enable/Disable TransientMemProto" ON)
option(enable_movmem "Enable/Disable MovMemProto" ON) option(enable_movmem "Enable/Disable MovMemProto" ON)
option(IS_EMCC_ENV "Is protocol be used in WASM of not" OFF)
option(DEBUG "Only enable during development" OFF) option(DEBUG "Only enable during development" OFF)
include_directories(${INCLUDE}) include_directories(${INCLUDE})
if(DEBUG) if(DEBUG)
message("Fetching googletest...")
# Google Test # Google Test
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
...@@ -27,8 +29,12 @@ FetchContent_Declare( ...@@ -27,8 +29,12 @@ FetchContent_Declare(
# For Windows: Prevent overriding the parent project's compiler/linker settings # For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest) FetchContent_MakeAvailable(googletest)
message("Fetching googletest...Done")
endif()
set(LIBAV libav) set(LIBAV libav)
if (DEBUG)
ExternalProject_Add( ExternalProject_Add(
libav libav
GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git
...@@ -37,6 +43,7 @@ ExternalProject_Add( ...@@ -37,6 +43,7 @@ ExternalProject_Add(
CONFIGURE_COMMAND ../${LIBAV}/configure --disable-x86asm --enable-libx264 --enable-debug --extra-cflags=-g CONFIGURE_COMMAND ../${LIBAV}/configure --disable-x86asm --enable-libx264 --enable-debug --extra-cflags=-g
--extra-ldflags=-g --enable-gpl --shlibdir=${PROJECT_SOURCE_DIR}/lib/ --extra-ldflags=-g --enable-gpl --shlibdir=${PROJECT_SOURCE_DIR}/lib/
--disable-ffmpeg --disable-ffprobe --disable-ffplay --prefix=${PROJECT_SOURCE_DIR}/lib/ --disable-ffmpeg --disable-ffprobe --disable-ffplay --prefix=${PROJECT_SOURCE_DIR}/lib/
--enable-shared
BUILD_COMMAND make -j BUILD_COMMAND make -j
INSTALL_COMMAND make install INSTALL_COMMAND make install
UPDATE_COMMAND "" UPDATE_COMMAND ""
...@@ -65,7 +72,15 @@ endif() ...@@ -65,7 +72,15 @@ endif()
# Library # Library
add_library(shmproto ${SRC_Files}) if(NOT IS_EMCC_ENV)
add_library(shmproto SHARED ${SRC_Files})
target_link_libraries(shmproto
avformat avcodec avdevice avfilter avutil
swresample swscale postproc z x264 lzma)
else()
add_library(shmproto STATIC ${SRC_Files})
endif()
install(TARGETS shmproto install(TARGETS shmproto
DESTINATION ${CMAKE_INSTALL_LIBDIR}) DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${ROOT}/src/proto/proto.h install(FILES ${ROOT}/src/proto/proto.h
...@@ -73,19 +88,7 @@ install(FILES ${ROOT}/src/proto/proto.h ...@@ -73,19 +88,7 @@ install(FILES ${ROOT}/src/proto/proto.h
${ROOT}/src/proto/proto.h ${ROOT}/src/proto/proto.h
${ROOT}/src/proto/movMemProto.h ${ROOT}/src/proto/movMemProto.h
DESTINATION include) DESTINATION include)
target_link_libraries(shmproto
${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(shmproto z)
target_link_libraries(shmproto x264)
target_link_libraries(shmproto lzma)
if(DEBUG) if(DEBUG)
...@@ -94,7 +97,7 @@ set(Tests ${ROOT}/tests) ...@@ -94,7 +97,7 @@ set(Tests ${ROOT}/tests)
set(TestCases set(TestCases
${Tests}/ioctxTestCases.cc) ${Tests}/ioctxTestCases.cc)
add_executable(unittest ${TestCases} ${SRC_Files}) add_executable(unittest ${TestCases} ${SRC_Files})
add_dependencies(unittest libav)
add_custom_command(TARGET unittest PRE_BUILD add_custom_command(TARGET unittest PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/resources/ $<TARGET_FILE_DIR:unittest>/resources) ${CMAKE_SOURCE_DIR}/resources/ $<TARGET_FILE_DIR:unittest>/resources)
......
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