Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions ports/tinyexpr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
6 changes: 6 additions & 0 deletions ports/tinyexpr/exports.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
EXPORTS
te_compile
te_eval
te_free
te_interp
te_print
16 changes: 16 additions & 0 deletions ports/tinyexpr/fix-issue-34.patch
Original file line number Diff line number Diff line change
@@ -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);

27 changes: 27 additions & 0 deletions ports/tinyexpr/portfile.cmake
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions ports/tinyexpr/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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"
}