Skip to content

Commit f5d00e5

Browse files
ryantremfacebook-github-bot
authored andcommitted
Fix jsi cmake include dirs (#207)
Summary: I'm trying to use JSI for a React Native custom module. I saw these existing examples where the JSI API is used in the context of a CMakeLists.txt: https://github.com/terrysahaidak/host-object-test/blob/master/libs/android-jsi/test-jsi/src/main/cpp/CMakeLists.txt https://github.com/ericlewis/react-native-hostobject-demo/pull/4/files#diff-834320be1b4e4016bac27c05dcd17fb9 In both cases, they manually grab the include directories and jsi.cpp from node_modules/react-native, but I also saw that node_modules/react-native/ReactCommon/jsi/jsi already has a CMakeLists.txt that appears to be intended to provide a jsi static lib, so I tried to pull this into my own CMakeLists.txt like this: ``` add_subdirectory(${RN_DIR}/ReactCommon/jsi/jsi ${CMAKE_CURRENT_BINARY_DIR}/jsi) ... target_link_libraries(MyLib jsi) ``` Unfortunately when doing this, the consuming project still doesn't see the correct include directories. The change I'm proposing here is to use `target_include_directories` and declare that `..` is a public (to consumers) include directory for the library named `jsi`. With this change, you can do what I showed above to consume the jsi lib by just pulling in the CMakeLists.txt file into your own CMakeLists.txt file. Changelog: [General][Fixed] Fix jsi cmake include dirs Pull Request resolved: facebook/hermes#207 Reviewed By: willholen Differential Revision: D21074270 Pulled By: tmikov fbshipit-source-id: 7d9ec3255f57a16c0b2be489dffa4540727738a1
1 parent b2ccfac commit f5d00e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ReactCommon/jsi/jsi/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
99
add_library(jsi
1010
jsi.cpp)
1111

12-
include_directories(..)
12+
target_include_directories(jsi PUBLIC ..)
1313

1414

1515
set(jsi_compile_flags "")

0 commit comments

Comments
 (0)