b2cc191bc6
${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.
202 lines
5.7 KiB
CMake
202 lines
5.7 KiB
CMake
|
|
if (MSVC)
|
|
set( RESOURCE_FILE flightgear.rc )
|
|
endif (MSVC)
|
|
|
|
set(SOURCES
|
|
bootstrap.cxx
|
|
fg_commands.cxx
|
|
fg_scene_commands.cxx
|
|
fg_init.cxx
|
|
fg_io.cxx
|
|
fg_os_common.cxx
|
|
fg_props.cxx
|
|
FGInterpolator.cxx
|
|
globals.cxx
|
|
locale.cxx
|
|
logger.cxx
|
|
main.cxx
|
|
options.cxx
|
|
util.cxx
|
|
positioninit.cxx
|
|
subsystemFactory.cxx
|
|
screensaver_control.cxx
|
|
${RESOURCE_FILE}
|
|
${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx
|
|
)
|
|
|
|
set(HEADERS
|
|
fg_commands.hxx
|
|
fg_init.hxx
|
|
fg_io.hxx
|
|
fg_props.hxx
|
|
FGInterpolator.hxx
|
|
globals.hxx
|
|
locale.hxx
|
|
logger.hxx
|
|
main.hxx
|
|
options.hxx
|
|
util.hxx
|
|
positioninit.hxx
|
|
subsystemFactory.hxx
|
|
AircraftDirVisitorBase.hxx
|
|
screensaver_control.hxx
|
|
${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx
|
|
)
|
|
|
|
add_custom_command(
|
|
OUTPUT ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx
|
|
${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx
|
|
COMMAND fgrcc --root=${CMAKE_SOURCE_DIR} --output-cpp-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx --init-func-name=initFlightGearEmbeddedResources --output-header-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx --output-header-identifier=_FG_FLIGHTGEAR_EMBEDDED_RESOURCES ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml
|
|
DEPENDS
|
|
fgrcc ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml
|
|
)
|
|
|
|
get_property(FG_SOURCES GLOBAL PROPERTY FG_SOURCES)
|
|
get_property(FG_HEADERS GLOBAL PROPERTY FG_HEADERS)
|
|
|
|
link_directories ( ${Boost_LIBRARY_DIRS} )
|
|
|
|
get_property(FG_GROUPS_C GLOBAL PROPERTY FG_GROUPS_C)
|
|
string(REPLACE "@" ";" groups ${FG_GROUPS_C} )
|
|
foreach(g ${groups})
|
|
string(REPLACE "#" ";" g2 ${g})
|
|
list(GET g2 0 name)
|
|
list(REMOVE_AT g2 0)
|
|
source_group("${name}\\Sources" FILES ${g2})
|
|
endforeach()
|
|
|
|
get_property(FG_GROUPS_H GLOBAL PROPERTY FG_GROUPS_H)
|
|
string(REPLACE "@" ";" groups ${FG_GROUPS_H} )
|
|
foreach(g ${groups})
|
|
string(REPLACE "#" ";" g2 ${g})
|
|
list(GET g2 0 name)
|
|
list(REMOVE_AT g2 0)
|
|
source_group("${name}\\Headers" FILES ${g2})
|
|
endforeach()
|
|
|
|
source_group("Main\\Headers" FILES ${HEADERS})
|
|
source_group("Main\\Sources" FILES ${SOURCES})
|
|
|
|
# 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
|
|
${SOURCES} ${FG_SOURCES} ${FG_HEADERS} ${HEADERS})
|
|
|
|
#-----------------------------------------------------------------------------
|
|
# MacOSX bundle packagaing
|
|
|
|
if(APPLE)
|
|
execute_process(COMMAND date +%Y
|
|
OUTPUT_VARIABLE CURRENT_YEAR
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
# in our local CMakeModules dir
|
|
set_target_properties(fgfs PROPERTIES
|
|
MACOSX_BUNDLE_INFO_PLIST FlightGearBundleInfo.plist.in
|
|
MACOSX_BUNDLE_GUI_IDENTIFIER "org.flightgear.FlightGear"
|
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${FLIGHTGEAR_VERSION}
|
|
MACOSX_BUNDLE_LONG_VERSION_STRING "FlightGear ${FLIGHTGEAR_VERSION} Nightly"
|
|
MACOSX_BUNDLE_BUNDLE_VERSION ${FLIGHTGEAR_VERSION}
|
|
MACOSX_BUNDLE_COPYRIGHT "FlightGear ${FLIGHTGEAR_VERSION} © 1997-${CURRENT_YEAR}, The FlightGear Project. Licensed under the GNU Public License version 2."
|
|
MACOSX_BUNDLE_INFO_STRING "Nightly build of FlightGear ${FLIGHTGEAR_VERSION} for testing and development"
|
|
MACOSX_BUNDLE_BUNDLE_NAME "FlightGear"
|
|
MACOSX_BUNDLE_ICON_FILE "FlightGear.icns"
|
|
)
|
|
endif()
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
get_property(FG_LIBS GLOBAL PROPERTY FG_LIBS)
|
|
#message(STATUS "fg libs ${FG_LIBS}")
|
|
#message(STATUS "OSG libs ${OPENSCENEGRAPH_LIBRARIES}")
|
|
#message(STATUS "SG libs ${SIMGEAR_LIBRARIES}")
|
|
|
|
if(RTI_FOUND)
|
|
set(HLA_LIBRARIES ${RTI_LIBRARIES})
|
|
else()
|
|
set(HLA_LIBRARIES "")
|
|
endif()
|
|
|
|
if(GDAL_FOUND)
|
|
set(GDAL_LIBRARIES ${GDAL_LIBRARY})
|
|
else()
|
|
set(GDAL_LIBRARIES "")
|
|
endif()
|
|
|
|
if(ENABLE_JSBSIM)
|
|
# FIXME - remove once JSBSim doesn't expose private headers
|
|
include_directories(${PROJECT_SOURCE_DIR}/src/FDM/JSBSim)
|
|
|
|
target_link_libraries(fgfs JSBSim)
|
|
endif()
|
|
if(ENABLE_IAX)
|
|
target_link_libraries(fgfs iaxclient_lib ${OPENAL_LIBRARY})
|
|
endif()
|
|
if(USE_DBUS)
|
|
target_link_libraries(fgfs ${DBUS_LIBRARIES})
|
|
endif()
|
|
if(FG_HAVE_GPERFTOOLS)
|
|
include_directories(${GooglePerfTools_INCLUDE_DIR})
|
|
target_link_libraries(fgfs ${GooglePerfTools_LIBRARIES})
|
|
endif()
|
|
|
|
if (CRASHRPT_FOUND)
|
|
target_link_libraries(fgfs ${CRASHRPT_LIBRARY})
|
|
endif()
|
|
if(X11_FOUND)
|
|
target_link_libraries(fgfs ${X11_LIBRARIES})
|
|
endif()
|
|
target_link_libraries(fgfs
|
|
SimGearCore SimGearScene
|
|
${SQLITE3_LIBRARY}
|
|
${SIMGEAR_LIBRARIES}
|
|
${OPENSCENEGRAPH_LIBRARIES}
|
|
${OPENGL_LIBRARIES}
|
|
${PLIB_LIBRARIES}
|
|
${HLA_LIBRARIES}
|
|
${GDAL_LIBRARIES}
|
|
${EVENT_INPUT_LIBRARIES}
|
|
${PLATFORM_LIBS}
|
|
)
|
|
|
|
if(ENABLE_FLITE)
|
|
if(SYSTEM_HTS_ENGINE)
|
|
target_link_libraries(fgfs flite_hts ${HTS_ENGINE_LIBRARIES})
|
|
else()
|
|
target_link_libraries(fgfs flite_hts hts_engine)
|
|
endif()
|
|
endif()
|
|
|
|
if (Qt5Core_FOUND)
|
|
target_link_libraries(fgfs Qt5::Widgets fglauncher)
|
|
set_property(TARGET fgfs PROPERTY AUTOMOC ON)
|
|
endif()
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
target_link_libraries(fgfs execinfo)
|
|
endif()
|
|
|
|
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)
|
|
target_link_libraries(metar
|
|
SimGearScene SimGearCore
|
|
${PLATFORM_LIBS}
|
|
)
|
|
|
|
install(TARGETS metar RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
endif()
|
|
|
|
if (COMMAND flightgear_test)
|
|
flightgear_test(posinit test_posinit.cxx)
|
|
flightgear_test(autosaveMigration test_autosaveMigration.cxx)
|
|
endif()
|