2018-03-25 12:18:24 +00:00
|
|
|
# CMake module includes.
|
2018-03-26 18:27:12 +00:00
|
|
|
include(FlightGearComponent)
|
2018-03-25 16:51:10 +00:00
|
|
|
include(SetupFGFSBundle)
|
2018-03-25 12:29:02 +00:00
|
|
|
include(SetupFGFSEmbeddedResources)
|
2018-03-26 20:27:25 +00:00
|
|
|
include(SetupFGFSIncludes)
|
2018-03-25 12:18:24 +00:00
|
|
|
include(SetupFGFSLibraries)
|
2018-03-25 12:35:46 +00:00
|
|
|
include(SetupMSVCGrouping)
|
2010-11-30 10:08:30 +00:00
|
|
|
|
2018-03-26 18:27:12 +00:00
|
|
|
# Set up the Main FG file sources and headers (excluding bootstrap.cxx and its main() function).
|
2018-03-02 21:18:28 +00:00
|
|
|
if(MSVC)
|
2018-03-26 18:27:12 +00:00
|
|
|
set(MS_RESOURCE_FILE flightgear.rc)
|
2018-03-02 21:18:28 +00:00
|
|
|
endif(MSVC)
|
2011-01-28 18:30:27 +00:00
|
|
|
|
2010-11-30 10:08:30 +00:00
|
|
|
set(SOURCES
|
2018-03-02 21:18:28 +00:00
|
|
|
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
|
2012-09-18 19:50:28 +00:00
|
|
|
positioninit.cxx
|
2013-12-09 00:13:44 +00:00
|
|
|
screensaver_control.cxx
|
2018-03-02 21:18:28 +00:00
|
|
|
subsystemFactory.cxx
|
|
|
|
util.cxx
|
2018-08-11 14:13:46 +00:00
|
|
|
XLIFFParser.cxx
|
2020-04-07 08:38:54 +00:00
|
|
|
sentryIntegration.cxx
|
2018-03-26 18:27:12 +00:00
|
|
|
${MS_RESOURCE_FILE}
|
2018-03-02 21:18:28 +00:00
|
|
|
)
|
2011-06-26 06:49:37 +00:00
|
|
|
|
|
|
|
set(HEADERS
|
2013-11-16 14:22:34 +00:00
|
|
|
AircraftDirVisitorBase.hxx
|
2018-03-02 21:18:28 +00:00
|
|
|
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
|
2013-12-09 00:13:44 +00:00
|
|
|
screensaver_control.hxx
|
2018-03-02 21:18:28 +00:00
|
|
|
subsystemFactory.hxx
|
|
|
|
util.hxx
|
2018-08-11 14:13:46 +00:00
|
|
|
XLIFFParser.hxx
|
2020-04-07 08:38:54 +00:00
|
|
|
sentryIntegration.hxx
|
2018-03-02 21:18:28 +00:00
|
|
|
)
|
2011-06-26 06:49:37 +00:00
|
|
|
|
2018-03-26 18:27:12 +00:00
|
|
|
flightgear_component(Main "${SOURCES}" "${HEADERS}")
|
|
|
|
|
|
|
|
# The main() function.
|
|
|
|
set(MAIN_SOURCE
|
|
|
|
bootstrap.cxx
|
|
|
|
)
|
|
|
|
|
2018-03-25 12:29:02 +00:00
|
|
|
# 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
|
|
|
|
2018-03-25 12:35:46 +00:00
|
|
|
# Sort the sources and headers for MSVC.
|
|
|
|
setup_msvc_grouping()
|
|
|
|
|
2020-08-19 13:49:50 +00:00
|
|
|
|
2018-03-26 20:27:25 +00:00
|
|
|
|
2018-03-25 12:29:02 +00:00
|
|
|
# All sources and headers to be built into fgfs.
|
2012-03-26 12:09:39 +00:00
|
|
|
get_property(FG_SOURCES GLOBAL PROPERTY FG_SOURCES)
|
|
|
|
get_property(FG_HEADERS GLOBAL PROPERTY FG_HEADERS)
|
2018-03-25 12:29:02 +00:00
|
|
|
get_property(EMBEDDED_RESOURCE_SOURCES GLOBAL PROPERTY EMBEDDED_RESOURCE_SOURCES)
|
|
|
|
get_property(EMBEDDED_RESOURCE_HEADERS GLOBAL PROPERTY EMBEDDED_RESOURCE_HEADERS)
|
2012-03-26 12:09:39 +00:00
|
|
|
|
2019-12-26 07:26:44 +00:00
|
|
|
set_source_files_properties(${EMBEDDED_RESOURCE_SOURCES} PROPERTIES GENERATED TRUE)
|
|
|
|
set_source_files_properties(${EMBEDDED_RESOURCE_HEADERS} PROPERTIES GENERATED TRUE)
|
|
|
|
|
2013-10-26 20:06:03 +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()
|
2014-02-14 18:58:36 +00:00
|
|
|
# similarly pass MACOSX_BUNDLE so we generate a .app on Mac
|
2018-03-25 12:29:02 +00:00
|
|
|
add_executable(fgfs
|
|
|
|
WIN32
|
|
|
|
MACOSX_BUNDLE
|
2018-03-26 18:27:12 +00:00
|
|
|
${MAIN_SOURCE}
|
2018-03-25 12:29:02 +00:00
|
|
|
${FG_SOURCES}
|
|
|
|
${FG_HEADERS}
|
|
|
|
${EMBEDDED_RESOURCE_SOURCES}
|
|
|
|
${EMBEDDED_RESOURCE_HEADERS}
|
|
|
|
)
|
2014-02-14 18:58:36 +00:00
|
|
|
|
2019-12-26 07:26:44 +00:00
|
|
|
add_dependencies(fgfs buildId embeddedresources)
|
2018-08-28 11:04:56 +00:00
|
|
|
# explicitly disable automoc for main fgfs target
|
|
|
|
set_property(TARGET fgfs PROPERTY AUTOMOC OFF)
|
2018-08-19 15:06:16 +00:00
|
|
|
|
2018-03-02 21:18:28 +00:00
|
|
|
# MacOSX bundle packaging
|
2014-02-14 18:58:36 +00:00
|
|
|
if(APPLE)
|
2018-03-25 16:51:10 +00:00
|
|
|
setup_fgfs_bundle(fgfs)
|
2014-02-14 18:58:36 +00:00
|
|
|
endif()
|
|
|
|
|
2018-03-26 20:27:25 +00:00
|
|
|
# Set up the target links.
|
2018-03-25 12:18:24 +00:00
|
|
|
setup_fgfs_libraries(fgfs)
|
2020-04-07 08:38:13 +00:00
|
|
|
export_debug_symbols(fgfs)
|
2020-08-19 13:49:50 +00:00
|
|
|
# Additional search paths for includes.
|
|
|
|
setup_fgfs_includes(fgfs)
|
2011-10-21 11:48:42 +00:00
|
|
|
|
2020-04-07 08:38:13 +00:00
|
|
|
if (TARGET sentry::sentry)
|
2020-04-14 10:15:40 +00:00
|
|
|
target_link_libraries(fgfs sentry::sentry)
|
2020-04-07 08:38:13 +00:00
|
|
|
endif()
|
|
|
|
|
2013-02-12 16:38:46 +00:00
|
|
|
if(ENABLE_METAR)
|
|
|
|
add_executable(metar metar_main.cxx)
|
2020-08-19 13:49:50 +00:00
|
|
|
target_link_libraries(metar SimGearScene)
|
2016-07-09 21:14:28 +00:00
|
|
|
install(TARGETS metar RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2013-02-12 16:38:46 +00:00
|
|
|
endif()
|
2017-03-27 14:37:54 +00:00
|
|
|
|
2018-06-16 12:03:23 +00:00
|
|
|
if (MSVC)
|
2020-06-10 16:59:09 +00:00
|
|
|
file(TO_NATIVE_PATH "${FG_QT_BIN_DIR}" _qt5_bin_dir_native)
|
2018-06-16 12:03:23 +00:00
|
|
|
file(TO_NATIVE_PATH "${MSVC_3RDPARTY_ROOT}/${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()
|
2018-11-12 15:46:41 +00:00
|
|
|
|
2020-06-10 16:59:09 +00:00
|
|
|
if (FG_QT_ROOT_DIR)
|
2018-11-12 15:46:41 +00:00
|
|
|
# for QtPlatformHeaders
|
2020-06-10 16:59:09 +00:00
|
|
|
target_include_directories(fgfs PRIVATE ${FG_QT_ROOT_DIR}/include)
|
2018-11-12 15:46:41 +00:00
|
|
|
endif()
|