mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 10:21:07 +08:00
[WIP][cjson] Add new port (#6081)
* [cjson] Add new port * [cjson] Fix cmake targets path * [cjson] Bump version info
This commit is contained in:
parent
70e7124cc4
commit
dc42151505
6
ports/cjson/CONTROL
Normal file
6
ports/cjson/CONTROL
Normal file
@ -0,0 +1,6 @@
|
||||
Source: cjson
|
||||
Version: 1.7.10-1
|
||||
Description: Ultralightweight JSON parser in ANSI C
|
||||
|
||||
Feature: utils
|
||||
Description: Enable building the cJSON_Utils library
|
34
ports/cjson/fix-install-path.patch
Normal file
34
ports/cjson/fix-install-path.patch
Normal file
@ -0,0 +1,34 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 033a882..6e2b2e4 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -149,7 +149,13 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/library_config/libcjson.pc.in"
|
||||
|
||||
install(FILES cJSON.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/cjson")
|
||||
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcjson.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")
|
||||
-install(TARGETS "${CJSON_LIB}" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" EXPORT "${CJSON_LIB}")
|
||||
+install(TARGETS "${CJSON_LIB}"
|
||||
+ EXPORT "${CJSON_LIB}"
|
||||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
|
||||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
|
||||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
|
||||
+ INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
|
||||
+)
|
||||
if (BUILD_SHARED_AND_STATIC_LIBS)
|
||||
install(TARGETS "${CJSON_LIB}-static" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
endif()
|
||||
@@ -186,7 +192,13 @@ if(ENABLE_CJSON_UTILS)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/library_config/libcjson_utils.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libcjson_utils.pc" @ONLY)
|
||||
|
||||
- install(TARGETS "${CJSON_UTILS_LIB}" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" EXPORT "${CJSON_UTILS_LIB}")
|
||||
+ install(TARGETS "${CJSON_UTILS_LIB}"
|
||||
+ EXPORT "${CJSON_UTILS_LIB}"
|
||||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
|
||||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
|
||||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
|
||||
+ INCLUDES DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}"
|
||||
+ )
|
||||
if (BUILD_SHARED_AND_STATIC_LIBS)
|
||||
install(TARGETS "${CJSON_UTILS_LIB}-static" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
endif()
|
63
ports/cjson/portfile.cmake
Normal file
63
ports/cjson/portfile.cmake
Normal file
@ -0,0 +1,63 @@
|
||||
include(vcpkg_common_functions)
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO DaveGamble/cJSON
|
||||
REF v1.7.10
|
||||
SHA512 f8d7c9fe798b51ec3c69cabe4124d2f6372f0e6d282285e3ca951c58c971a9a520d87550530d750ff7f8055c0b6ff566f237b9af9eb345cf4f4fc4ff8c910740
|
||||
HEAD_REF master
|
||||
PATCHES
|
||||
fix-install-path.patch
|
||||
)
|
||||
|
||||
if("utils" IN_LIST FEATURES)
|
||||
set(ENABLE_CJSON_UTILS ON)
|
||||
else()
|
||||
set(ENABLE_CJSON_UTILS OFF)
|
||||
endif()
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ENABLE_PUBLIC_SYMBOLS)
|
||||
else()
|
||||
set(ENABLE_PUBLIC_SYMBOLS OFF)
|
||||
endif()
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DBUILD_SHARED_AND_STATIC_LIBS=OFF
|
||||
-DCJSON_OVERRIDE_BUILD_SHARED_LIBS=OFF
|
||||
-DENABLE_PUBLIC_SYMBOLS=${ENABLE_PUBLIC_SYMBOLS}
|
||||
-DENABLE_TARGET_EXPORT=ON # Export CMake config files
|
||||
-DENABLE_CJSON_UTILS=${ENABLE_CJSON_UTILS}
|
||||
-DENABLE_CJSON_TEST=OFF
|
||||
-DENABLE_FUZZING=OFF
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/cJSON)
|
||||
|
||||
file(REMOVE_RECURSE
|
||||
${CURRENT_PACKAGES_DIR}/debug/include
|
||||
${CURRENT_PACKAGES_DIR}/debug/share
|
||||
)
|
||||
|
||||
file(READ ${CURRENT_PACKAGES_DIR}/include/cjson/cJSON.h _contents)
|
||||
if(ENABLE_PUBLIC_SYMBOLS)
|
||||
string(REPLACE "defined(CJSON_HIDE_SYMBOLS)" "0 /* defined(CJSON_HIDE_SYMBOLS) */" _contents "${_contents}")
|
||||
string(REPLACE "defined(CJSON_EXPORT_SYMBOLS)" "0 /* defined(CJSON_EXPORT_SYMBOLS) */" _contents "${_contents}")
|
||||
string(REPLACE "defined(CJSON_IMPORT_SYMBOLS)" "1 /* defined(CJSON_IMPORT_SYMBOLS) */" _contents "${_contents}")
|
||||
else()
|
||||
string(REPLACE "defined(CJSON_HIDE_SYMBOLS)" "1 /* defined(CJSON_HIDE_SYMBOLS) */" _contents "${_contents}")
|
||||
endif()
|
||||
file(WRITE ${CURRENT_PACKAGES_DIR}/include/cjson/cJSON.h "${_contents}")
|
||||
|
||||
# Handle copyright
|
||||
configure_file(${SOURCE_PATH}/LICENSE ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)
|
||||
|
||||
# CMake integration test
|
||||
vcpkg_test_cmake(PACKAGE_NAME ${PORT})
|
Loading…
x
Reference in New Issue
Block a user