Merge pull request #21 from LonghronShen/master

Add CMake support and fix building issues for Visual C++ with CMake
master
Gordon Williams 5 years ago committed by GitHub
commit 779bf5c518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

3
.gitignore vendored

@ -0,0 +1,3 @@
.vscode/
build/
build.*/

@ -0,0 +1,45 @@
project (tiny-js)
cmake_minimum_required (VERSION 2.6)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Debug")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif(NOT CMAKE_BUILD_TYPE)
if (NOT WIN32)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall")
else()
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++14 support.")
endif()
endif(NOT WIN32)
FILE(GLOB TINY_JS_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/TinyJS.h
)
FILE(GLOB TINY_JS_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/TinyJS.cpp
${CMAKE_CURRENT_LIST_DIR}/TinyJS_Functions.cpp
${CMAKE_CURRENT_LIST_DIR}/TinyJS_MathFunctions.cpp
)
add_library(tiny-js STATIC ${TINY_JS_HEADER_FILES} ${TINY_JS_SOURCE_FILES})
ADD_EXECUTABLE(tiny-js-cli Script.cpp ${TINY_JS_SOURCE_FILES})
ADD_EXECUTABLE(tiny-js-tests run_tests.cpp ${TINY_JS_SOURCE_FILES})
add_custom_command(
TARGET tiny-js-tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/tests
${CMAKE_CURRENT_BINARY_DIR}/tests)

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Gordon Williams
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -188,7 +188,7 @@ void scMathSinh(CScriptVar *c, void *userdata) {
//Math.asinh(a) - returns trig. hyperbolic arcsine of given angle in radians
void scMathASinh(CScriptVar *c, void *userdata) {
scReturnDouble( asinh( scGetDouble("a") ) );
scReturnDouble( asinh( (long double)scGetDouble("a") ) );
}
//Math.cosh(a) - returns trig. hyperbolic cosine of given angle in radians
@ -198,7 +198,7 @@ void scMathCosh(CScriptVar *c, void *userdata) {
//Math.acosh(a) - returns trig. hyperbolic arccosine of given angle in radians
void scMathACosh(CScriptVar *c, void *userdata) {
scReturnDouble( acosh( scGetDouble("a") ) );
scReturnDouble( acosh( (long double)scGetDouble("a") ) );
}
//Math.tanh(a) - returns trig. hyperbolic tangent of given angle in radians

Loading…
Cancel
Save