-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathPluginSetup.cmake
77 lines (71 loc) · 2.41 KB
/
PluginSetup.cmake
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
# ~~~
# Summary: Set up plugin_target and plugin_target_version.
# License: GPLv3+
# Copyright (c) 2020-2021 Alec Leamas
# ~~~
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
include(GetArch)
if (DEFINED plugin_target)
return ()
endif ()
if (NOT "${OCPN_TARGET_TUPLE}" STREQUAL "")
list(GET OCPN_TARGET_TUPLE 0 plugin_target)
list(GET OCPN_TARGET_TUPLE 1 plugin_target_version)
elseif ("${BUILD_TYPE}" STREQUAL "flatpak")
set(plugin_target "flatpak-${ARCH}")
file(GLOB manifest_path "${PROJECT_SOURCE_DIR}/flatpak/org.opencpn.*.yaml")
file(READ ${manifest_path} manifest)
string(REPLACE "\n" ";" manifest_lines "${manifest}")
foreach (_line ${manifest_lines})
if (${_line} MATCHES "org.freedesktop.Sdk")
string(REGEX REPLACE ".*//" "" plugin_target_version "${_line}")
endif ()
endforeach ()
message(STATUS "Building for flatpak runtime ${plugin_target_version}")
elseif (MINGW)
set(plugin_target "mingw")
if (CMAKE_SYSTEM_VERSION)
set(plugin_target_version ${CMAKE_SYSTEM_VERSION})
else ()
set(plugin_target_version 10)
endif ()
elseif (MSVC)
set(plugin_target "msvc-wx32")
if (CMAKE_SYSTEM_VERSION)
set(plugin_target_version ${CMAKE_SYSTEM_VERSION})
elseif (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
set(plugin_target_version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
else ()
set(plugin_target_version 10)
endif ()
elseif (APPLE)
set(plugin_target "darwin-wx32")
set(plugin_target_version "10.13.6")
elseif (UNIX)
execute_process(
COMMAND "lsb_release" "-is"
OUTPUT_VARIABLE plugin_target
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND "lsb_release" "-rs"
OUTPUT_VARIABLE plugin_target_version
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT ${plugin_target} MATCHES ${ARCH})
set(plugin_target "${plugin_target}-${ARCH}")
endif ()
else ()
set(plugin_target "unknown")
set(plugin_target_version 1)
endif ()
string(STRIP "${plugin_target}" plugin_target)
string(TOLOWER "${plugin_target}" plugin_target)
string(STRIP "${plugin_target_version}" plugin_target_version)
string(TOLOWER "${plugin_target_version}" plugin_target_version)
message(STATUS
"Building for target:release ${plugin_target}:${plugin_target_version}"
)