1 cmake_minimum_required (VERSION 2.6)
2 project ("CasparCG Server")
9 exec_program("${GIT_EXECUTABLE}" "${PROJECT_SOURCE_DIR}"
10 ARGS rev-parse --verify --short HEAD
11 OUTPUT_VARIABLE GIT_REV)
14 configure_file("${PROJECT_SOURCE_DIR}/version.tmpl" "${PROJECT_SOURCE_DIR}/version.h")
16 set(DEPENDENCIES_FOLDER "${PROJECT_SOURCE_DIR}/dependencies64")
18 set(BOOST_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/boost")
19 set(RXCPP_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/RxCpp/include")
20 set(TBB_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/tbb/include")
21 set(GLEW_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/glew/include")
22 set(SFML_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/sfml/include")
23 set(FREETYPE_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/freetype/include")
26 set(FFMPEG_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/ffmpeg/include" "${DEPENDENCIES_FOLDER}/ffmpeg/include-win32")
28 set(FFMPEG_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/ffmpeg/include")
31 set(ASMLIB_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/asmlib")
32 set(FREEIMAGE_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/freeimage/include")
33 set(OPENAL_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/openal/include")
34 set(BLUEFISH_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/bluefish/include")
35 set(CEF_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/cef/include")
36 set(GTEST_INCLUDE_PATH "${DEPENDENCIES_FOLDER}/gtest/include")
39 set(PLATFORM_FOLDER_NAME "win32")
40 elseif (CMAKE_COMPILER_IS_GNUCXX)
41 set(PLATFORM_FOLDER_NAME "linux")
44 set(FFMPEG_BIN_PATH "${DEPENDENCIES_FOLDER}/ffmpeg/bin/${PLATFORM_FOLDER_NAME}")
45 set(FREEIMAGE_BIN_PATH "${DEPENDENCIES_FOLDER}/freeimage/bin/${PLATFORM_FOLDER_NAME}")
46 set(GLEW_BIN_PATH "${DEPENDENCIES_FOLDER}/glew/bin/${PLATFORM_FOLDER_NAME}")
47 set(OPENAL_BIN_PATH "${DEPENDENCIES_FOLDER}/openal/bin/${PLATFORM_FOLDER_NAME}")
48 set(TBB_BIN_PATH "${DEPENDENCIES_FOLDER}/tbb/bin/${PLATFORM_FOLDER_NAME}")
49 set(LIBERATION_FONTS_BIN_PATH "${DEPENDENCIES_FOLDER}/liberation-fonts")
50 set(CEF_PATH "${DEPENDENCIES_FOLDER}/cef")
51 set(CEF_BIN_PATH "${DEPENDENCIES_FOLDER}/cef/bin/${PLATFORM_FOLDER_NAME}")
53 link_directories("${DEPENDENCIES_FOLDER}/boost/stage/lib/${PLATFORM_FOLDER_NAME}")
54 link_directories("${DEPENDENCIES_FOLDER}/tbb/lib/${PLATFORM_FOLDER_NAME}")
55 link_directories("${DEPENDENCIES_FOLDER}/glew/lib/${PLATFORM_FOLDER_NAME}")
56 link_directories("${DEPENDENCIES_FOLDER}/sfml/lib/${PLATFORM_FOLDER_NAME}")
57 link_directories("${DEPENDENCIES_FOLDER}/sfml/extlibs/lib")
58 link_directories("${DEPENDENCIES_FOLDER}/freetype/objs/win32/vc2010")
59 link_directories("${DEPENDENCIES_FOLDER}/ffmpeg/lib/${PLATFORM_FOLDER_NAME}")
60 link_directories("${DEPENDENCIES_FOLDER}/asmlib")
61 link_directories("${DEPENDENCIES_FOLDER}/freeimage/lib/${PLATFORM_FOLDER_NAME}")
62 link_directories("${DEPENDENCIES_FOLDER}/openal/lib/${PLATFORM_FOLDER_NAME}")
63 link_directories("${DEPENDENCIES_FOLDER}/bluefish/lib")
64 link_directories("${DEPENDENCIES_FOLDER}/zlib/lib")
65 link_directories("${DEPENDENCIES_FOLDER}/cef/lib/${PLATFORM_FOLDER_NAME}")
66 link_directories("${DEPENDENCIES_FOLDER}/gtest/lib/${PLATFORM_FOLDER_NAME}")
68 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
70 add_definitions( -DSFML_STATIC )
71 add_definitions( -DBOOST_THREAD_VERSION=4 )
72 add_definitions( -DTBB_USE_CAPTURED_EXCEPTION=0 )
73 add_definitions( -DUNICODE )
74 add_definitions( -D_UNICODE )
75 add_definitions( -DGLEW_NO_GLU )
76 add_definitions( "-DBOOST_ASIO_ERROR_CATEGORY_NOEXCEPT=noexcept(true)" ) # Workaround macro redefinition in boost
77 add_definitions( -D_GLIBCXX_USE_CXX11_ABI=0 ) # Allow compilation in GCC 5 while keeping old dependencies
80 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa /Zi /W4 /WX /MP /fp:fast /Zm192 /FIcommon/compiler/vs/disable_silly_warnings.h")
81 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D TBB_USE_ASSERT=1 /D TBB_USE_DEBUG /bigobj")
82 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /Ot /Gy /bigobj")
83 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /Gy /bigobj /Ob2")
84 elseif (CMAKE_COMPILER_IS_GNUCXX)
85 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
86 add_compile_options( -std=c++11 )
87 add_compile_options( -msse3 )
88 add_compile_options( -mssse3 )
89 add_compile_options( -msse4.1 )
90 add_compile_options( -pthread )
91 add_compile_options( -fPIC )
92 add_compile_options( -fnon-call-exceptions ) # Allow signal handler to throw exception
93 add_definitions( -DBOOST_NO_SWPRINTF ) # swprintf on Linux seems to always use , as decimal point regardless of C-locale or C++-locale
97 cmake_policy(SET CMP0045 OLD)
100 include(CMake/PrecompiledHeader.cmake)
102 set(CASPARCG_MODULE_INCLUDE_STATEMENTS "" CACHE INTERNAL "")
103 set(CASPARCG_MODULE_INIT_STATEMENTS "" CACHE INTERNAL "")
104 set(CASPARCG_MODULE_UNINIT_STATEMENTS "" CACHE INTERNAL "")
105 set(CASPARCG_MODULE_COMMAND_LINE_ARG_INTERCEPTORS_STATEMENTS "" CACHE INTERNAL "")
106 set(CASPARCG_MODULE_PROJECTS "" CACHE INTERNAL "")
107 set(CASPARCG_RUNTIME_DEPENDENCIES "" CACHE INTERNAL "")
109 function(casparcg_add_include_statement HEADER_FILE_TO_INCLUDE)
110 set(CASPARCG_MODULE_INCLUDE_STATEMENTS "${CASPARCG_MODULE_INCLUDE_STATEMENTS}"
111 "#include <${HEADER_FILE_TO_INCLUDE}>"
115 function(casparcg_add_init_statement INIT_FUNCTION_NAME NAME_TO_LOG)
116 set(CASPARCG_MODULE_INIT_STATEMENTS "${CASPARCG_MODULE_INIT_STATEMENTS}"
117 " ${INIT_FUNCTION_NAME}(dependencies)\;"
118 " CASPAR_LOG(info) << L\"Initialized ${NAME_TO_LOG} module.\"\;"
123 function(casparcg_add_uninit_statement UNINIT_FUNCTION_NAME)
124 set(CASPARCG_MODULE_UNINIT_STATEMENTS
125 " ${UNINIT_FUNCTION_NAME}()\;"
126 "${CASPARCG_MODULE_UNINIT_STATEMENTS}"
130 function(casparcg_add_command_line_arg_interceptor INTERCEPTOR_FUNCTION_NAME)
131 set(CASPARCG_MODULE_COMMAND_LINE_ARG_INTERCEPTORS_STATEMENTS "${CASPARCG_MODULE_COMMAND_LINE_ARG_INTERCEPTORS_STATEMENTS}"
132 " if (${INTERCEPTOR_FUNCTION_NAME}(argc, argv))"
138 function(casparcg_add_module_project PROJECT)
139 set(CASPARCG_MODULE_PROJECTS "${CASPARCG_MODULE_PROJECTS}" "${PROJECT}" CACHE INTERNAL "")
142 # http://stackoverflow.com/questions/7172670/best-shortest-way-to-join-a-list-in-cmake
143 function(join_list VALUES GLUE OUTPUT)
144 string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
145 string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
146 set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
149 function(casparcg_add_runtime_dependency FILE_TO_COPY)
150 set(CASPARCG_RUNTIME_DEPENDENCIES "${CASPARCG_RUNTIME_DEPENDENCIES}" "${FILE_TO_COPY}" CACHE INTERNAL "")
153 add_subdirectory(accelerator)
154 add_subdirectory(common)
155 add_subdirectory(core)
156 add_subdirectory(modules)
158 add_subdirectory(protocol)
159 add_subdirectory(shell)
160 add_subdirectory(unit-test)