diff options
| author | myd7349 <myd7349@gmail.com> | 2020-10-09 15:41:42 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-09 00:41:42 -0700 |
| commit | df9c8e260e66713dcf768630cd434caf2c29bbff (patch) | |
| tree | d40ebc609bb9dfefe2332beb78f252e62734eeb2 /ports/tinyexpr | |
| parent | 95c0643813ad529c0fc1be8d66517b25ab131dd5 (diff) | |
| download | vcpkg-df9c8e260e66713dcf768630cd434caf2c29bbff.tar.gz vcpkg-df9c8e260e66713dcf768630cd434caf2c29bbff.zip | |
[tinyexpr] Add new port (#13729)
Diffstat (limited to 'ports/tinyexpr')
| -rw-r--r-- | ports/tinyexpr/CMakeLists.txt | 48 | ||||
| -rw-r--r-- | ports/tinyexpr/exports.def | 6 | ||||
| -rw-r--r-- | ports/tinyexpr/fix-issue-34.patch | 16 | ||||
| -rw-r--r-- | ports/tinyexpr/portfile.cmake | 27 | ||||
| -rw-r--r-- | ports/tinyexpr/vcpkg.json | 7 |
5 files changed, 104 insertions, 0 deletions
diff --git a/ports/tinyexpr/CMakeLists.txt b/ports/tinyexpr/CMakeLists.txt new file mode 100644 index 000000000..60f38348a --- /dev/null +++ b/ports/tinyexpr/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.14)
+
+project(tinyexpr LANGUAGES C)
+
+include(CheckSymbolExists)
+include(GNUInstallDirs)
+
+if(WIN32 AND BUILD_SHARED_LIBS)
+ add_library(tinyexpr tinyexpr.c exports.def)
+else()
+ add_library(tinyexpr tinyexpr.c)
+endif()
+
+target_include_directories(
+ tinyexpr
+ PUBLIC
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+
+# https://stackoverflow.com/questions/32816646/can-cmake-detect-if-i-need-to-link-to-libm-when-using-pow-in-c
+if(NOT POW_FUNCTION_EXISTS AND NOT NEED_LINKING_AGAINST_LIBM)
+ check_symbol_exists(pow "math.h" POW_FUNCTION_EXISTS)
+ if(NOT POW_FUNCTION_EXISTS)
+ unset(POW_FUNCTION_EXISTS CACHE)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES m)
+ check_symbol_exists(pow "math.h" POW_FUNCTION_EXISTS)
+ if(POW_FUNCTION_EXISTS)
+ set(NEED_LINKING_AGAINST_LIBM True CACHE BOOL "" FORCE)
+ else()
+ message(FATAL_ERROR "Failed making the pow() function available")
+ endif()
+ endif()
+endif()
+
+if(NEED_LINKING_AGAINST_LIBM)
+ target_link_libraries(tinyexpr PUBLIC m)
+endif()
+
+set_target_properties(tinyexpr PROPERTIES PUBLIC_HEADER tinyexpr.h)
+
+install(TARGETS tinyexpr EXPORT unofficial-tinyexpr-config)
+
+install(
+ EXPORT unofficial-tinyexpr-config
+ NAMESPACE unofficial::tinyexpr::
+ DESTINATION share/unofficial-tinyexpr
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+)
diff --git a/ports/tinyexpr/exports.def b/ports/tinyexpr/exports.def new file mode 100644 index 000000000..a43f437d2 --- /dev/null +++ b/ports/tinyexpr/exports.def @@ -0,0 +1,6 @@ +EXPORTS
+ te_compile
+ te_eval
+ te_free
+ te_interp
+ te_print
diff --git a/ports/tinyexpr/fix-issue-34.patch b/ports/tinyexpr/fix-issue-34.patch new file mode 100644 index 000000000..000fea053 --- /dev/null +++ b/ports/tinyexpr/fix-issue-34.patch @@ -0,0 +1,16 @@ +diff --git a/tinyexpr.c b/tinyexpr.c +index 90ed8fc..570f2fd 100755 +--- a/tinyexpr.c ++++ b/tinyexpr.c +@@ -49,6 +49,11 @@ For log = natural log uncomment the next line. */ + #define INFINITY (1.0/0.0) + #endif + ++/* https://github.com/codeplea/tinyexpr/issues/34 */ ++#ifdef _MSC_VER ++#pragma function(ceil) ++#pragma function(floor) ++#endif + + typedef double (*te_fun2)(double, double); + diff --git a/ports/tinyexpr/portfile.cmake b/ports/tinyexpr/portfile.cmake new file mode 100644 index 000000000..480c67a24 --- /dev/null +++ b/ports/tinyexpr/portfile.cmake @@ -0,0 +1,27 @@ +vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO codeplea/tinyexpr
+ REF ffb0d41b13e5f8d318db95feb071c220c134fe70
+ SHA512 fe4975f8b444a50d7ba8135450a42007a81f1545eebd7775f92307b87b72bc9abee4591e56ddeb76ec9e5aa41f0852ba98c99881d671f47a58caca8bd1ca9999
+ HEAD_REF master
+ PATCHES
+ fix-issue-34.patch
+)
+
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/exports.def DESTINATION ${SOURCE_PATH})
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+)
+
+vcpkg_install_cmake()
+
+vcpkg_copy_pdbs()
+
+vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-${PORT} TARGET_PATH share/unofficial-${PORT})
+
+file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
+
+file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
diff --git a/ports/tinyexpr/vcpkg.json b/ports/tinyexpr/vcpkg.json new file mode 100644 index 000000000..6ed72b483 --- /dev/null +++ b/ports/tinyexpr/vcpkg.json @@ -0,0 +1,7 @@ +{ + "name": "tinyexpr", + "version-string": "2020-09-25", + "description": "Tiny recursive descent parser and evaluation engine in C", + "homepage": "https://codeplea.com/tinyexpr", + "license": "Zlib" +} |
