1
0
Fork 0

Cmake: fix compat with CMake 3.10

Thankfully StackOverflow had an evil solution to this missing feature
in 3.10.
This commit is contained in:
James Turner 2020-08-23 22:25:03 +01:00
parent 95fd692af1
commit a82a13b70c
3 changed files with 20 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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)