CMakeLists.txt 1.41 KB
Newer Older
1 2 3 4
include_directories(../3rdpart)
file(GLOB jsoncpp_src_list ../3rdpart/jsoncpp/*.cpp ../3rdpart/jsoncpp/*.h )
add_library(jsoncpp STATIC ${jsoncpp_src_list})

5
file(GLOB MediaServer_src_list ./*.cpp ./*.h)
6
#message(STATUS ${MediaServer_src_list})
xiongziliang committed
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
# 添加git版本信息
set(COMMIT_HASH "Git_NotFound_Unkown_commit")
set(BRANCH_NAME "Git_NotFound_Unkown_branch")
set(BUILD_TIME "")

string(TIMESTAMP BUILD_TIME "%Y/%m/%d-%H:%M:%S")

find_package(Git QUIET)
if(GIT_FOUND)
	execute_process(
			COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%H
			OUTPUT_VARIABLE COMMIT_HASH
			OUTPUT_STRIP_TRAILING_WHITESPACE
			ERROR_QUIET
			WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../
	)
	execute_process(
			COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
			OUTPUT_VARIABLE BRANCH_NAME
			OUTPUT_STRIP_TRAILING_WHITESPACE
			ERROR_QUIET
			WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../
	)
endif()

message(STATUS "Git version is ${BRANCH_NAME}:${COMMIT_HASH}:${BUILD_TIME}")

configure_file(
		${CMAKE_CURRENT_SOURCE_DIR}/version.h.ini
		${CMAKE_BINARY_DIR}/Version.h
		@ONLY
)
include_directories(${CMAKE_BINARY_DIR})
add_definitions(-DENABLE_VERSION)

43
add_executable(MediaServer ${MediaServer_src_list})
xiongziliang committed
44 45 46

if(WIN32)
	set_target_properties(MediaServer PROPERTIES COMPILE_FLAGS  ${VS_FALGS} )
wxf committed
47 48
else()
	install(TARGETS MediaServer DESTINATION ${INSTALL_PATH_EXECUTABLE})
xiongziliang committed
49 50
endif()

51
target_link_libraries(MediaServer jsoncpp ${LINK_LIB_LIST})