This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
94 lines (89 loc) · 2.77 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
cmake_minimum_required(VERSION 3.10)
set(PROJECT_NAME libwinmedia)
set(VERSION 0.0.3)
set(CPPWINRT_VERSION 2.0.210806.1)
project(${PROJECT_NAME} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(
"${PROJECT_NAME} - ${VERSION}\n"
"-------------------\n"
"Building on Windows against C++/WinRT ${CPPWINRT_VERSION}\n"
"C++ Standard: 17"
)
set(NUGET_URL https://dist.nuget.org/win-x86-commandline/latest/nuget.exe)
set(NUGET ${CMAKE_CURRENT_SOURCE_DIR}/nuget.exe)
if (NOT EXISTS ${NUGET})
file(DOWNLOAD ${NUGET_URL} ${NUGET})
endif()
set(LIBS ${CMAKE_CURRENT_SOURCE_DIR}/external)
set(CPP_WINRT ${LIBS}/Microsoft.Windows.CppWinRT)
if (NOT EXISTS ${CPP_WINRT})
add_custom_target(CPP_WINRT_DOWNLOAD ALL)
add_custom_command(
TARGET CPP_WINRT_DOWNLOAD PRE_BUILD
COMMAND ${NUGET} install Microsoft.Windows.CppWinRT -Version ${CPPWINRT_VERSION} -ExcludeVersion -OutputDirectory ${LIBS}
DEPENDS ${NUGET}
)
endif()
add_library(${PROJECT_NAME} SHARED
${PROJECT_NAME}.cpp
${PROJECT_NAME}.rc
)
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden)
set_target_properties(
${PROJECT_NAME} PROPERTIES
VS_PROJECT_IMPORT ${CPP_WINRT}/build/native/Microsoft.Windows.CppWinRT.props
)
if (DEFINED DART_VM)
message(
"Enabled Dart VM NativePorts callbacks."
)
target_include_directories(
${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/external/dart_api
)
add_definitions(/DDART_VM)
else()
message(
"Disabled Dart VM NativePorts callbacks."
)
endif()
target_link_libraries(
${PROJECT_NAME} PRIVATE
${CPP_WINRT}/build/native/Microsoft.Windows.CppWinRT.targets
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(
"${PROJECT_NAME} - ${VERSION}\n"
"-------------------\n"
"Building on Linux against GTK 3.0 & WebKit2 4.0\n"
"C++ Standard: 17"
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
pkg_check_modules(WebKit REQUIRED IMPORTED_TARGET webkit2gtk-4.0)
add_library(${PROJECT_NAME} SHARED
${PROJECT_NAME}.cpp
)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME winmedia)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::GTK)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::WebKit)
if (DEFINED DART_VM)
message(
"Enabled Dart VM NativePorts callbacks."
)
target_include_directories(
${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/linux
${CMAKE_CURRENT_SOURCE_DIR}/external/dart_api
${CMAKE_CURRENT_SOURCE_DIR}/external/webview
)
add_definitions(-DDART_VM)
else()
message(
"Disabled Dart VM NativePorts callbacks."
)
endif()
endif()