Skip to content

Commit

Permalink
Switch to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Zandvliet committed Apr 2, 2015
1 parent dff9c19 commit 9b6312c
Show file tree
Hide file tree
Showing 10 changed files with 486 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Makefile.in
version.m4
docs
build
nbproject
autom4te.cache
/Mist*
Expand Down
274 changes: 274 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
cmake_minimum_required (VERSION 2.6)
project (MistServer)

if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

macro(makeAnalyser analyserName format)
add_executable( MistAnalyser${analyserName} src/analysers/${format}_analyser.cpp )
target_link_libraries( MistAnalyser${analyserName} mist )
endmacro()

macro(makeInput inputName format)
add_executable( MistIn${inputName} src/input/mist_in.cpp src/input/input.cpp src/input/input_${format}.cpp )
set_target_properties( MistIn${inputName} PROPERTIES COMPILE_DEFINITIONS INPUTTYPE=\"input_${format}.h\")
target_link_libraries( MistIn${inputName} mist )
endmacro()

macro(makeOutput outputName format)
#check if 'http' is one of the argyments, if yes, this is an http output
if (";${ARGN};" MATCHES ";http;")
SET(httpOutput src/output/output_http.cpp)
SET(tsBaseClass Output)
if (";${ARGN};" MATCHES ";ts;")
SET(tsBaseClass HTTPOutput)
endif()
endif()
if (";${ARGN};" MATCHES ";ts;")
SET(tsOutput src/output/output_ts_base.cpp)
endif()
add_executable( MistOut${outputName} src/output/mist_out.cpp src/output/output.cpp ${httpOutput} ${tsOutput} src/output/output_${format}.cpp )
set_target_properties( MistOut${outputName} PROPERTIES COMPILE_DEFINITIONS "OUTPUTTYPE=\"output_${format}.h\";TS_BASECLASS=${tsBaseClass}")
target_link_libraries( MistOut${outputName} mist )
endmacro()

set(lspSOURCES lsp/plugins/md5.js lsp/plugins/cattablesort.js lsp/mist.js)
set(lspSOURCESmin lsp/plugins/jquery.js lsp/plugins/jquery.flot.min.js lsp/plugins/jquery.flot.time.min.js lsp/plugins/jquery.qrcode.min.js)
set(lspDATA lsp/header.html lsp/main.css lsp/footer.html)


SET(SOURCE_DIR ${PROJECT_SOURCE_DIR})
SET(BINARY_DIR ${PROJECT_BINARY_DIR})
include_directories(${SOURCE_DIR})
include_directories(${BINARY_DIR})

enable_testing()
include(CTest)

find_package(Doxygen)
find_package(Java)

if(JAVA_FOUND)
SET(CLOSURE "java -jar closure-compiler.jar --warning_level QUIET")
else()
SET(CLOSURE cat)
endif()

if (RELEASE)
set (RELEASE_RAW ${RELEASE})
else()
#get the bitlength of this system
execute_process(COMMAND getconf LONG_BIT OUTPUT_VARIABLE RELEASE_RAW )
set(RELEASE_RAW "Generic_${RELEASE_RAW}" )
endif()
string(STRIP ${RELEASE_RAW} RELEASE)
set(RELEASE \"${RELEASE}\" )

#See if we have a git repo to get the version from
execute_process(COMMAND git describe --tags OUTPUT_VARIABLE PACKAGE_VERSION_RAW ERROR_QUIET)
if (NOT PACKAGE_VERSION_RAW)
execute_process(COMMAND cat VERSION OUTPUT_VARIABLE PACKAGE_VERSION_RAW ERROR_QUIET)
endif()
if (NOT PACKAGE_VERSION_RAW)
set(PACKAGE_VERSION_RAW Unknown)
endif()
#strip off the trailing spaces and newline
string(STRIP "${PACKAGE_VERSION_RAW}" PACKAGE_VERSION)
set(PACKAGE_VERSION \"${PACKAGE_VERSION}\" )


if (NOT DEBUG)
set(DEBUG 4)
endif()

message("Builing release ${RELEASE} for version ${PACKAGE_VERSION} @ debug level ${DEBUG}")

add_definitions(-g -funsigned-char -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DDEBUG=${DEBUG} -DPACKAGE_VERSION=${PACKAGE_VERSION} -DRELEASE=${RELEASE})
if (NOT DEFINED ${NOSHM} )
add_definitions(-DSHM_ENABLED=1)
endif()
if (DEFINED ${WITH_THREADNAMES} )
add_definitions(-DWITH_THREADNAMES=1)
endif()

if(DOXYGEN_FOUND)
configure_file(${SOURCE_DIR}/Doxyfile.in ${BINARY_DIR}/Doxyfile @ONLY)
add_custom_target( docs
# ALL
${DOXYGEN_EXECUTABLE} ${BINARY_DIR}/Doxyfile
COMMAND rm -rf ${BINARY_DIR}/docs
COMMAND mv ${SOURCE_DIR}/docs ${BINARY_DIR}
WORKING_DIRECTORY ${SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
endif(DOXYGEN_FOUND)

#Compile the lib
set(libHeaders
${SOURCE_DIR}/lib/config.h
${SOURCE_DIR}/lib/flv_tag.h
${SOURCE_DIR}/lib/mp4.h
${SOURCE_DIR}/lib/dtsc.h
${SOURCE_DIR}/lib/ts_packet.h
${SOURCE_DIR}/lib/checksum.h
${SOURCE_DIR}/lib/bitstream.h
${SOURCE_DIR}/lib/bitfields.h
${SOURCE_DIR}/lib/shared_memory.h
${SOURCE_DIR}/lib/mp4_adobe.h
${SOURCE_DIR}/lib/http_parser.h
${SOURCE_DIR}/lib/converter.h
${SOURCE_DIR}/lib/procs.h
${SOURCE_DIR}/lib/defines.h
${SOURCE_DIR}/lib/base64.h
${SOURCE_DIR}/lib/ftp.h
${SOURCE_DIR}/lib/socket.h
${SOURCE_DIR}/lib/ogg.h
${SOURCE_DIR}/lib/timing.h
${SOURCE_DIR}/lib/filesystem.h
${SOURCE_DIR}/lib/mp4_generic.h
${SOURCE_DIR}/lib/amf.h
${SOURCE_DIR}/lib/mp4_ms.h
${SOURCE_DIR}/lib/rtmpchunks.h
${SOURCE_DIR}/lib/tinythread.h
${SOURCE_DIR}/lib/nal.h
${SOURCE_DIR}/lib/vorbis.h
${SOURCE_DIR}/lib/auth.h
${SOURCE_DIR}/lib/stream.h
${SOURCE_DIR}/lib/theora.h
${SOURCE_DIR}/lib/json.h
)
set(libSources
${SOURCE_DIR}/lib/tinythread.cpp
${SOURCE_DIR}/lib/mp4_ms.cpp
${SOURCE_DIR}/lib/filesystem.cpp
${SOURCE_DIR}/lib/procs.cpp
${SOURCE_DIR}/lib/bitfields.cpp
${SOURCE_DIR}/lib/amf.cpp
${SOURCE_DIR}/lib/mp4_adobe.cpp
${SOURCE_DIR}/lib/ftp.cpp
${SOURCE_DIR}/lib/base64.cpp
${SOURCE_DIR}/lib/http_parser.cpp
${SOURCE_DIR}/lib/ts_packet.cpp
${SOURCE_DIR}/lib/auth.cpp
${SOURCE_DIR}/lib/rtmpchunks.cpp
${SOURCE_DIR}/lib/shared_memory.cpp
${SOURCE_DIR}/lib/dtsc.cpp
${SOURCE_DIR}/lib/converter.cpp
${SOURCE_DIR}/lib/config.cpp
${SOURCE_DIR}/lib/vorbis.cpp
${SOURCE_DIR}/lib/nal.cpp
${SOURCE_DIR}/lib/bitstream.cpp
${SOURCE_DIR}/lib/socket.cpp
${SOURCE_DIR}/lib/flv_tag.cpp
${SOURCE_DIR}/lib/ogg.cpp
${SOURCE_DIR}/lib/mp4_generic.cpp
${SOURCE_DIR}/lib/mp4.cpp
${SOURCE_DIR}/lib/theora.cpp
${SOURCE_DIR}/lib/timing.cpp
${SOURCE_DIR}/lib/dtscmeta.cpp
${SOURCE_DIR}/lib/stream.cpp
${SOURCE_DIR}/lib/json.cpp
)
add_library ( mist ${libHeaders} ${libSources} )
target_link_libraries( mist -lpthread -lrt)

add_custom_command(TARGET mist
POST_BUILD
COMMAND mkdir -p ${BINARY_DIR}/mist
COMMAND cp ${libHeaders} ${BINARY_DIR}/mist
DEPENDS ${libHeaders}
)

makeAnalyser(RTMP rtmp)
makeAnalyser(FLV flv)
makeAnalyser(DTSC dtsc)
makeAnalyser(AMF amf)
makeAnalyser(MP4 mp4)
makeAnalyser(OGG ogg)
add_executable( MistInfo src/analysers/info.cpp )
target_link_libraries( MistInfo mist )

makeInput(DTSC dtsc)
makeInput(MP3 mp3)
makeInput(FLV flv)
makeInput(OGG ogg)
makeInput(Buffer buffer)

makeOutput(RTMP rtmp)
makeOutput(OGG progressive_ogg http)
makeOutput(FLV progressive_flv http)
makeOutput(MP4 progressive_mp4 http)
makeOutput(MP3 progressive_mp3 http)
makeOutput(HSS hss http)
makeOutput(HDS hds http)
makeOutput(SRT srt http)
makeOutput(JSON json http)
makeOutput(TS ts ts)
makeOutput(HTTPTS httpts http ts)
makeOutput(HLS hls http ts)

add_executable( sourcery src/sourcery.cpp )

add_custom_target( embedcode
./sourcery ${CMAKE_CURRENT_SOURCE_DIR}/src/embed.js embed_js ${CMAKE_CURRENT_BINARY_DIR}/embed.js.h
DEPENDS sourcery ${CMAKE_CURRENT_SOURCE_DIR}/src/embed.js
VERBATIM
)

add_custom_target( lsp
${SOURCE_DIR}/lsp/generateLSP.sh ${BINARY_DIR}/server.html "${CLOSURE}"
DEPENDS ${SOURCE_DIR}/lsp/generateLSP.sh ${lspSOURCES} ${lspSOURCESmin} ${lspDATA}
WORKING_DIRECTORY ${SOURCE_DIR}/lsp
VERBATIM
)
add_custom_target( localSettingsPage
./sourcery ${BINARY_DIR}/server.html server_html ${CMAKE_CURRENT_BINARY_DIR}/server.html.h
DEPENDS sourcery lsp
VERBATIM
)

add_executable( MistOutHTTP src/output/mist_out.cpp src/output/output.cpp src/output/output_http.cpp src/output/output_http_internal.cpp)
set_target_properties( MistOutHTTP PROPERTIES COMPILE_DEFINITIONS "OUTPUTTYPE=\"output_http_internal.h\"")
add_dependencies(MistOutHTTP embedcode)
target_link_libraries( MistOutHTTP mist )

set(controllerHeaders
${SOURCE_DIR}/src/controller/controller_api.h
${SOURCE_DIR}/src/controller/controller_statistics.h
${SOURCE_DIR}/src/controller/controller_connectors.h
${SOURCE_DIR}/src/controller/controller_storage.h
${SOURCE_DIR}/src/controller/controller_capabilities.h
${SOURCE_DIR}/src/controller/controller_streams.h
)
set(controllerSources
${SOURCE_DIR}/src/controller/controller.cpp
${SOURCE_DIR}/src/controller/controller_streams.cpp
${SOURCE_DIR}/src/controller/controller_storage.cpp
${SOURCE_DIR}/src/controller/controller_connectors.cpp
${SOURCE_DIR}/src/controller/controller_statistics.cpp
${SOURCE_DIR}/src/controller/controller_capabilities.cpp
${SOURCE_DIR}/src/controller/controller_api.cpp
)

add_executable( MistController ${controllerHeaders} ${controllerSources} )
set_target_properties( MistController PROPERTIES COMPILE_DEFINITIONS RELEASE=${RELEASE})
target_link_libraries( MistController mist )
add_dependencies(MistController localSettingsPage)

#make clean stuff
add_custom_target(clean-all
COMMAND ${CMAKE_BUILD_TOOL} clean
COMMAND rm -rf ${BINARY_DIR}/CMakeCache.txt
COMMAND rm -rf ${BINARY_DIR}/cmake_install.cmake
COMMAND rm -rf ${BINARY_DIR}/Makefile
COMMAND rm -rf ${BINARY_DIR}/CMakeFiles
COMMAND rm -rf ${BINARY_DIR}/Testing
COMMAND rm -rf ${BINARY_DIR}/CTestTestfile.cmake
COMMAND rm -rf ${BINARY_DIR}/DartConfiguration.tcl
COMMAND rm -rf ${BINARY_DIR}/server.html
COMMAND rm -rf ${BINARY_DIR}/server.html.h
COMMAND rm -rf ${BINARY_DIR}/embed.js.h
COMMAND rm -rf ${BINARY_DIR}/mist
)
2 changes: 1 addition & 1 deletion Doxyfile → Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = MistServer
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1
PROJECT_NUMBER = "@PACKAGE_VERSION@ (@RELEASE@)"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
69 changes: 69 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
add_library ( mist SHARED
amf.cpp
amf.h
auth.cpp
auth.h
base64.cpp
base64.h
bitfields.cpp
bitfields.h
bitstream.cpp
bitstream.h
checksum.h
CMakeLists.txt
config.cpp
config.h
converter.cpp
converter.h
defines.h
dtsc.cpp
dtsc.h
dtscmeta.cpp
filesystem.cpp
filesystem.h
flv_tag.cpp
flv_tag.h
ftp.cpp
ftp.h
http_parser.cpp
http_parser.h
json.cpp
json.h
mp4_adobe.cpp
mp4_adobe.h
mp4.cpp
mp4_generic.cpp
mp4_generic.h
mp4.h
mp4_ms.cpp
mp4_ms.h
nal.cpp
nal.h
ogg.cpp
ogg.h
procs.cpp
procs.h
rtmpchunks.cpp
rtmpchunks.h
shared_memory.cpp
shared_memory.h
socket.cpp
socket.h
stream.cpp
stream.h
theora.cpp
theora.h
timing.cpp
timing.h
tinythread.cpp
tinythread.h
ts_packet.cpp
ts_packet.h
vorbis.cpp
vorbis.h
)

target_link_libraries( mist
-lpthread
-lrt
)
4 changes: 3 additions & 1 deletion lib/shared_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ namespace IPC {
}
}
if (handle == -1) {
FAIL_MSG("shm_open for page %s failed: %s", name.c_str(), strerror(errno));
if (!master_ && autoBackoff){
FAIL_MSG("shm_open for page %s failed: %s", name.c_str(), strerror(errno));
}
return;
}
if (master) {
Expand Down
11 changes: 11 additions & 0 deletions lsp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(lspSOURCES plugins/md5.js plugins/cattablesort.js mist.js)
set(lspSOURCESmin plugins/jquery.js plugins/jquery.flot.min.js plugins/jquery.flot.time.min.js plugins/jquery.qrcode.min.js)
set(lspDATA header.html main.css footer.html)

add_custom_target( lsp
ALL
${CMAKE_CURRENT_SOURCE_DIR}/generateLSP.sh ${CMAKE_CURRENT_BINARY_DIR}/server.html
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generateLSP.sh ${lspSOURCES} ${lspSOURCESmin} ${lspDATA}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
11 changes: 11 additions & 0 deletions lsp/generateLSP.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cat header.html > $1
echo "<script>" >> $1
cat plugins/jquery.js plugins/jquery.flot.min.js plugins/jquery.flot.time.min.js plugins/jquery.qrcode.min.js >> $1
cat plugins/md5.js plugins/cattablesort.js mist.js >> $1
echo "</script><style>" >> $1
cat main.css >> $1
echo "</style>" >> $1
cat footer.html >> $1

Loading

0 comments on commit 9b6312c

Please sign in to comment.