Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci/linux/generate_appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/Freespace2 -DCOMPONENT=Unspecified
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/Freespace2 -DCOMPONENT=Freespace2 -P cmake_install.cmake

# We need to be a bit creative for determining the AppImage name since we don't want to hard-code the name
FILENAME="$(find $INSTALL_FOLDER/Freespace2/bin -name 'fs2_open_*' -type f -printf "%f\n").AppImage"
FILENAME="$(find $INSTALL_FOLDER/Freespace2/bin -maxdepth 1 -name 'fs2_open_*' -type f -executable -printf "%f\n").AppImage"
appimagetool -n "$INSTALL_FOLDER/Freespace2" "$INSTALL_FOLDER/$FILENAME"
chmod +x "$INSTALL_FOLDER/$FILENAME"

Expand All @@ -17,7 +17,7 @@ if [ -f qtfred/cmake_install.cmake ]; then
cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_FOLDER/qtFRED -DCOMPONENT=qtFRED -P cmake_install.cmake

# We need to be a bit creative for determining the AppImage name since we don't want to hard-code the name
FILENAME="$(find $INSTALL_FOLDER/qtFRED/bin -iname 'qtfred_*' -type f -printf "%f\n").AppImage"
FILENAME="$(find $INSTALL_FOLDER/qtFRED/bin -maxdepth 1 -iname 'qtfred_*' -type f -executable -printf "%f\n").AppImage"
appimagetool -n "$INSTALL_FOLDER/qtFRED" "$INSTALL_FOLDER/$FILENAME"
chmod +x "$INSTALL_FOLDER/$FILENAME"
fi
Expand Down
4 changes: 2 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ ADD_SUBDIRECTORY(lz4)

set(HIDAPI_WITH_LIBUSB OFF)
set(HIDAPI_WITH_HIDRAW ON)
add_subdirectory(hidapi)
add_subdirectory(hidapi EXCLUDE_FROM_ALL)

ADD_SUBDIRECTORY(imgui)

if(FSO_BUILD_WITH_OPENXR)
add_subdirectory(openxr)
add_subdirectory(openxr EXCLUDE_FROM_ALL)
endif()
2 changes: 1 addition & 1 deletion lib/antlr4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif()
set(WITH_DEMO FALSE)
set(ANTLR4_INSTALL FALSE)

add_subdirectory(antlr4-cpp-runtime)
add_subdirectory(antlr4-cpp-runtime EXCLUDE_FROM_ALL)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/antlr4-cpp-runtime/cmake" PARENT_SCOPE)
suppress_warnings(antlr4_static)
Expand Down
198 changes: 121 additions & 77 deletions qtfred/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.21)

