aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/tinyexpr
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/tinyexpr')
-rw-r--r--vcpkg/ports/tinyexpr/CMakeLists.txt48
-rw-r--r--vcpkg/ports/tinyexpr/exports.def6
-rw-r--r--vcpkg/ports/tinyexpr/fix-issue-34.patch16
-rw-r--r--vcpkg/ports/tinyexpr/portfile.cmake26
-rw-r--r--vcpkg/ports/tinyexpr/vcpkg.json18
5 files changed, 114 insertions, 0 deletions
diff --git a/vcpkg/ports/tinyexpr/CMakeLists.txt b/vcpkg/ports/tinyexpr/CMakeLists.txt
new file mode 100644
index 0000000..60f3834
--- /dev/null
+++ b/vcpkg/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/vcpkg/ports/tinyexpr/exports.def b/vcpkg/ports/tinyexpr/exports.def
new file mode 100644
index 0000000..a43f437
--- /dev/null
+++ b/vcpkg/ports/tinyexpr/exports.def
@@ -0,0 +1,6 @@
+EXPORTS
+ te_compile
+ te_eval
+ te_free
+ te_interp
+ te_print
diff --git a/vcpkg/ports/tinyexpr/fix-issue-34.patch b/vcpkg/ports/tinyexpr/fix-issue-34.patch
new file mode 100644
index 0000000..000fea0
--- /dev/null
+++ b/vcpkg/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/vcpkg/ports/tinyexpr/portfile.cmake b/vcpkg/ports/tinyexpr/portfile.cmake
new file mode 100644
index 0000000..968f1be
--- /dev/null
+++ b/vcpkg/ports/tinyexpr/portfile.cmake
@@ -0,0 +1,26 @@
+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_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+)
+
+vcpkg_cmake_install()
+
+vcpkg_copy_pdbs()
+
+vcpkg_cmake_config_fixup(PACKAGE_NAME 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/vcpkg/ports/tinyexpr/vcpkg.json b/vcpkg/ports/tinyexpr/vcpkg.json
new file mode 100644
index 0000000..7b55dfe
--- /dev/null
+++ b/vcpkg/ports/tinyexpr/vcpkg.json
@@ -0,0 +1,18 @@
+{
+ "name": "tinyexpr",
+ "version-date": "2020-09-25",
+ "port-version": 2,
+ "description": "Tiny recursive descent parser and evaluation engine in C",
+ "homepage": "https://codeplea.com/tinyexpr",
+ "license": "Zlib",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ]
+}