1
0
Fork 0
flightgear/src/Main/CMakeLists.txt

122 lines
3 KiB
Text
Raw Normal View History

# CMake module includes.
include(FlightGearComponent)
include(SetupFGFSBundle)
include(SetupFGFSEmbeddedResources)
include(SetupFGFSIncludes)
include(SetupFGFSLibraries)
include(SetupMSVCGrouping)
# Set up the Main FG file sources and headers (excluding bootstrap.cxx and its main() function).
if(MSVC)
set(MS_RESOURCE_FILE flightgear.rc)
endif(MSVC)
set(SOURCES
fg_commands.cxx
fg_init.cxx
fg_io.cxx
fg_os_common.cxx
fg_scene_commands.cxx
fg_props.cxx
FGInterpolator.cxx
globals.cxx
locale.cxx
logger.cxx
main.cxx
options.cxx
positioninit.cxx
screensaver_control.cxx
subsystemFactory.cxx
util.cxx
XLIFFParser.cxx
ErrorReporter.cxx
${MS_RESOURCE_FILE}
)
set(HEADERS
AircraftDirVisitorBase.hxx
fg_commands.hxx
fg_init.hxx
fg_io.hxx
fg_props.hxx
FGInterpolator.hxx
globals.hxx
locale.hxx
logger.hxx
main.hxx
options.hxx
positioninit.hxx
screensaver_control.hxx
subsystemFactory.hxx
util.hxx
XLIFFParser.hxx
ErrorReporter.hxx
sentryIntegration.hxx
)
flightgear_component(Main "${SOURCES}" "${HEADERS}" sentryIntegration.cxx)
# the main() function
set(MAIN_SOURCE
bootstrap.cxx
)
# Set up the embedded resources.
setup_fgfs_embedded_resources()
Integrate the EmbeddedResourceManager into FlightGear ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml (currently empty) is automatically "compiled" into ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.[ch]xx by fgrcc inside the build directory. These files are incorporated into the FlightGear build (FlightGear-resources.cxx is linked into FlightGear). When the XML embedded resource declaration file added here, FlightGear-resources.xml, is compiled, fgrcc is passed the --root=${CMAKE_SOURCE_DIR} option, so that files referred to in FlightGear-resources.xml are looked up relatively to the root directory of the FlightGear repository. One could use a second XML embedded resource declaration file compiled with a different --root option to grab files from FGData, for instance. I would name such a file FGData-resources.xml to be consistent with the current naming scheme. Note: this --root option applies to the paths of real files. Don't confuse it with the 'prefix' attribute of <qresource> elements inside XML resource declaration files (such as FlightGear-resources.xml), which applies to the virtual path of each resource defined beneath. The commands in src/Main/CMakeLists.txt ensure that FlightGear-resources.xml is recompiled with fgrcc whenever it is changed, and obviously also when FlightGear-resources.cxx or FlightGear-resources.hxx is missing. However, CMake doesn't know how to parse fgrcc XML resource declaration files, therefore when a resource is modified but the XML file it is declared in is not (here, FlightGear-resources.xml), you have to trigger yourself a recompilation of the XML resource declaration file to see the new resource contents inside FlightGear. The easiest ways to do so are: - either update the timestamp of the XML resource declaration file; - or remove one or both of the generated files (FlightGear-resources.cxx and FlightGear-resources.hxx here). The EmbeddedResourceManager is created in fgMainInit() just after Options::processOptions() set the language that was either requested by the user or obtained from the system (locales). Resources from FlightGear-resources.cxx are added to it, after which EmbeddedResourceManager::selectLocale() is called with the user's preferred locale (obtained with FGLocale::getPreferredLanguage()). Upon reset (fgStartNewReset()), EmbeddedResourceManager::selectLocale() is called in a similar way after Options::processOptions(), however in this case the EmbeddedResourceManager instance doesn't have to be recreated.
2017-04-27 22:09:14 +00:00
# Sort the sources and headers for MSVC.
setup_msvc_grouping()
# souerces which are different for fgfs vs the test-suite
get_property(TEST_SOURCES GLOBAL PROPERTY FG_TEST_SOURCES)
2020-08-19 13:49:50 +00:00
# important we pass WIN32 here so the console is optional. Other
# platforms ignore this option. If a console is needed we allocate
# it manually via AllocConsole()
# similarly pass MACOSX_BUNDLE so we generate a .app on Mac
add_executable(fgfs
WIN32
MACOSX_BUNDLE
${MAIN_SOURCE}
${TEST_SOURCES}
$<TARGET_OBJECTS:fgfsObjects>
)
add_dependencies(fgfs buildId)
# explicitly disable automoc for main fgfs target
set_property(TARGET fgfs PROPERTY AUTOMOC OFF)
# MacOSX bundle packaging
if(APPLE)
setup_fgfs_bundle(fgfs)
endif()
# Set up the target links.
setup_fgfs_libraries(fgfs)
export_debug_symbols(fgfs)
2020-08-19 13:49:50 +00:00
# Additional search paths for includes.
setup_fgfs_includes(fgfs)
# this has to live here for compatability with older CMake versions
if (APPLE)
install(TARGETS fgfs BUNDLE DESTINATION .)
else()
install(TARGETS fgfs RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if(ENABLE_METAR)
add_executable(metar metar_main.cxx)
2020-08-19 13:49:50 +00:00
target_link_libraries(metar SimGearScene)
install(TARGETS metar RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
# ensure run/debug paths are set automatically in Visual Studio
if (MSVC)
file(TO_NATIVE_PATH "${FG_QT_BIN_DIR}" _qt5_bin_dir_native)
file(TO_NATIVE_PATH "${FINAL_MSVC_3RDPARTY_DIR}/bin" _msvc_3rdparty_bin_dir)
file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" _install_bin_dir)
set_property(TARGET fgfs PROPERTY
VS_GLOBAL_LocalDebuggerEnvironment "PATH=${_install_bin_dir};${_msvc_3rdparty_bin_dir};${_qt5_bin_dir_native}")
endif()