Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: Prevent QuickJS 'version' file from being included as header

esengine1468c69996e1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cbd425362..9386ff7fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -151,6 +151,7 @@ else()
src/esengine/scripting/ScriptValue.hpp
src/esengine/scripting/bindings/ECSBindings.hpp
)
+
endif()
add_library(esengine STATIC ${ESENGINE_SOURCES} ${ESENGINE_HEADERS})
@@ -166,6 +167,11 @@ target_include_directories(esengine
${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb
)
+# Add QuickJS include path only for native platform (PRIVATE to avoid polluting consumers)
+if(NOT ES_BUILD_WEB AND NOT ES_BUILD_WXGAME)
+ target_include_directories(esengine PRIVATE ${QUICKJS_INCLUDE_DIR})
+endif()
+
target_link_libraries(esengine PUBLIC glm)
# Platform-specific settings
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index ea1d7acb1..e326f7751 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -49,11 +49,14 @@ if(NOT ES_BUILD_WEB AND NOT ES_BUILD_WXGAME)
)
add_library(quickjs STATIC ${QUICKJS_SOURCES})
- # Expose QuickJS headers to consumers (esengine scripting module)
- # Note: We use PUBLIC here so that #include <quickjs.h> works in esengine
- target_include_directories(quickjs PUBLIC
+ # Use PRIVATE to avoid exposing quickjs internal files (like 'version' text file)
+ # which could be mistakenly included as headers by the compiler
+ # Consumers should link quickjs and add the include path themselves if needed
+ target_include_directories(quickjs PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/quickjs
)
+ # Provide a variable for consumers to add QuickJS include path
+ set(QUICKJS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/quickjs" PARENT_SCOPE)
# QuickJS specific settings
if(WIN32)