project(qtfred VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set_policy(CMP0177 NEW) # normalize install() destination paths

option(QT_USE_PRECOMPILED "Use precompiled version of Qt. If disabled the system libraries will be used." OFF)

if(QT_USE_PRECOMPILED)
Expand All @@ -13,6 +15,7 @@ if(QT_USE_PRECOMPILED)
else()
SET(QT6_INSTALL_ROOT "" CACHE PATH
"The path to the Qt6 installation root. May be necessary on windows if the standard find_package fails to find the Qt installation.")
message(STATUS "Using system Qt libraries. Don't distribute these FSO binaries if these are the GPL libraries/plugins!")
endif()

if(QT6_INSTALL_ROOT)
Expand All @@ -23,7 +26,6 @@ find_package(Qt6 REQUIRED COMPONENTS Core Widgets OpenGL Help)
include(source_groups.cmake)
qt_standard_project_setup()
add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)
INCLUDE(InstallRequiredSystemLibraries)
qt6_wrap_ui(QTFRED_UI_GENERATED ${files_UI})
source_group("UI\\Generated" FILES ${QTFRED_UI_GENERATED})
qt_add_executable(qtfred
Expand Down Expand Up @@ -53,8 +55,6 @@ target_include_directories(qtfred PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
)

set(CMAKE_MAP_IMPORTED_CONFIG_FASTDEBUG Release Debug)

target_link_libraries(qtfred PUBLIC code Qt6::Widgets Qt6::OpenGL Qt6::Help)

include(CreateLaunchers)
Expand Down Expand Up @@ -128,9 +128,11 @@ add_custom_command(
COMMENT "Compiling QtFRED help content (qtfred_help.qch)"
VERBATIM)

# Pre-build the collection (.qhc) with the .qch already registered. Runtime
# just opens this in read-only mode -- no QHelpEngine::registerDocumentation
# bootstrap, which is unreliable on a fresh .qhc under Qt6.
# Pre-build the collection (.qhc) with the .qch already registered. At runtime
# we copy this to AppDataLocation (writable on all platforms including macOS) and
# open it from there so Qt can write the search index alongside it. We avoid
# creating a fresh .qhc at runtime because QHelpEngine::registerDocumentation
# bootstrapping on a new empty collection is unreliable under Qt6.
add_custom_command(
OUTPUT "${QTFRED_HELP_QHC}"
COMMAND ${CMAKE_COMMAND} -E env
Expand Down Expand Up @@ -170,48 +172,16 @@ install(FILES "${QTFRED_HELP_QCH}" "${QTFRED_HELP_QHC}"
enable_clang_tidy(qtfred)
COPY_FILES_TO_TARGET(qtfred)

if(PLATFORM_WINDOWS)
get_target_property(QMAKE_EXE Qt6::qmake IMPORTED_LOCATION)
get_filename_component(QT_BIN_DIR ${_QTFRED_QMAKE} DIRECTORY)
message(STATUS "Qt bin dir: ${QT_BIN_DIR}")
message(STATUS "qmake path: ${QMAKE_EXE}")

find_program(DEPLOYQT_EXECUTABLE
NAMES windeployqt6 windeployqt
HINTS "${QT_BIN_DIR}"
REQUIRED
)

if(NOT DEPLOYQT_EXECUTABLE)
message(WARNING "windeployqt not found in '${QT_BIN_DIR}' — Qt DLLs will not be deployed")
else()
message(STATUS "Found windeployqt: ${DEPLOYQT_EXECUTABLE}")
endif()

add_custom_command(TARGET qtfred POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Target file is: $<TARGET_FILE:qtfred>"
COMMENT "Debug: checking target file path"
)
set(QTFRED_DEPLOY_PREFIX "$<TARGET_FILE_DIR:qtfred>")
set(QTFRED_DEPLOY_OPTIONS "")

add_custom_command(TARGET qtfred POST_BUILD
COMMAND "${DEPLOYQT_EXECUTABLE}"
--qthelp
$<$<OR:$<CONFIG:Debug>,$<CONFIG:FastDebug>>:--debug>
$<$<CONFIG:Release>:--release>
--dir "$<TARGET_FILE_DIR:qtfred>"
$<TARGET_FILE:qtfred>
COMMENT "Running windeployqt (with Qt Help support)..."
)

install(
DIRECTORY "$<TARGET_FILE_DIR:qtfred>/"
DESTINATION ${BINARY_DESTINATION}
COMPONENT "qtFRED"
FILES_MATCHING
PATTERN "Qt6Help*.dll"
PATTERN "qsqlite*.dll"
PATTERN "qwindows*.dll"
PATTERN "*.dll"
if(PLATFORM_WINDOWS)
set(QTFRED_DEPLOY_OPTIONS
NO_COMPILER_RUNTIME
DEPLOY_TOOL_OPTIONS
BIN_DIR ${BINARY_DESTINATION}
LIB_DIR ${LIBRAY_DESTINATION}
NO_OVERWRITE
)
elseif(PLATFORM_MAC)
# Handling of mac resources
Expand All @@ -233,42 +203,116 @@ elseif(PLATFORM_MAC)
COMMENT "Copying resources into bundle..."
)

# fix up Qt libs
find_program(DEPLOYQT_EXECUTABLE
NAMES macdeployqt6 macdeployqt
HINTS "${_QTFRED_QT_BINS}"
REQUIRED
set(QTFRED_DEPLOY_PREFIX "$<TARGET_BUNDLE_DIR:qtfred>/..")
set(QTFRED_DEPLOY_OPTIONS
DEPLOY_TOOL_OPTIONS
-codesign=-
NO_APP_STORE_COMPLIANCE
NO_OVERWRITE
)
elseif(PLATFORM_LINUX)
if (FSO_BUILD_APPIMAGE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/AppRun.in" "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen" @ONLY)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen")

add_custom_command(TARGET qtfred POST_BUILD
COMMAND "${DEPLOYQT_EXECUTABLE}"
"$<TARGET_BUNDLE_DIR:qtfred>"
-codesign=-
COMMENT "Running macdeployqt..."
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>" DESTINATION "." RENAME "AppRun"
COMPONENT "qtFRED")

configure_file("${CMAKE_CURRENT_LIST_DIR}/cmake/AppImage.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen" @ONLY)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen")

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop" DESTINATION "." RENAME "qtfred.desktop"
COMPONENT "qtFRED")

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/resources/fred_icon.png" DESTINATION "."
COMPONENT "qtFRED")

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/resources/fonts" DESTINATION ${LIBRAY_DESTINATION}
COMPONENT "qtFRED")
endif()

add_custom_command(
TARGET qtfred POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/resources/fonts"
"$<TARGET_FILE_DIR:qtfred>/${LIBRAY_DESTINATION}/fonts"
COMMENT "Copying QtFRED fonts..."
VERBATIM
)

set(QTFRED_DEPLOY_OPTIONS
INCLUDE_PLUGINS
eglfs linuxfb minimalegl minimal
offscreen vkkhrdisplay vnc
wayland xcb
)
elseif(FSO_BUILD_APPIMAGE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/AppRun.in" "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen" @ONLY)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen")
endif()

install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>" DESTINATION "." RENAME "AppRun"
COMPONENT "qtFRED")
# create Qt deploy script to fixup Qt libs/plugins
qt_generate_deploy_app_script(
TARGET qtfred
OUTPUT_SCRIPT QTFRED_DEPLOY_SCRIPT
NO_UNSUPPORTED_PLATFORM_ERROR
${QTFRED_DEPLOY_OPTIONS}
)

