mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-30 21:39:45 -05:00
Make deps/exprtk dependency optional
This commit is contained in:
@@ -383,8 +383,18 @@ target_precompile_headers(${LIB_NAME} PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/lib/pch.hpp")
|
||||
|
||||
target_include_directories(
|
||||
${LIB_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/obs-websocket/lib"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/deps/exprtk")
|
||||
${LIB_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/obs-websocket/lib")
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/exprtk/exprtk.hpp")
|
||||
target_include_directories(${LIB_NAME}
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/exprtk")
|
||||
target_compile_definitions(${LIB_NAME} PRIVATE EXPRTK_SUPPORT=1)
|
||||
else()
|
||||
message(
|
||||
STATUS
|
||||
"${PROJECT_NAME}: deps/exprtk not found - math expression support disabled"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT nlohmann_json_DIR
|
||||
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/json/CMakeLists.txt")
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
#include "obs-module-helper.hpp"
|
||||
|
||||
#include <climits>
|
||||
#ifdef EXPRTK_SUPPORT
|
||||
#include <exprtk.hpp>
|
||||
#include <random>
|
||||
#endif
|
||||
|
||||
namespace advss {
|
||||
|
||||
std::variant<double, std::string> EvalMathExpression(const std::string &expr)
|
||||
{
|
||||
#ifdef EXPRTK_SUPPORT
|
||||
static auto randomFunc = []() {
|
||||
thread_local std::mt19937 gen(std::random_device{}());
|
||||
thread_local std::uniform_real_distribution<double> dis(0.0,
|
||||
@@ -26,6 +29,7 @@ std::variant<double, std::string> EvalMathExpression(const std::string &expr)
|
||||
if (parser.compile(expr, expression)) {
|
||||
return expression.value();
|
||||
}
|
||||
#endif
|
||||
return std::string(obs_module_text(
|
||||
"AdvSceneSwitcher.math.expressionFail")) +
|
||||
" \"" + expr + "\"";
|
||||
|
||||
@@ -85,8 +85,11 @@ target_sources(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE test-math.cpp ${ADVSS_SOURCE_DIR}/lib/utils/math-helpers.cpp
|
||||
${ADVSS_SOURCE_DIR}/lib/utils/obs-module-helper.cpp)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${ADVSS_SOURCE_DIR}/deps/exprtk)
|
||||
if(EXISTS "${ADVSS_SOURCE_DIR}/deps/exprtk/exprtk.hpp")
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${ADVSS_SOURCE_DIR}/deps/exprtk)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE EXPRTK_SUPPORT=1)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC /MP /d2FH4- /wd4267 /bigobj)
|
||||
|
||||
Reference in New Issue
Block a user