mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 18:13:01 +08:00
Add libgo library packge (#3394)
* Add libgo library packge * [libgo] Fix Windows and adjust cmake usage information
This commit is contained in:
parent
e011ec2993
commit
68447ced17
3
ports/libgo/CONTROL
Normal file
3
ports/libgo/CONTROL
Normal file
@ -0,0 +1,3 @@
|
||||
Source: libgo
|
||||
Version: 2.7
|
||||
Description: The best stackful coroutine by c++11.
|
38
ports/libgo/cmake.patch
Normal file
38
ports/libgo/cmake.patch
Normal file
@ -0,0 +1,38 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 0d291e4..0f6cc38 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -158,7 +158,7 @@ if (UNIX)
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -fPIC -Wall -pthread ${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -pg ${CMAKE_CXX_FLAGS} -Werror")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-g -O3 ${CMAKE_CXX_FLAGS} -Werror")
|
||||
-else ()
|
||||
+elseif (NOT DISABLE_ADJUST_COMMAND_LINE_FLAGS)
|
||||
if (NOT DISABLE_DYNAMIC_LIB)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
|
||||
@@ -180,7 +180,7 @@ set(STATIC_T "libgo_static")
|
||||
add_library("${STATIC_T}" STATIC ${CO_SRC_LIST})
|
||||
set_target_properties("${STATIC_T}" PROPERTIES OUTPUT_NAME "${TARGET}")
|
||||
|
||||
-if (UNIX)
|
||||
+if (UNIX OR FORCE_UNIX_TARGETS)
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/libgo/main)
|
||||
|
||||
if (NOT DISABLE_DYNAMIC_LIB)
|
||||
@@ -201,9 +201,15 @@ if (UNIX)
|
||||
PATTERN "ctx_boost_coroutine" EXCLUDE
|
||||
PATTERN "ctx_ucontext" EXCLUDE
|
||||
PATTERN "*.h")
|
||||
+ if(UNIX)
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/libgo/linux/ DESTINATION "include/libgo" FILES_MATCHING PATTERN "*.h")
|
||||
+ else()
|
||||
+ install(DIRECTORY ${PROJECT_SOURCE_DIR}/libgo/windows/ DESTINATION "include/libgo" FILES_MATCHING PATTERN "*.h")
|
||||
+ endif()
|
||||
+ if(NOT DISABLE_SYSTEMWIDE)
|
||||
file(WRITE ${PROJECT_SOURCE_DIR}/tools/libgo.conf "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/tools/libgo.conf DESTINATION "/etc/ld.so.conf.d")
|
||||
+ endif()
|
||||
if (DEPEND_BOOST)
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/libgo/ctx_boost_coroutine/ DESTINATION "include/libgo/ctx_boost_coroutine" FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/libgo/ctx_boost_context/ DESTINATION "include/libgo/ctx_boost_context" FILES_MATCHING PATTERN "*.h")
|
25
ports/libgo/libgo-config.cmake
Normal file
25
ports/libgo/libgo-config.cmake
Normal file
@ -0,0 +1,25 @@
|
||||
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
if(NOT LIBGO_FIND_COMPONENTS)
|
||||
set(LIBGO_FIND_COMPONENTS libgo libgo)
|
||||
if(LIBGO_FIND_REQUIRED)
|
||||
set(LIBGO_FIND_REQUIRED_libgo TRUE)
|
||||
endif()
|
||||
|
||||
set(LIBGO_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
set(LIBGO_INCLUDE_DIRS ${_DIR}/../../include)
|
||||
set(LIBGO_LIBRARIES)
|
||||
if (EXISTS ${_DIR}/../../lib/liblibgo.a)
|
||||
list(APPEND LIBGO_LIBRARIES optimized ${_DIR}/../../lib/liblibgo.a)
|
||||
endif()
|
||||
if (EXISTS ${_DIR}/../../debug/lib/liblibgo.a)
|
||||
list(APPEND LIBGO_LIBRARIES debug ${_DIR}/../../debug/lib/liblibgo.a)
|
||||
endif()
|
||||
if (EXISTS ${_DIR}/../../lib/libgo.lib)
|
||||
list(APPEND LIBGO_LIBRARIES optimized ${_DIR}/../../lib/libgo.lib)
|
||||
endif()
|
||||
if (EXISTS ${_DIR}/../../debug/lib/libgo.lib)
|
||||
list(APPEND LIBGO_LIBRARIES debug ${_DIR}/../../debug/lib/libgo.lib)
|
||||
endif()
|
62
ports/libgo/portfile.cmake
Normal file
62
ports/libgo/portfile.cmake
Normal file
@ -0,0 +1,62 @@
|
||||
include(vcpkg_common_functions)
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
||||
message("libgo currently only supports static linkage")
|
||||
set(VCPKG_LIBRARY_LINKAGE static)
|
||||
endif()
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO yyzybb537/libgo
|
||||
REF v2.7
|
||||
SHA512 eb83b87cf06464be8fc9632b69c14fd6e0612bedbf5b2e04c0a9c178d554ece85e3673b4e6076d7d8801d308d5975f6347662f2c2c4682cc8583b3096cced574
|
||||
HEAD_REF master
|
||||
PATCHES ${CMAKE_CURRENT_LIST_DIR}/cmake.patch
|
||||
)
|
||||
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "https://github.com/XBased/xhook/archive/e18c450541892212ca4f11dc91fa269fabf9646f.tar.gz"
|
||||
FILENAME "xhook-e18c450541892212ca4f11dc91fa269fabf9646f.tar.gz"
|
||||
SHA512 1bcf320f50cff13d92013a9f0ab5c818c2b6b63e9c1ac18c5dd69189e448d7a848f1678389d8b2c08c65f907afb3909e743f6c593d9cfb21e2bb67d5c294a166
|
||||
)
|
||||
|
||||
file(REMOVE_RECURSE ${SOURCE_PATH}/third_party)
|
||||
|
||||
vcpkg_extract_source_archive(${ARCHIVE} ${SOURCE_PATH}/third_party)
|
||||
file(RENAME ${SOURCE_PATH}/third_party/xhook-e18c450541892212ca4f11dc91fa269fabf9646f ${SOURCE_PATH}/third_party/xhook)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DDISABLE_ADJUST_COMMAND_LINE_FLAGS=ON
|
||||
-DDISABLE_DYNAMIC_LIB=ON
|
||||
-DFORCE_UNIX_TARGETS=ON
|
||||
-DDISABLE_SYSTEMWIDE=ON
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
||||
# remove duplicated include files
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/libgo/disable_hook)
|
||||
|
||||
file(GLOB REL_MAIN ${CURRENT_PACKAGES_DIR}/lib/libgo_main.lib ${CURRENT_PACKAGES_DIR}/lib/liblibgo_main.a)
|
||||
if(REL_MAIN)
|
||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/lib/manual-link)
|
||||
file(COPY ${REL_MAIN} DESTINATION ${CURRENT_PACKAGES_DIR}/lib/manual-link)
|
||||
file(REMOVE ${REL_MAIN})
|
||||
endif()
|
||||
|
||||
file(GLOB DBG_MAIN ${CURRENT_PACKAGES_DIR}/debug/lib/libgo_main.lib ${CURRENT_PACKAGES_DIR}/debug/lib/liblibgo_main.a)
|
||||
if(DBG_MAIN)
|
||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link)
|
||||
file(COPY ${DBG_MAIN} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link)
|
||||
file(REMOVE ${DBG_MAIN})
|
||||
endif()
|
||||
|
||||
# Handle copyright
|
||||
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libgo RENAME copyright)
|
||||
file(INSTALL ${CURRENT_PORT_DIR}/libgo-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/libgo)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
|
5
ports/libgo/usage
Normal file
5
ports/libgo/usage
Normal file
@ -0,0 +1,5 @@
|
||||
The package libgo provides CMake integration:
|
||||
|
||||
find_package(libgo REQUIRED)
|
||||
target_include_directories(main PRIVATE ${LIBGO_INCLUDE_DIRS})
|
||||
target_link_libraries(main PRIVATE ${LIBGO_LIBRARIES})
|
Loading…
Reference in New Issue
Block a user