From eb33d2f7583405fca184bcdf7fdd5828ec88ac05 Mon Sep 17 00:00:00 2001 From: Julia DeMille <8127111+judemille@users.noreply.github.com> Date: Thu, 14 Dec 2023 02:19:20 -0600 Subject: [PATCH] [x-plane] Update to 4.0.1, effectively new port (#35032) * [xplane-sdk] New port * [xplane-sdk] This build should work. * [xplane-sdk] updated versions. i forgor. * [xplane-sdk] Build fixed for Mac. * [x-plane-sdk] xplane-sdk renamed to x-plane-sdk. xplane-sdk has not yet been published, so this is okay. * [x-plane-sdk] Renaming fixes. * [x-plane-sdk] Clarify license. The license seems to be a weird mix of the MIT, BSD 1-clause, and BSD 3-clause licenses. I can't work it out. It's permissive, but it's not any one license. * [x-plane-sdk] Switch to vcpkg_install_copyright. * [x-plane-sdk] Fixup config. * Rename x-plane-sdk to x-plane. Includes also moved to include root. Signed-off-by: Julia DeMille * Forgot to format and update versions. Signed-off-by: Julia DeMille --------- Signed-off-by: Julia DeMille --- ports/x-plane/CMakeLists.txt | 99 +++++++++++++++++++ ports/x-plane/portfile.cmake | 51 +++++----- .../unofficial-x-plane-config.cmake.in | 62 ++++++++++++ ports/x-plane/usage | 4 + ports/x-plane/vcpkg.json | 16 ++- versions/baseline.json | 4 +- versions/x-/x-plane.json | 5 + 7 files changed, 207 insertions(+), 34 deletions(-) create mode 100644 ports/x-plane/CMakeLists.txt create mode 100644 ports/x-plane/unofficial-x-plane-config.cmake.in create mode 100644 ports/x-plane/usage diff --git a/ports/x-plane/CMakeLists.txt b/ports/x-plane/CMakeLists.txt new file mode 100644 index 0000000000..a04fbbc972 --- /dev/null +++ b/ports/x-plane/CMakeLists.txt @@ -0,0 +1,99 @@ +cmake_minimum_required(VERSION 3.21) +project(x-plane LANGUAGES C CXX) + +if(WIN32 OR APPLE) + add_library(unofficial::x-plane::xplm SHARED IMPORTED) + if(WIN32) + set_target_properties( + unofficial::x-plane::xplm + PROPERTIES IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Win/XPLM_64.lib") + set_target_properties( + unofficial::x-plane::xplm PROPERTIES INTERFACE_COMPILE_DEFINITIONS + "-DIBM=1;-DAPL=0;-DLIN=0") + else() + set_target_properties( + unofficial::x-plane::xplm + PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Mac/XPLM.framework/XPLM") + set_target_properties( + unofficial::x-plane::xplm PROPERTIES INTERFACE_COMPILE_DEFINITIONS + "-DIBM=0;-DAPL=1;-DLIN=0") + endif() +else() + add_library(unofficial::x-plane::xplm INTERFACE IMPORTED) + set_target_properties( + unofficial::x-plane::xplm PROPERTIES INTERFACE_COMPILE_DEFINITIONS + "-DIBM=0;-DAPL=0;-DLIN=1") +endif() +set_target_properties( + unofficial::x-plane::xplm PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${CMAKE_CURRENT_SOURCE_DIR}/CHeaders/XPLM") + +if(WIN32 OR APPLE) + add_library(unofficial::x-plane::xpwidgets SHARED IMPORTED) + if(WIN32) + set_target_properties( + unofficial::x-plane::xpwidgets + PROPERTIES IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Win/XPWidgets_64.lib") + else() + set_target_properties( + unofficial::x-plane::xpwidgets + PROPERTIES IMPORTED_LOCATION + "${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Mac/XPWidgets.framework/XPWidgets") + endif() +else() + add_library(unofficial::x-plane::xpwidgets INTERFACE IMPORTED) +endif() +set_target_properties( + unofficial::x-plane::xpwidgets PROPERTIES INTERFACE_LINK_LIBRARIES + "unofficial::x-plane::xplm") +set_target_properties( + unofficial::x-plane::xpwidgets + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/CHeaders/Widgets") + +add_library(xplm_cpp STATIC) + +target_sources( + xplm_cpp + PRIVATE CHeaders/Wrappers/XPCBroadcaster.cpp + CHeaders/Wrappers/XPCDisplay.cpp + CHeaders/Wrappers/XPCListener.cpp + CHeaders/Wrappers/XPCProcessing.cpp + CHeaders/Wrappers/XPCWidget.cpp + CHeaders/Wrappers/XPCWidgetAttachments.cpp) + +target_include_directories( + xplm_cpp + INTERFACE $ + $) + +target_link_libraries(xplm_cpp PUBLIC unofficial::x-plane::xplm + unofficial::x-plane::xpwidgets) + +install( + TARGETS xplm_cpp + EXPORT xplm-targets + ARCHIVE DESTINATION lib) + +file(GLOB HEADERS "${CMAKE_CURRENT_LIST_DIR}/CHeaders/XPLM/*.h") +install(FILES ${HEADERS} DESTINATION "include") + +file(GLOB HEADERS "${CMAKE_CURRENT_LIST_DIR}/CHeaders/Widgets/*.h") +install(FILES ${HEADERS} DESTINATION "include") + +file(GLOB HEADERS "${CMAKE_CURRENT_LIST_DIR}/CHeaders/Wrappers/*.h") +install(FILES ${HEADERS} DESTINATION "include") + +include(CMakePackageConfigHelpers) +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/unofficial-x-plane-config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/unofficial-x-plane-config.cmake" + INSTALL_DESTINATION "share/unofficial-x-plane") + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-x-plane-config.cmake" + DESTINATION "share/unofficial-x-plane") + +install( + EXPORT xplm-targets + DESTINATION share/unofficial-x-plane + FILE unofficial-x-plane-targets.cmake + NAMESPACE unofficial::x-plane::) diff --git a/ports/x-plane/portfile.cmake b/ports/x-plane/portfile.cmake index f7a291feea..eebc06d6c1 100644 --- a/ports/x-plane/portfile.cmake +++ b/ports/x-plane/portfile.cmake @@ -1,37 +1,30 @@ -vcpkg_download_distfile(ARCHIVE - URLS "http://developer.x-plane.com/wp-content/plugins/code-sample-generation/sample_templates/XPSDK303.zip" - FILENAME "XPSDK303.zip" - SHA512 23a1efc893fdb838ce90307ac2e1bf592b03880e9c7bf7aac51cf0d358816931b56a3d603e266f3c9041620190c689dc4d3b28b288bc39cf6e653db6f2125395 -) +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) +set(XPSDK_VERSION "401") +vcpkg_download_distfile( + XPLANE_SDK_ZIP + URLS "https://developer.x-plane.com/wp-content/plugins/code-sample-generation/sample_templates/XPSDK${XPSDK_VERSION}.zip" + FILENAME "XPSDK${XPSDK_VERSION}.zip" + SHA512 8e00789befd15f5b1cb4f426ddf9c3f7f021c5fba50b907e8af5fbf09abbc362804b5d1543332855d01e8ae91b9c50a55933e63df6e11e88e58c10ca8f949bf4 +) vcpkg_extract_source_archive( SOURCE_PATH - ARCHIVE ${ARCHIVE} + ARCHIVE "${XPLANE_SDK_ZIP}" ) -# create lib dir -if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_OSX) - file(MAKE_DIRECTORY - ${CURRENT_PACKAGES_DIR}/lib - ${CURRENT_PACKAGES_DIR}/debug/lib - ) -endif() +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-x-plane-config.cmake.in" DESTINATION "${SOURCE_PATH}") -# copy headers & sources -file(COPY ${SOURCE_PATH}/CHeaders/Widgets/ DESTINATION ${CURRENT_PACKAGES_DIR}/include) -file(COPY ${SOURCE_PATH}/CHeaders/Wrappers/ DESTINATION ${CURRENT_PACKAGES_DIR}/include) -file(COPY ${SOURCE_PATH}/CHeaders/XPLM/ DESTINATION ${CURRENT_PACKAGES_DIR}/include) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) -# copy prebuilt libs -if(VCPKG_TARGET_IS_WINDOWS) - file(COPY ${SOURCE_PATH}/Libraries/Win/XPLM_64.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib/) - file(COPY ${SOURCE_PATH}/Libraries/Win/XPWidgets_64.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib/) - file(COPY ${SOURCE_PATH}/Libraries/Win/XPLM_64.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/) - file(COPY ${SOURCE_PATH}/Libraries/Win/XPWidgets_64.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/) -elseif (VCPKG_TARGET_IS_OSX) - file(COPY ${SOURCE_PATH}/Libraries/Mac/ DESTINATION ${CURRENT_PACKAGES_DIR}/lib/) - file(COPY ${SOURCE_PATH}/Libraries/Mac/ DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/) -endif() +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-x-plane) -# Handle copyright -file(INSTALL ${SOURCE_PATH}/license.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/license.txt") + +configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") diff --git a/ports/x-plane/unofficial-x-plane-config.cmake.in b/ports/x-plane/unofficial-x-plane-config.cmake.in new file mode 100644 index 0000000000..f4b7e77ed8 --- /dev/null +++ b/ports/x-plane/unofficial-x-plane-config.cmake.in @@ -0,0 +1,62 @@ +@PACKAGE_INIT@ + +get_filename_component(ROOT "${CMAKE_CURRENT_LIST_DIR}" PATH) +get_filename_component(ROOT "${ROOT}" PATH) + +if(NOT TARGET unofficial::x-plane::xplm) + if(WIN32 OR APPLE) + add_library(unofficial::x-plane::xplm SHARED IMPORTED) + if(WIN32) + set_target_properties( + unofficial::x-plane::xplm + PROPERTIES IMPORTED_IMPLIB "${ROOT}/lib/x-plane/XPLM_64.lib") + set_target_properties( + unofficial::x-plane::xplm PROPERTIES INTERFACE_COMPILE_DEFINITIONS + "-DIBM=1;-DAPL=0;-DLIN=0") + else() + set_target_properties( + unofficial::x-plane::xplm + PROPERTIES IMPORTED_LOCATION "${ROOT}/lib/x-plane/XPLM.framework/XPLM") + set_target_properties( + unofficial::x-plane::xplm PROPERTIES INTERFACE_COMPILE_DEFINITIONS + "-DIBM=0;-DAPL=1;-DLIN=0") + endif() + else() + add_library(unofficial::x-plane::xplm INTERFACE IMPORTED) + set_target_properties( + unofficial::x-plane::xplm PROPERTIES INTERFACE_COMPILE_DEFINITIONS + "-DIBM=0;-DAPL=0;-DLIN=1") + endif() + set_target_properties( + unofficial::x-plane::xplm PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${ROOT}/include") +endif() + +if(NOT TARGET unofficial::x-plane::xpwidgets) + if(WIN32 OR APPLE) + add_library(unofficial::x-plane::xpwidgets SHARED IMPORTED) + if(WIN32) + set_target_properties( + unofficial::x-plane::xpwidgets + PROPERTIES IMPORTED_IMPLIB "${ROOT}/lib/x-plane/XPWidgets_64.lib") + else() + set_target_properties( + unofficial::x-plane::xpwidgets + PROPERTIES IMPORTED_LOCATION + "${ROOT}/lib/x-plane/XPWidgets.framework/XPWidgets") + endif() + else() + add_library(unofficial::x-plane::xpwidgets INTERFACE IMPORTED) + endif() + set_target_properties( + unofficial::x-plane::xpwidgets PROPERTIES INTERFACE_LINK_LIBRARIES + "unofficial::x-plane::xplm") + set_target_properties( + unofficial::x-plane::xpwidgets + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${ROOT}/include") +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-x-plane-targets.cmake") + +check_required_components(unofficial-x-plane) diff --git a/ports/x-plane/usage b/ports/x-plane/usage new file mode 100644 index 0000000000..de07716df2 --- /dev/null +++ b/ports/x-plane/usage @@ -0,0 +1,4 @@ +x-plane provides CMake targets: + + find_package(unofficial-x-plane CONFIG REQUIRED) + target_link_libraries(main PRIVATE unofficial::x-plane::xplm unofficial::x-plane::xpwidgets unofficial::x-plane::xplm_cpp) diff --git a/ports/x-plane/vcpkg.json b/ports/x-plane/vcpkg.json index 156986edd8..9dbb8e9e98 100644 --- a/ports/x-plane/vcpkg.json +++ b/ports/x-plane/vcpkg.json @@ -1,8 +1,18 @@ { "name": "x-plane", - "version": "3.0.3", - "port-version": 2, + "version": "4.0.1", "description": "The X-Plane Plugin SDK", "homepage": "https://developer.x-plane.com/sdk/", - "supports": "!(x86 | arm | wasm32)" + "license": null, + "supports": "(windows & !uwp & x64) | (osx & (x64 | arm64)) | (linux & x64)", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] } diff --git a/versions/baseline.json b/versions/baseline.json index ee50342808..332897d665 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -9141,8 +9141,8 @@ "port-version": 0 }, "x-plane": { - "baseline": "3.0.3", - "port-version": 2 + "baseline": "4.0.1", + "port-version": 0 }, "x264": { "baseline": "0.164.3107", diff --git a/versions/x-/x-plane.json b/versions/x-/x-plane.json index 62e2c66012..572bc3d789 100644 --- a/versions/x-/x-plane.json +++ b/versions/x-/x-plane.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "be6ff276d2a18e64a2cf91a50ef1a53d26a33fa8", + "version": "4.0.1", + "port-version": 0 + }, { "git-tree": "4f081103e3e99e2d77b5b3124824ad6f0d7410fc", "version": "3.0.3",