From 476b9eb3d12913345bcf629a25f6d91a8bdc2792 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 23 Aug 2020 21:10:56 +0100 Subject: [PATCH 1/3] Ensure OSG headers are founding building the UI --- src/GUI/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GUI/CMakeLists.txt b/src/GUI/CMakeLists.txt index 55935646f..87bb61816 100644 --- a/src/GUI/CMakeLists.txt +++ b/src/GUI/CMakeLists.txt @@ -135,7 +135,11 @@ if (HAVE_QT) ${qml_sources}) set_property(TARGET fglauncher PROPERTY AUTOMOC ON) - target_include_directories(fglauncher PRIVATE ${PROJECT_BINARY_DIR}/src/GUI) + target_include_directories(fglauncher PRIVATE ${PROJECT_BINARY_DIR}/src/GUI ) + + # we include WindowBuilder.h which needs this + target_include_directories(fglauncher PRIVATE ${OPENSCENEGRAPH_INCLUDE_DIRS}) + target_link_libraries(fglauncher Qt5::Core Qt5::Widgets Qt5::Network Qt5::Qml Qt5::Quick Qt5::Svg SimGearCore) if (ENABLE_QQ_UI) @@ -196,8 +200,8 @@ if (HAVE_QT) set_property(TARGET fgqmlui PROPERTY AUTOMOC ON) target_link_libraries(fgqmlui Qt5::Quick Qt5::Widgets Qt5::Network Qt5::Qml Qt5::Gui SimGearCore) - target_include_directories(fgqmlui PRIVATE ${PROJECT_BINARY_DIR}/src/GUI) - + target_include_directories(fgqmlui PRIVATE ${PROJECT_BINARY_DIR}/src/GUI ${OPENSCENEGRAPH_INCLUDE_DIRS}) + if (ENABLE_QQ_UI) # this is a headers-only dependency, so we can include target_link_libraries(fgqmlui Qt5::GuiPrivate) From 95fd692af1fbc0af357bb539e300386dddc37ca2 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 23 Aug 2020 21:50:36 +0100 Subject: [PATCH 2/3] CMake: move install() rule for compatability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Older CMake versions can’t install(TARGET…) from a different directory. --- CMakeModules/Installation.cmake | 5 ----- src/Main/CMakeLists.txt | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeModules/Installation.cmake b/CMakeModules/Installation.cmake index 8c09d7b9e..3ebecda15 100644 --- a/CMakeModules/Installation.cmake +++ b/CMakeModules/Installation.cmake @@ -1,9 +1,4 @@ -if (APPLE) - install(TARGETS fgfs BUNDLE DESTINATION .) -else() - install(TARGETS fgfs RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -endif() if (TARGET sentry_crashpad::handler) if (APPLE) diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index fce400c1b..1e3010e7a 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -99,6 +99,13 @@ export_debug_symbols(fgfs) # 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 (TARGET sentry::sentry) target_link_libraries(fgfs sentry::sentry) endif() From a82a13b70c667393098e29d4e6877144b5110b3c Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 23 Aug 2020 22:25:03 +0100 Subject: [PATCH 3/3] Cmake: fix compat with CMake 3.10 Thankfully StackOverflow had an evil solution to this missing feature in 3.10. --- CMakeLists.txt | 13 +++++++++++++ CMakeModules/FindDBus.cmake | 5 ++++- CMakeModules/FindLibEvent.cmake | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0f3c1270..71f4c8589 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,19 @@ set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version") +if(${CMAKE_VERSION} VERSION_LESS "3.11.0") + # override add_library to work around a missing feature in CMake 3.10 + # see https://stackoverflow.com/questions/45401212/how-to-make-imported-target-global-afterwards + # for discussion of why we need this + function(add_library) + set(_args ${ARGN}) + if ("${_args}" MATCHES ";IMPORTED") + list(APPEND _args GLOBAL) + endif() + _add_library(${_args}) + endfunction() +endif() + project(FlightGear) # Define SRC_PARENT_DIR as the parent directory of the project source directory diff --git a/CMakeModules/FindDBus.cmake b/CMakeModules/FindDBus.cmake index 2df20f869..9e5aa88e3 100644 --- a/CMakeModules/FindDBus.cmake +++ b/CMakeModules/FindDBus.cmake @@ -18,12 +18,15 @@ if(WIN32) else() find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) pkg_check_modules(DBUS IMPORTED_TARGET dbus-1) endif (PKG_CONFIG_FOUND) if(DBUS_FOUND) - set_target_properties(PkgConfig::DBUS PROPERTIES IMPORTED_GLOBAL TRUE) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.11.0") + set_target_properties(PkgConfig::DBUS PROPERTIES IMPORTED_GLOBAL TRUE) + endif() set(HAVE_DBUS 1) # alias the PkgConfig name to standard one diff --git a/CMakeModules/FindLibEvent.cmake b/CMakeModules/FindLibEvent.cmake index 664f2385d..c0898fcf4 100644 --- a/CMakeModules/FindLibEvent.cmake +++ b/CMakeModules/FindLibEvent.cmake @@ -22,7 +22,9 @@ else() endif() if(libEvent_FOUND) - set_target_properties(PkgConfig::libEvent PROPERTIES IMPORTED_GLOBAL TRUE) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.11.0") + set_target_properties(PkgConfig::libEvent PROPERTIES IMPORTED_GLOBAL TRUE) + endif() # alias the PkgConfig name to standard one add_library(libEvent ALIAS PkgConfig::libEvent)