You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
188 lines
4.8 KiB
CMake
188 lines
4.8 KiB
CMake
|
8 months ago
|
cmake_minimum_required(VERSION 3.10)
|
||
|
|
project(onvif)
|
||
|
|
|
||
|
|
# gSOAP 설정
|
||
|
|
set(GSOAP_PREFIX "/usr/local" CACHE PATH "gSOAP installation prefix")
|
||
|
|
set(GSOAP_BASE "${GSOAP_PREFIX}/share/gsoap")
|
||
|
|
set(GSOAP_PLUGINS "${GSOAP_BASE}/plugin")
|
||
|
|
set(GSOAP_IMPORT "${GSOAP_BASE}/import")
|
||
|
|
|
||
|
|
# SOAP 소스 파일
|
||
|
|
file(GLOB SOAP_SOURCES
|
||
|
|
"gen/soapC_*.cpp"
|
||
|
|
"gen/soap*.cpp"
|
||
|
|
"gen/stdsoap2.cpp"
|
||
|
|
)
|
||
|
|
|
||
|
|
# WSSE 소스
|
||
|
|
set(WSSE_SOURCES
|
||
|
|
${GSOAP_PLUGINS}/wsseapi.c
|
||
|
|
${GSOAP_PLUGINS}/smdevp.c
|
||
|
|
${GSOAP_PLUGINS}/mecevp.c
|
||
|
|
${GSOAP_BASE}/custom/struct_timeval.c
|
||
|
|
)
|
||
|
|
set_source_files_properties(${WSSE_SOURCES} PROPERTIES LANGUAGE CXX)
|
||
|
|
|
||
|
|
# ONVIF 서비스 구현 소스
|
||
|
|
file(GLOB SERVICE_SOURCES
|
||
|
|
"src/ServiceDevice.cpp"
|
||
|
|
"src/ServiceMedia.cpp"
|
||
|
|
"src/ServicePTZ.cpp"
|
||
|
|
"src/ServiceImaging.cpp"
|
||
|
|
"src/ServiceEvent.cpp"
|
||
|
|
"src/ServiceIO.cpp"
|
||
|
|
"src/ServiceAnalytics.cpp"
|
||
|
|
"src/ServiceRecording.cpp"
|
||
|
|
"src/ServiceReplay.cpp"
|
||
|
|
"src/ServiceReceiver.cpp"
|
||
|
|
"src/ServiceDisplay.cpp"
|
||
|
|
)
|
||
|
|
|
||
|
|
# SOAP 라이브러리
|
||
|
|
add_library(soap_lib STATIC
|
||
|
|
${SOAP_SOURCES}
|
||
|
|
${SERVICE_SOURCES} # 서비스 구현 추가
|
||
|
|
)
|
||
|
|
target_include_directories(soap_lib PUBLIC
|
||
|
|
${CMAKE_SOURCE_DIR}/gen
|
||
|
|
${CMAKE_SOURCE_DIR}/inc
|
||
|
|
${GSOAP_PREFIX}/include
|
||
|
|
${GSOAP_PLUGINS}
|
||
|
|
${GSOAP_IMPORT}
|
||
|
|
)
|
||
|
|
|
||
|
|
# onvif server 라이브러리
|
||
|
|
file(GLOB SERVER_SOURCES "src/server*.cpp")
|
||
|
|
add_library(onvif_server STATIC ${SERVER_SOURCES})
|
||
|
|
target_link_libraries(onvif_server PUBLIC soap_lib)
|
||
|
|
|
||
|
|
# 실행 파일
|
||
|
|
add_executable(onvif-server
|
||
|
|
src/onvif-server.cpp
|
||
|
|
src/onvif_impl.cpp
|
||
|
|
${WSSE_SOURCES}
|
||
|
|
)
|
||
|
|
|
||
|
|
target_link_libraries(onvif-server
|
||
|
|
PRIVATE
|
||
|
|
onvif_server
|
||
|
|
soap_lib
|
||
|
|
wsdd
|
||
|
|
v4l2rtsp
|
||
|
|
v4l2cpp
|
||
|
|
liveMedia
|
||
|
|
groupsock
|
||
|
|
BasicUsageEnvironment
|
||
|
|
UsageEnvironment
|
||
|
|
gsoapssl++
|
||
|
|
ssl
|
||
|
|
crypto
|
||
|
|
z
|
||
|
|
pthread
|
||
|
|
dl
|
||
|
|
)
|
||
|
|
|
||
|
|
# gSOAP 생성 코드
|
||
|
|
file(MAKE_DIRECTORY gen)
|
||
|
|
add_custom_command(
|
||
|
|
OUTPUT gen/onvif.h
|
||
|
|
COMMAND ${GSOAP_PREFIX}/bin/wsdl2h -d -Ntev -W -L -o gen/onvif.h ${CMAKE_SOURCE_DIR}/wsdl/*
|
||
|
|
COMMAND ${GSOAP_PREFIX}/bin/soapcpp2 -2jx gen/onvif.h -I${GSOAP_IMPORT} -I${GSOAP_BASE} -Iinc -dgen -f1000 -w
|
||
|
|
DEPENDS ${CMAKE_SOURCE_DIR}/wsdl/*
|
||
|
|
)
|
||
|
|
|
||
|
|
# 버전 설정
|
||
|
|
execute_process(
|
||
|
|
COMMAND git describe --tags --always --dirty
|
||
|
|
OUTPUT_VARIABLE VERSION
|
||
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||
|
|
)
|
||
|
|
add_definitions(-DVERSION="${VERSION}")
|
||
|
|
|
||
|
|
# 컴파일러 옵션
|
||
|
|
set(CMAKE_CXX_STANDARD 11)
|
||
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g2 -fpermissive")
|
||
|
|
|
||
|
|
# WSSE 소스를 C++로 컴파일하도록 설정
|
||
|
|
set_source_files_properties(
|
||
|
|
${GSOAP_PLUGINS}/wsseapi.c
|
||
|
|
${GSOAP_PLUGINS}/smdevp.c
|
||
|
|
${GSOAP_PLUGINS}/mecevp.c
|
||
|
|
${GSOAP_BASE}/custom/struct_timeval.c
|
||
|
|
PROPERTIES LANGUAGE CXX
|
||
|
|
)
|
||
|
|
|
||
|
|
# 포함 디렉토리
|
||
|
|
include_directories(
|
||
|
|
inc
|
||
|
|
ws-discovery/gsoap
|
||
|
|
gen
|
||
|
|
${GSOAP_PREFIX}/include
|
||
|
|
${GSOAP_PLUGINS}
|
||
|
|
)
|
||
|
|
|
||
|
|
# 정의
|
||
|
|
add_definitions(
|
||
|
|
-DWITH_DOM
|
||
|
|
-DWITH_OPENSSL
|
||
|
|
-DSOAP_PURE_VIRTUAL
|
||
|
|
)
|
||
|
|
|
||
|
|
# ws-discovery
|
||
|
|
add_custom_command(
|
||
|
|
OUTPUT ${CMAKE_BINARY_DIR}/libwsdd.a
|
||
|
|
#COMMAND git submodule init ws-discovery
|
||
|
|
#COMMAND git submodule update ws-discovery
|
||
|
|
COMMAND make -C ws-discovery/gsoap libwsdd.a
|
||
|
|
COMMAND cp ws-discovery/gsoap/libwsdd.a ${CMAKE_BINARY_DIR}
|
||
|
|
)
|
||
|
|
add_custom_target(wsdd_build DEPENDS ${CMAKE_BINARY_DIR}/libwsdd.a)
|
||
|
|
add_library(wsdd STATIC IMPORTED)
|
||
|
|
set_target_properties(wsdd PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/libwsdd.a)
|
||
|
|
|
||
|
|
# v4l2rtspserver
|
||
|
|
add_custom_command(
|
||
|
|
OUTPUT ${CMAKE_BINARY_DIR}/liblibv4l2rtspserver.a
|
||
|
|
COMMAND git submodule update --recursive --init v4l2rtspserver
|
||
|
|
COMMAND cd v4l2rtspserver && cmake -DALSA=OFF . && make libv4l2rtspserver
|
||
|
|
COMMAND cp v4l2rtspserver/liblibv4l2rtspserver.a ${CMAKE_BINARY_DIR}
|
||
|
|
)
|
||
|
|
add_custom_target(v4l2rtsp_build DEPENDS ${CMAKE_BINARY_DIR}/liblibv4l2rtspserver.a)
|
||
|
|
add_library(v4l2rtsp STATIC IMPORTED)
|
||
|
|
set_target_properties(v4l2rtsp PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/liblibv4l2rtspserver.a)
|
||
|
|
|
||
|
|
# v4l2cpp
|
||
|
|
add_library(v4l2cpp STATIC IMPORTED)
|
||
|
|
set_target_properties(v4l2cpp PROPERTIES
|
||
|
|
IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/v4l2rtspserver/libv4l2cpp/liblibv4l2cpp.a
|
||
|
|
)
|
||
|
|
|
||
|
|
# live555 설정
|
||
|
|
set(LIVE_DIR ${CMAKE_SOURCE_DIR}/v4l2rtspserver/live)
|
||
|
|
include_directories(
|
||
|
|
${LIVE_DIR}/groupsock/include
|
||
|
|
${LIVE_DIR}/liveMedia/include
|
||
|
|
${LIVE_DIR}/UsageEnvironment/include
|
||
|
|
${LIVE_DIR}/BasicUsageEnvironment/include
|
||
|
|
v4l2rtspserver/inc
|
||
|
|
v4l2rtspserver/libv4l2cpp/inc
|
||
|
|
)
|
||
|
|
|
||
|
|
# 빌드 순서 설정
|
||
|
|
add_dependencies(onvif-server wsdd_build v4l2rtsp_build)
|
||
|
|
|
||
|
|
add_executable(onvif-client src/onvif-client.cpp ${WSSE_SOURCES} ${GSOAP_PLUGINS}/wsaapi.c)
|
||
|
|
target_link_libraries(onvif-client
|
||
|
|
onvif_server
|
||
|
|
gsoapssl++
|
||
|
|
ssl
|
||
|
|
crypto
|
||
|
|
z
|
||
|
|
pthread
|
||
|
|
dl
|
||
|
|
)
|
||
|
|
|
||
|
|
# 설치
|
||
|
|
install(TARGETS onvif-server onvif-client
|
||
|
|
RUNTIME DESTINATION bin
|
||
|
|
)
|