@@ -44,7 +44,7 @@ if (LUA_LIBRARIES MATCHES "LUA_LIBRARIES-NOTFOUND")
4444 endif ()
4545else ()
4646 message (STATUS "Lua: using information from luarocks" )
47- endif ()
47+ endif ()
4848
4949message (STATUS "Lua: " ${LUA} )
5050message (STATUS "Lua include: " ${LUA_INCLUDE_DIR} )
@@ -54,6 +54,24 @@ enable_language(CXX)
5454include_directories (src src/3rdParty ${LUA_INCLUDE_DIR} )
5555add_definitions (-std=c++17 -O3 -fPIC )
5656
57+ # Detect Android Termux environment
58+ # Termux typically has ANDROID_ROOT environment variable set and PREFIX points to Termux directory
59+ set (IS_TERMUX FALSE )
60+ if (DEFINED ENV{ANDROID_ROOT})
61+ # Check if PREFIX environment variable points to Termux directory
62+ if (DEFINED ENV{PREFIX})
63+ if ("$ENV{PREFIX} " MATCHES "com.termux" )
64+ set (IS_TERMUX TRUE )
65+ message (STATUS "Detected Android Termux environment (via PREFIX: $ENV{PREFIX} )" )
66+ endif ()
67+ endif ()
68+ # Alternative check: verify if Termux installation path exists
69+ if (NOT IS_TERMUX AND EXISTS "/data/data/com.termux/files/usr" )
70+ set (IS_TERMUX TRUE )
71+ message (STATUS "Detected Android Termux environment (via filesystem check)" )
72+ endif ()
73+ endif ()
74+
5775if (APPLE )
5876 add_compile_options (-Wno-deprecated-declarations )
5977endif ()
@@ -70,6 +88,11 @@ set_target_properties(libyue PROPERTIES PREFIX "")
7088set_target_properties (libyue PROPERTIES OUTPUT_NAME "yue" )
7189target_link_libraries (libyue ${LUA_LIBRARIES} )
7290
91+ # Add YUE_NO_WATCHER macro for Termux environment
92+ if (IS_TERMUX)
93+ target_compile_definitions (libyue PRIVATE YUE_NO_WATCHER )
94+ endif ()
95+
7396add_executable (yue
7497 src/yuescript/ast.cpp
7598 src/yuescript/parser.cpp
@@ -154,6 +177,11 @@ else ()
154177 target_compile_options (yue PRIVATE -Wall -Wno-long-long -fPIC )
155178endif ()
156179
180+ # Add YUE_NO_WATCHER macro for Termux environment
181+ if (IS_TERMUX)
182+ target_compile_definitions (yue PRIVATE YUE_NO_WATCHER )
183+ endif ()
184+
157185if (${CMAKE_BUILD_TYPE} MATCHES "Debug" )
158186 target_compile_definitions (yue PRIVATE DEBUG )
159187elseif (${CMAKE_BUILD_TYPE} MATCHES "Release" )
@@ -169,9 +197,9 @@ elseif (NOT (${CMAKE_SYSTEM_NAME} MATCHES "Haiku") AND NOT WIN32)
169197else ()
170198 target_link_libraries (yue PRIVATE ${LUA_LIBRARIES} )
171199endif ()
172-
200+
173201if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
174- target_link_options (yue PRIVATE -lstdc++fs - ldl )
202+ target_link_options (yue PRIVATE -ldl )
175203endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
176204
177205install (CODE "" )
0 commit comments