This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
169 lines (128 loc) · 5.13 KB
/
CMakeLists.txt
1
2
3
4
5
6
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
project(libavg_cef)
cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0015 NEW)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
set(PLATFORM_LINUX TRUE)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
set(PLATFORM_MACOSX TRUE)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
set(PLATFORM_WINDOWS TRUE)
endif()
set( CMAKE_BUILD_TYPE "Release" )
set( CMAKE_CXX_STANDARD 11 )
###############################################################################
# Find dependencies
set(Python_ADDITIONAL_VERSIONS 2.7)
find_package(PythonLibs REQUIRED)
# On linux just use PkgConfig.
if(NOT PLATFORM_WINDOWS)
find_package(PkgConfig REQUIRED)
pkg_search_module(LIBXML2 REQUIRED libxml-2.0 libxml2)
pkg_search_module(SDL2 REQUIRED sdl2)
set( AVG_BUILD_DIR "" CACHE PATH "Path to avg build directory.")
else() # On windows let user specify dependencies.
set( AVG_DEPENDENCY_INCLUDE_DIR "" CACHE PATH "Path to libavg windows dependencies/include")
set( AVG_DEPENDENCY_LIBRARIES "" CACHE PATH "Path to libavg windows dependencies/libs")
set( AVG_LIB_PATH "" CACHE FILEPATH "Path to avg.lib.")
endif()
set( RELEASE_DIR ${CMAKE_BINARY_DIR}/Release/ CACHE PATH "Output directory." )
set( CEF_WRAPPER_LIB "" CACHE FILEPATH "Path to libcef_dll_wrapper.a/lib." )
set( CEF_DIR "" CACHE PATH "Path to CEF directory.")
set( AVG_DIR "" CACHE PATH "Path to avg directory.")
include_directories(
src
${PYTHON_INCLUDE_DIRS}
${CEF_DIR}
#unix
${SDL2_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIRS}
#for windows
${AVG_DEPENDENCY_INCLUDE_DIR}
)
link_directories(
${CEF_DIR}/Release/
#unix
${SDL2_LIBRARIES}
${LIBXML2_LIBRARIES}
#windows
${AVG_DEPENDENCY_LIBRARIES} )
##############################################################################
# HELPER
set(HELPERSOURCES src/libavg_cefhelper.cpp src/cefwrapper.cpp src/cefwrapper.h
src/ini.hpp)
add_executable(avg_cefhelper ${HELPERSOURCES})
if(NOT PLATFORM_WINDOWS)
target_link_libraries(avg_cefhelper cef ${CEF_WRAPPER_LIB})
else()
target_link_libraries(avg_cefhelper libcef ${CEF_WRAPPER_LIB})
endif()
target_compile_definitions(avg_cefhelper PRIVATE CEF_APP_ONLY)
# Copy helper executable to Release/
add_custom_command( TARGET avg_cefhelper POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:avg_cefhelper>"
"${RELEASE_DIR}/$<TARGET_FILE_NAME:avg_cefhelper>"
COMMENT "Copying helper exe to ./Release directory." )
##############################################################################
# PLUGIN
set(PLUGINSOURCES src/cefwrapper.cpp src/cefwrapper.h
src/cefplugin.cpp src/cefplugin.h src/ini.hpp )
add_library(avg_cefplugin MODULE ${PLUGINSOURCES})
set_target_properties(avg_cefplugin PROPERTIES PREFIX "lib")
target_include_directories( avg_cefplugin PRIVATE ${AVG_DIR}/src/
${AVG_BUILD_DIR}/src/ )
if(NOT PLATFORM_WINDOWS)
target_link_libraries( avg_cefplugin
${AVG_BUILD_DIR}/src/wrapper/avg.so
${AVG_BUILD_DIR}/src/player/libplayer.a
${AVG_BUILD_DIR}/src/video/libvideo.a
${AVG_BUILD_DIR}/src/audio/libaudio.a
${AVG_BUILD_DIR}/src/imaging/libimaging.a
${AVG_BUILD_DIR}/src/graphics/libgraphics.a
${AVG_BUILD_DIR}/src/anim/libanim.a
${AVG_BUILD_DIR}/src/base/libbase.a
${AVG_BUILD_DIR}/src/tess/libtess.a
${AVG_BUILD_DIR}/src/oscpack/liboscpack.a
${PYTHON_LIBRARY}
cef ${CEF_WRAPPER_LIB} SDL2 SDL2main )
# Creating a hard link to python2.7.
# This is necessary because unix CEF loads dependencies from binary folder
# Which would be /usr/bin, which is not acceptable.
message( STATUS "Creating copy of /usr/bin/python2.7 : ${RELEASE_DIR}/mypy.")
execute_process(
COMMAND cp /usr/bin/python2.7 ${RELEASE_DIR}/mypy
OUTPUT_VARIABLE MYERR
)
message( STATUS ${MYERR} )
else()
target_link_libraries( avg_cefplugin
${AVG_LIB_PATH}
${PYTHON_LIBRARY}
libcef ${CEF_WRAPPER_LIB} SDL2 SDL2main )
# Make boost link the dynamic libraries instead of the static ones.
target_compile_definitions( avg_cefplugin PRIVATE -DBOOST_ALL_DYN_LINK )
endif()
# Getting python site-packages directory.
execute_process(
COMMAND python -c "import site; print(site.getsitepackages()[0])"
OUTPUT_VARIABLE PYTHON_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE )
# Copy plugin so/dll to site-packages/avg/plugin directory.
add_custom_command( TARGET avg_cefplugin POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:avg_cefplugin>"
"${PYTHON_SITE}/libavg/plugin/$<TARGET_FILE_NAME:avg_cefplugin>"
COMMENT "Copying plugin to ${PYTHON_SITE}/libavg/plugin/" )
###############################################################################
# Copying CEF dependencies and test files to Release directory.
message( STATUS "Copying CEF dependencies to Release directory." )
file(GLOB CEF_RESOURCES ${CEF_DIR}/Resources/*)
file(INSTALL ${CEF_RESOURCES} DESTINATION ${RELEASE_DIR})
file(GLOB CEF_RELEASE_FILES ${CEF_DIR}/Release/*)
file(INSTALL ${CEF_RELEASE_FILES} DESTINATION ${RELEASE_DIR})
message( STATUS "Copying test files to Release directory.")
file(GLOB TEST_FILES ${CMAKE_SOURCE_DIR}/src/test/*)
file(INSTALL ${TEST_FILES} DESTINATION ${RELEASE_DIR})