configure_file("${CMAKE_CURRENT_LIST_DIR}/cmake/AppImage.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen" @ONLY)
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/AppImage.desktop.gen")
if(PLATFORM_LINUX AND QT_USE_PRECOMPILED)
# Using prebuilt Qt libs on Linux poses a problem since the deploy script
# needs to be able to find the Qt libs, which aren't in a normal location.
# So to address this we need to modify the deploy script to change the RPATH
# of the QtFRED binary to include this alternate location, run the deployment
# and then reset the RPATH to it's original value.
#
# WARNING: We do this using undocumented internal functionality of CMake's
# file() command, and requires CMake 3.21 or newer to work.

# save current RPATH to reset it later
get_target_property(install_rpath_old qtfred INSTALL_RPATH)
# fix delimiters
string(REPLACE ";" ":" QTFRED_RPATH_orig "${install_rpath_old}")

# set new RPATH to be written to binary
# Note: file(RPATH_SET ...) cannot extend RPATH length so we have to do it
# this way to reserve enough space for the modified script to work properly
set_target_properties(qtfred PROPERTIES
INSTALL_RPATH "${QTFRED_RPATH_orig}:${_QTFRED_QT_LIBS}"
)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AppImage-$<CONFIG>.desktop" DESTINATION "." RENAME "qtfred.desktop"
COMPONENT "qtFRED")
# swap script name so no other code needs to be changed to use it
set(QTFRED_DEPLOY_SCRIPT_orig ${QTFRED_DEPLOY_SCRIPT})
set(QTFRED_DEPLOY_SCRIPT "${QTFRED_DEPLOY_SCRIPT_orig}-libfix")

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/resources/fred_icon.png" DESTINATION "."
COMPONENT "qtFRED")
# create modified deploy script with our RPATH fix/hack
file(GENERATE OUTPUT ${QTFRED_DEPLOY_SCRIPT} CONTENT
"file(RPATH_SET FILE $<TARGET_FILE:qtfred> NEW_RPATH \"${QTFRED_RPATH_orig}:${_QTFRED_QT_LIBS}\")
include(${QTFRED_DEPLOY_SCRIPT_orig})
file(RPATH_SET FILE $<TARGET_FILE:qtfred> NEW_RPATH \"${QTFRED_RPATH_orig}\")\n"
)
endif()

if (FSO_INSTALL_DEBUG_FILES)
if (MSVC)
install(FILES "$<TARGET_PDB_FILE:qtfred>"
DESTINATION ${BINARY_DESTINATION}
OPTIONAL)
endif()
# deploy Qt libs/plugins
add_custom_command(TARGET qtfred POST_BUILD
COMMAND ${CMAKE_COMMAND}
-D CMAKE_INSTALL_PREFIX=${QTFRED_DEPLOY_PREFIX}
-D QT_DEPLOY_PREFIX=${QTFRED_DEPLOY_PREFIX}
-D QT_DEPLOY_BIN_DIR=${BINARY_DESTINATION}
-D QT_DEPLOY_LIB_DIR=${LIBRAY_DESTINATION}
-P "${QTFRED_DEPLOY_SCRIPT}"
COMMENT "Running Qt deploy script..."
VERBATIM
)

install(CODE "
set(QT_DEPLOY_BIN_DIR ${BINARY_DESTINATION})
set(QT_DEPLOY_LIB_DIR ${LIBRAY_DESTINATION})
" COMPONENT "qtFRED")

install(SCRIPT "${QTFRED_DEPLOY_SCRIPT}" COMPONENT "qtFRED")

if (FSO_INSTALL_DEBUG_FILES AND MSVC)
install(FILES "$<TARGET_PDB_FILE:qtfred>"
DESTINATION ${BINARY_DESTINATION}
OPTIONAL)
endif()
7 changes: 0 additions & 7 deletions qtfred/cmake/AppRun.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,4 @@
HERE=$(dirname $(readlink -f "${0}"))
export LD_LIBRARY_PATH=${HERE}/lib:$LD_LIBRARY_PATH

# Qt5 doesn't work so well with Wayland for us so prefer the use of X11 unless
# another backend is already specified
# (NOTE: the -platform option will override this so we don't need to test for it)
if [ -z "$QT_QPA_PLATFORM" ]; then
export QT_QPA_PLATFORM="xcb;wayland"
fi

exec "${HERE}/bin/$<TARGET_FILE_NAME:qtfred>" "$@"
Binary file added qtfred/resources/fonts/DejaVuSans.ttf
Binary file not shown.
Binary file added qtfred/resources/fonts/DejaVuSansMono.ttf
Binary file not shown.
Loading
Loading