Restore compatibility with CMake < 3.12
This commit is contained in:
parent
37272b14ac
commit
6e42c8fc57
2 changed files with 92 additions and 6 deletions
|
@ -312,7 +312,7 @@ if (ENABLE_QT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC OFF)
|
set(CMAKE_AUTOMOC OFF)
|
||||||
|
|
||||||
message(STATUS "Qt GUI enabled, found Qt at: ${FG_QT_ROOT_DIR}")
|
message(STATUS "Qt GUI enabled, found Qt at: ${FG_QT_ROOT_DIR}")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Qt GUI disabled, Qt/qmake not found in PATH/CMAKE_PREFIX_PATH")
|
message(STATUS "Qt GUI disabled, Qt/qmake not found in PATH/CMAKE_PREFIX_PATH")
|
||||||
|
@ -378,6 +378,12 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
|
||||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
|
||||||
|
|
||||||
|
if(HAVE_QT)
|
||||||
|
# if Qt is built with reduce-relocations, applicatino code
|
||||||
|
# needs to be compiled with -fPIC to match
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
endif()
|
||||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
|
||||||
|
@ -482,15 +488,15 @@ include(SetupFGFSLibraries)
|
||||||
# create an object library target to hold all our sources
|
# create an object library target to hold all our sources
|
||||||
# subdirectories will append sources to this target, and we'll
|
# subdirectories will append sources to this target, and we'll
|
||||||
# link it into our real executable targets
|
# link it into our real executable targets
|
||||||
|
# use of 'flightgear-version' text file here is a dummy; CMake 3.10
|
||||||
|
# requries at least one direct source file for targets, even though
|
||||||
|
# we use target_sources() later
|
||||||
|
|
||||||
|
add_library(fgfsObjects OBJECT flightgear-version)
|
||||||
|
|
||||||
add_library(fgfsObjects OBJECT)
|
|
||||||
# Set up the include search paths for the object library
|
|
||||||
setup_fgfs_libraries(fgfsObjects)
|
|
||||||
setup_fgfs_includes(fgfsObjects)
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(3rdparty)
|
add_subdirectory(3rdparty)
|
||||||
add_subdirectory(utils)
|
add_subdirectory(utils)
|
||||||
|
|
||||||
|
@ -500,6 +506,11 @@ add_subdirectory(man)
|
||||||
add_subdirectory(package)
|
add_subdirectory(package)
|
||||||
add_subdirectory(scripts)
|
add_subdirectory(scripts)
|
||||||
|
|
||||||
|
# Set up the include search paths for the object library : has to be done
|
||||||
|
# after targets are fully defined
|
||||||
|
setup_fgfs_library_includes(fgfsObjects)
|
||||||
|
setup_fgfs_includes(fgfsObjects)
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
### MSVC startup project - ensure you can just hit build & run in MSVC
|
### MSVC startup project - ensure you can just hit build & run in MSVC
|
||||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT fgfs)
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT fgfs)
|
||||||
|
|
|
@ -67,3 +67,78 @@ function(setup_fgfs_libraries target)
|
||||||
target_link_libraries(${target} sentry::sentry)
|
target_link_libraries(${target} sentry::sentry)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# CMake < 3.12 can't define a link to an OBJECT library to specify its include
|
||||||
|
# paths, so we have to essentially duplicate the above and configure the paths manually.
|
||||||
|
# Once we require CMake 3.12, delete all this and use the function above.
|
||||||
|
|
||||||
|
function (_apply_target_includes dest target)
|
||||||
|
if (NOT TARGET ${target})
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# retrieve the list of includes from the target
|
||||||
|
get_target_property(includes ${target} INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
|
||||||
|
foreach(i ${includes})
|
||||||
|
# skip any invalid includes
|
||||||
|
if (NOT i)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(${dest} PUBLIC ${i})
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function (_apply_all_target_includes dest)
|
||||||
|
foreach(arg IN LISTS ARGN)
|
||||||
|
_apply_target_includes(${dest} ${arg})
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function (setup_fgfs_library_includes target)
|
||||||
|
|
||||||
|
_apply_all_target_includes(${target}
|
||||||
|
SimGearCore
|
||||||
|
SimGearScene
|
||||||
|
Boost::boost
|
||||||
|
${EVENT_INPUT_LIBRARIES}
|
||||||
|
${HLA_LIBRARIES}
|
||||||
|
${OPENGL_LIBRARIES}
|
||||||
|
${OPENSCENEGRAPH_LIBRARIES}
|
||||||
|
${PLATFORM_LIBS}
|
||||||
|
${PLIB_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(ENABLE_JSBSIM)
|
||||||
|
_apply_target_includes(${target} JSBSim)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
_apply_target_includes(${target} fgsqlite3)
|
||||||
|
_apply_target_includes(${target} fgvoicesynth)
|
||||||
|
_apply_target_includes(${target} fgembeddedresources)
|
||||||
|
|
||||||
|
if (HAVE_QT)
|
||||||
|
_apply_all_target_includes(${target} Qt5::Core Qt5::Widgets Qt5::Gui)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_IAX)
|
||||||
|
_apply_target_includes(${target} iaxclient_lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (ENABLE_SWIFT)
|
||||||
|
_apply_all_target_includes(${target} ${dbus_target})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (ENABLE_PLIB_JOYSTICK)
|
||||||
|
_apply_target_includes(${target} PLIBJoystick)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
_apply_target_includes(${target} PLIBFont)
|
||||||
|
|
||||||
|
if (TARGET sentry::sentry)
|
||||||
|
_apply_target_includes(${target} sentry::sentry)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endfunction()
|
Loading…
Reference in a new issue