2022-10-03 15:18:40 +00:00
|
|
|
|
2022-10-26 18:06:06 +00:00
|
|
|
if(WIN32 AND GUI_EXE)
|
|
|
|
message(STATUS "using pre-built lokinet gui executable: ${GUI_EXE}")
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${GUI_EXE}" "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe")
|
|
|
|
elseif(BUILD_GUI)
|
|
|
|
message(STATUS "Building lokinet-gui from source")
|
|
|
|
|
|
|
|
set(default_gui_target pack)
|
|
|
|
if(APPLE)
|
|
|
|
set(default_gui_target macos:raw)
|
|
|
|
elseif(WIN32)
|
|
|
|
set(default_gui_target win32)
|
|
|
|
endif()
|
2022-07-25 21:12:33 +00:00
|
|
|
|
2022-10-26 18:06:06 +00:00
|
|
|
set(GUI_YARN_TARGET "${default_gui_target}" CACHE STRING "yarn target for building the GUI")
|
|
|
|
set(GUI_YARN_EXTRA_OPTS "" CACHE STRING "extra options to pass into the yarn build command")
|
2022-07-25 21:12:33 +00:00
|
|
|
|
2022-07-28 16:07:38 +00:00
|
|
|
# allow manually specifying yarn with -DYARN=
|
2022-08-16 19:49:08 +00:00
|
|
|
if(NOT YARN)
|
2022-07-28 16:07:38 +00:00
|
|
|
find_program(YARN NAMES yarnpkg yarn REQUIRED)
|
2022-08-16 19:49:08 +00:00
|
|
|
endif()
|
2022-07-25 21:12:33 +00:00
|
|
|
message(STATUS "Building lokinet-gui with yarn ${YARN}, target ${GUI_YARN_TARGET}")
|
2022-08-12 22:57:00 +00:00
|
|
|
|
2022-07-28 16:07:38 +00:00
|
|
|
if(NOT WIN32)
|
|
|
|
add_custom_target(lokinet-gui
|
|
|
|
COMMAND ${YARN} install --frozen-lockfile &&
|
|
|
|
${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET}
|
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui")
|
|
|
|
endif()
|
2022-07-25 21:12:33 +00:00
|
|
|
|
|
|
|
if(APPLE)
|
2022-08-12 22:57:00 +00:00
|
|
|
add_custom_target(assemble_gui ALL
|
|
|
|
DEPENDS assemble lokinet-gui
|
2022-08-29 15:53:08 +00:00
|
|
|
COMMAND mkdir "${lokinet_app}/Contents/Helpers"
|
|
|
|
COMMAND cp -a "${PROJECT_SOURCE_DIR}/gui/release/mac/Lokinet-GUI.app" "${lokinet_app}/Contents/Helpers/"
|
|
|
|
COMMAND mkdir -p "${lokinet_app}/Contents/Resources/en.lproj"
|
|
|
|
COMMAND cp "${PROJECT_SOURCE_DIR}/contrib/macos/InfoPlist.strings" "${lokinet_app}/Contents/Resources/en.lproj/"
|
|
|
|
COMMAND cp "${lokinet_app}/Contents/Resources/icon.icns" "${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Resources/icon.icns"
|
|
|
|
COMMAND cp "${PROJECT_SOURCE_DIR}/contrib/macos/InfoPlist.strings" "${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Resources/en.lproj/"
|
2022-08-12 22:57:00 +00:00
|
|
|
COMMAND /usr/libexec/PlistBuddy
|
2022-07-28 16:07:38 +00:00
|
|
|
-c "Delete :CFBundleDisplayName"
|
|
|
|
-c "Add :LSHasLocalizedDisplayName bool true"
|
|
|
|
-c "Add :CFBundleDevelopmentRegion string en"
|
|
|
|
-c "Set :CFBundleShortVersionString ${lokinet_VERSION}"
|
|
|
|
-c "Set :CFBundleVersion ${lokinet_VERSION}.${LOKINET_APPLE_BUILD}"
|
|
|
|
"${lokinet_app}/Contents/Helpers/Lokinet-GUI.app/Contents/Info.plist"
|
2022-07-25 21:12:33 +00:00
|
|
|
)
|
|
|
|
elseif(WIN32)
|
|
|
|
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/gui")
|
2022-10-26 18:06:06 +00:00
|
|
|
add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe"
|
|
|
|
COMMAND ${YARN} install --frozen-lockfile &&
|
|
|
|
USE_SYSTEM_7ZA=true DISPLAY= WINEDEBUG=-all WINEPREFIX="${PROJECT_BINARY_DIR}/wineprefix" ${YARN} ${GUI_YARN_EXTRA_OPTS} ${GUI_YARN_TARGET}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
"${PROJECT_SOURCE_DIR}/gui/release/Lokinet-GUI_portable.exe"
|
|
|
|
"${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe"
|
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/gui")
|
2022-07-28 16:07:38 +00:00
|
|
|
add_custom_target(assemble_gui ALL COMMAND "true" DEPENDS "${PROJECT_BINARY_DIR}/gui/lokinet-gui.exe")
|
2022-07-25 21:12:33 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Building/bundling the GUI from this repository is not supported on this platform")
|
|
|
|
endif()
|
|
|
|
else()
|
2022-08-16 19:49:08 +00:00
|
|
|
message(STATUS "not building gui")
|
2022-07-25 21:12:33 +00:00
|
|
|
endif()
|
2022-07-28 16:07:38 +00:00
|
|
|
|
|
|
|
if(NOT TARGET assemble_gui)
|
|
|
|
add_custom_target(assemble_gui COMMAND "true")
|
|
|
|
endif()
|