[gainput] imporve cmake search gainput library (#11000)

* imporve cmake search gainput library.

* Update ports/gainput/install_as_cmake_package.patch

* Update ports/gainput/install_as_cmake_package.patch

* fix error

* add prefix "unofficial"

* [gainput] fix dynamic build generate static lib

* remove unimportant changes

* [gainput] update ci.baseline.txt

* [gainput] fix build error on osx

* [gainput] update portfile

* Reset osx related code

* [gainput] update build option

* [gainput] update build option.
This commit is contained in:
L 2020-05-08 14:45:18 +08:00 committed by GitHub
parent d374b34165
commit 6d3a3bc4aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 10 deletions

View File

@ -1,4 +1,4 @@
Source: gainput
Version: 1.0.0-2
Version: 1.0.0-3
Homepage: https://github.com/jkuhlmann/gainput
Description: Gainput is a multiplatform C++ input library, supporting mouse, keyboard and controllers

View File

@ -0,0 +1,69 @@
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 14d5e85..cb7232f 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -30,19 +30,27 @@ if (GAINPUT_BUILD_SHARED)
endif (GAINPUT_BUILD_SHARED)
if (GAINPUT_BUILD_STATIC)
- message(STATUS "..Building shared libraries (-DGAINPUT_BUILD_STATIC=OFF to disable)")
+ message(STATUS "..Building static libraries (-DGAINPUT_BUILD_STATIC=OFF to disable)")
add_library(gainputstatic STATIC ${sources} ${mmsources})
set_target_properties(gainputstatic PROPERTIES DEBUG_POSTFIX -d FOLDER gainput)
set(install_libs ${install_libs} gainputstatic)
endif (GAINPUT_BUILD_STATIC)
if(WIN32)
- target_link_libraries(gainput ${XINPUT} ws2_32)
- target_link_libraries(gainputstatic ${XINPUT} ws2_32)
+ if (GAINPUT_BUILD_SHARED)
+ target_link_libraries(gainput ${XINPUT} ws2_32)
+ endif(GAINPUT_BUILD_SHARED)
+ if(GAINPUT_BUILD_STATIC)
+ target_link_libraries(gainputstatic ${XINPUT} ws2_32)
+ endif(GAINPUT_BUILD_STATIC)
add_definitions(-DGAINPUT_LIB_DYNAMIC=1)
elseif(ANDROID)
- target_link_libraries(gainputstatic native_app_glue log android)
- target_link_libraries(gainput native_app_glue log android)
+ if (GAINPUT_BUILD_SHARED)
+ target_link_libraries(gainput native_app_glue log android)
+ endif(GAINPUT_BUILD_SHARED)
+ if(GAINPUT_BUILD_STATIC)
+ target_link_libraries(gainputstatic native_app_glue log android)
+ endif(GAINPUT_BUILD_STATIC)
elseif(APPLE)
find_library(FOUNDATION Foundation)
find_library(IOKIT IOKit)
@@ -65,6 +73,14 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
+foreach(t ${install_libs})
+ target_include_directories(
+ ${t}
+ INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include>
+ )
+endforeach()
+
install(
DIRECTORY "include/gainput"
DESTINATION "include"
@@ -73,7 +89,15 @@ install(
install(
TARGETS ${install_libs}
+ EXPORT unofficial-${PROJECT_NAME}-Targets
LIBRARY DESTINATION "${libdir}"
ARCHIVE DESTINATION "${libdir}"
RUNTIME DESTINATION "bin"
)
+
+install(
+ EXPORT unofficial-${PROJECT_NAME}-Targets
+ FILE unofficial-${PROJECT_NAME}Config.cmake
+ NAMESPACE unofficial::${PROJECT_NAME}::
+ DESTINATION share/unofficial-${PROJECT_NAME}
+)
\ No newline at end of file

View File

@ -6,26 +6,34 @@ vcpkg_from_github(
REF v1.0.0
SHA512 56fdc4c0613d7260861885b270ebe9e624e940175f41e3ac82516e2eb0d6d229e405fbcc2e54608e7d6751c1d8658b5b5e186153193badc6487274cb284a8cd6
HEAD_REF master
PATCHES
"install_as_cmake_package.patch"
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(GAINPUT_BUILD_SHARED OFF)
set(GAINPUT_BUILD_STATIC ON)
else()
set(GAINPUT_BUILD_SHARED ON)
set(GAINPUT_BUILD_STATIC OFF)
endif()
if(APPLE)
set(GAINPUT_BUILD_SHARED ON)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DGAINPUT_BUILD_SHARED=${GAINPUT_BUILD_SHARED}
-DGAINPUT_BUILD_STATIC=${GAINPUT_BUILD_STATIC}
-DGAINPUT_TESTS=OFF
-DGAINPUT_SAMPLES=OFF
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-gainput TARGET_PATH share/unofficial-gainput)
vcpkg_copy_pdbs()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/gainputstatic.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/gainputstatic.lib ${CURRENT_PACKAGES_DIR}/lib/gainput.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/gainputstaticd.lib ${CURRENT_PACKAGES_DIR}/debug/lib/gainputd.lib)
endif()
endif()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

View File

@ -504,7 +504,6 @@ g3log:x64-uwp=fail
gainput:arm-uwp=fail
gainput:x64-linux=fail
gainput:x64-uwp=fail
gainput:x64-windows-static=fail
gamma:x64-linux=fail
gamma:x64-osx=fail
gasol:arm64-windows=fail