mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-11 16:29:00 +08:00
a68a14e7a0
Fixes https://github.com/microsoft/vcpkg/issues/34492 - [X] Changes comply with the [maintainer guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md). - [X] The name of the port matches an existing name for this component on https://repology.org/ if possible, and/or is strongly associated with that component on search engines. - [X] Optional dependencies are resolved in exactly one way. For example, if the component is built with CMake, all `find_package` calls are REQUIRED, are satisfied by `vcpkg.json`'s declared dependencies, or disabled with [CMAKE_DISABLE_FIND_PACKAGE_Xxx](https://cmake.org/cmake/help/latest/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.html). - [X] The versioning scheme in `vcpkg.json` matches what upstream says. - [X] The license declaration in `vcpkg.json` matches what upstream says. - [X] The installed as the "copyright" file matches what upstream says. - [X] The source code of the component installed comes from an authoritative source. - [X] The generated "usage text" is accurate. See [adding-usage](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/examples/adding-usage.md) for context. - [X] The version database is fixed by rerunning `./vcpkg x-add-version --all` and committing the result. - [X] Only one version is in the new port's versions file. - [X] Only one version is added to each modified port's versions file. Notes: - This library is static only, so it's only supported for the static triplets. - Unfortunately, godot-cpp is not yet installable, so I had to patch its cmake script. I have made a PR upstream: https://github.com/godotengine/godot-cpp/pull/1418 But in the meanwhile, I have created an unofficial export target `unofficial::godot::cpp`.
127 lines
4.5 KiB
Diff
127 lines
4.5 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index e715102..b000066 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -37,7 +37,7 @@
|
|
# Todo
|
|
# Test build for Windows, Mac and mingw.
|
|
|
|
-cmake_minimum_required(VERSION 3.12)
|
|
+cmake_minimum_required(VERSION 3.19)
|
|
project(godot-cpp LANGUAGES CXX)
|
|
|
|
option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node." ON)
|
|
@@ -65,9 +65,8 @@ if(NOT DEFINED BITS)
|
|
endif()
|
|
|
|
# Input from user for GDExtension interface header and the API JSON file
|
|
-set(GODOT_GDEXTENSION_DIR "gdextension" CACHE STRING "")
|
|
+set(GODOT_GDEXTENSION_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gdextension" CACHE STRING "")
|
|
set(GODOT_CUSTOM_API_FILE "" CACHE STRING "")
|
|
-
|
|
set(GODOT_GDEXTENSION_API_FILE "${GODOT_GDEXTENSION_DIR}/extension_api.json")
|
|
if (NOT "${GODOT_CUSTOM_API_FILE}" STREQUAL "") # User-defined override.
|
|
set(GODOT_GDEXTENSION_API_FILE "${GODOT_CUSTOM_API_FILE}")
|
|
@@ -85,9 +84,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
|
set(GODOT_COMPILE_FLAGS "/utf-8") # /GF /MP
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
- set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MDd") # /Od /RTC1 /Zi
|
|
+ set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /Od") # /Od /RTC1 /Zi
|
|
else()
|
|
- set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MD /O2") # /Oy /GL /Gy
|
|
+ set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /O2") # /Oy /GL /Gy
|
|
STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
|
endif(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
@@ -117,7 +116,6 @@ else()
|
|
endif()
|
|
|
|
# Generate source from the bindings file
|
|
-find_package(Python3 3.4 REQUIRED) # pathlib should be present
|
|
if(GENERATE_TEMPLATE_GET_NODE)
|
|
set(GENERATE_BINDING_PARAMETERS "True")
|
|
else()
|
|
@@ -183,9 +181,10 @@ if (GODOT_CPP_SYSTEM_HEADERS)
|
|
endif ()
|
|
|
|
target_include_directories(${PROJECT_NAME} ${GODOT_CPP_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC
|
|
- include
|
|
- ${CMAKE_CURRENT_BINARY_DIR}/gen/include
|
|
- ${GODOT_GDEXTENSION_DIR}
|
|
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/gen/include>
|
|
+ $<BUILD_INTERFACE:${GODOT_GDEXTENSION_DIR}>
|
|
+ $<INSTALL_INTERFACE:include>
|
|
)
|
|
|
|
# Add the compile flags
|
|
@@ -213,4 +212,8 @@ set_target_properties(${PROJECT_NAME}
|
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
|
|
OUTPUT_NAME "${OUTPUT_NAME}"
|
|
+ EXPORT_NAME "cpp"
|
|
)
|
|
+
|
|
+
|
|
+include("cmake/install.cmake")
|
|
diff --git a/cmake/config.cmake b/cmake/config.cmake
|
|
new file mode 100644
|
|
index 0000000..bcddb3c
|
|
--- /dev/null
|
|
+++ b/cmake/config.cmake
|
|
@@ -0,0 +1 @@
|
|
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-godot-cpp-target.cmake")
|
|
diff --git a/cmake/install.cmake b/cmake/install.cmake
|
|
new file mode 100644
|
|
index 0000000..f48ab5c
|
|
--- /dev/null
|
|
+++ b/cmake/install.cmake
|
|
@@ -0,0 +1,46 @@
|
|
+
|
|
+include("CMakePackageConfigHelpers")
|
|
+include("GNUInstallDirs")
|
|
+
|
|
+install(TARGETS "godot-cpp"
|
|
+ EXPORT "unofficial-godot-cpp-target"
|
|
+ ARCHIVE
|
|
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
+)
|
|
+install(
|
|
+ DIRECTORY
|
|
+ "${CMAKE_CURRENT_SOURCE_DIR}/include/"
|
|
+ "${CMAKE_CURRENT_BINARY_DIR}/gen/include/"
|
|
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
+)
|
|
+
|
|
+install(FILES "${GODOT_GDEXTENSION_DIR}/gdextension_interface.h"
|
|
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
+)
|
|
+install(FILES "${GODOT_GDEXTENSION_API_FILE}"
|
|
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/godot-cpp"
|
|
+)
|
|
+
|
|
+install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake"
|
|
+ RENAME "unofficial-godot-cpp-config.cmake"
|
|
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-godot-cpp"
|
|
+)
|
|
+install(EXPORT "unofficial-godot-cpp-target"
|
|
+ NAMESPACE "unofficial::godot::"
|
|
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-godot-cpp"
|
|
+)
|
|
+
|
|
+file(READ "${GODOT_GDEXTENSION_API_FILE}" GODOT_GDEXTENSION_API_JSON)
|
|
+string(JSON GODOT_API_VERSION_MAJOR GET "${GODOT_GDEXTENSION_API_JSON}" "header" "version_major")
|
|
+string(JSON GODOT_API_VERSION_MINOR GET "${GODOT_GDEXTENSION_API_JSON}" "header" "version_minor")
|
|
+string(JSON GODOT_API_VERSION_PATCH GET "${GODOT_GDEXTENSION_API_JSON}" "header" "version_patch")
|
|
+set(GODOT_API_VERSION "${GODOT_API_VERSION_MAJOR}.${GODOT_API_VERSION_MINOR}.${GODOT_API_VERSION_PATCH}")
|
|
+unset(GODOT_GDEXTENSION_API_JSON)
|
|
+
|
|
+write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-godot-cpp-config-version.cmake"
|
|
+ VERSION "${GODOT_API_VERSION}"
|
|
+ COMPATIBILITY SameMinorVersion
|
|
+)
|
|
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-godot-cpp-config-version.cmake"
|
|
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-godot-cpp"
|
|
+)
|