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/CMakeLists.txt | |
| parent | 95c0643813ad529c0fc1be8d66517b25ab131dd5 (diff) | |
| download | vcpkg-df9c8e260e66713dcf768630cd434caf2c29bbff.tar.gz vcpkg-df9c8e260e66713dcf768630cd434caf2c29bbff.zip | |
[tinyexpr] Add new port (#13729)
Diffstat (limited to 'ports/tinyexpr/CMakeLists.txt')
| -rw-r--r-- | ports/tinyexpr/CMakeLists.txt | 48 |
1 files changed, 48 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
+)
|
