aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2025-11-04 09:58:12 +0800
committerLi Jin <dragon-fly@qq.com>2025-11-04 09:58:12 +0800
commitb6423d2d81ca0867570bf8ff021c30205cb7fd57 (patch)
tree7ec78a12927812e55cc9946653e84345b965086b /CMakeLists.txt
parentaca747dffa1c185c6fc66af4834284e32225751f (diff)
downloadyuescript-b6423d2d81ca0867570bf8ff021c30205cb7fd57.tar.gz
yuescript-b6423d2d81ca0867570bf8ff021c30205cb7fd57.tar.bz2
yuescript-b6423d2d81ca0867570bf8ff021c30205cb7fd57.zip
Fixed build files for Termux.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt34
1 files changed, 31 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 613019e..2d155b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,7 @@ if (LUA_LIBRARIES MATCHES "LUA_LIBRARIES-NOTFOUND")
44 endif() 44 endif()
45else () 45else ()
46 message(STATUS "Lua: using information from luarocks") 46 message(STATUS "Lua: using information from luarocks")
47endif() 47endif()
48 48
49message(STATUS "Lua: " ${LUA}) 49message(STATUS "Lua: " ${LUA})
50message(STATUS "Lua include: " ${LUA_INCLUDE_DIR}) 50message(STATUS "Lua include: " ${LUA_INCLUDE_DIR})
@@ -54,6 +54,24 @@ enable_language(CXX)
54include_directories(src src/3rdParty ${LUA_INCLUDE_DIR}) 54include_directories(src src/3rdParty ${LUA_INCLUDE_DIR})
55add_definitions(-std=c++17 -O3 -fPIC) 55add_definitions(-std=c++17 -O3 -fPIC)
56 56
57# Detect Android Termux environment
58# Termux typically has ANDROID_ROOT environment variable set and PREFIX points to Termux directory
59set(IS_TERMUX FALSE)
60if (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()
73endif()
74
57if (APPLE) 75if (APPLE)
58 add_compile_options(-Wno-deprecated-declarations) 76 add_compile_options(-Wno-deprecated-declarations)
59endif () 77endif ()
@@ -70,6 +88,11 @@ set_target_properties(libyue PROPERTIES PREFIX "")
70set_target_properties(libyue PROPERTIES OUTPUT_NAME "yue") 88set_target_properties(libyue PROPERTIES OUTPUT_NAME "yue")
71target_link_libraries(libyue ${LUA_LIBRARIES}) 89target_link_libraries(libyue ${LUA_LIBRARIES})
72 90
91# Add YUE_NO_WATCHER macro for Termux environment
92if (IS_TERMUX)
93 target_compile_definitions(libyue PRIVATE YUE_NO_WATCHER)
94endif()
95
73add_executable(yue 96add_executable(yue
74 src/yuescript/ast.cpp 97 src/yuescript/ast.cpp
75 src/yuescript/parser.cpp 98 src/yuescript/parser.cpp
@@ -154,6 +177,11 @@ else ()
154 target_compile_options(yue PRIVATE -Wall -Wno-long-long -fPIC) 177 target_compile_options(yue PRIVATE -Wall -Wno-long-long -fPIC)
155endif() 178endif()
156 179
180# Add YUE_NO_WATCHER macro for Termux environment
181if (IS_TERMUX)
182 target_compile_definitions(yue PRIVATE YUE_NO_WATCHER)
183endif()
184
157if (${CMAKE_BUILD_TYPE} MATCHES "Debug") 185if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
158 target_compile_definitions(yue PRIVATE DEBUG) 186 target_compile_definitions(yue PRIVATE DEBUG)
159elseif (${CMAKE_BUILD_TYPE} MATCHES "Release") 187elseif (${CMAKE_BUILD_TYPE} MATCHES "Release")
@@ -169,9 +197,9 @@ elseif (NOT (${CMAKE_SYSTEM_NAME} MATCHES "Haiku") AND NOT WIN32)
169else () 197else ()
170 target_link_libraries(yue PRIVATE ${LUA_LIBRARIES}) 198 target_link_libraries(yue PRIVATE ${LUA_LIBRARIES})
171endif() 199endif()
172 200
173if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 201if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
174 target_link_options(yue PRIVATE -lstdc++fs -ldl) 202 target_link_options(yue PRIVATE -ldl)
175endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 203endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
176 204
177install(CODE "") 205install(CODE "")