Skip to content

Commit

Permalink
Fix jsi cmake include dirs (#207)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ryantrem authored and facebook-github-bot committed Apr 16, 2020
1 parent b2ccfac commit f5d00e5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ReactCommon/jsi/jsi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(jsi
jsi.cpp)

include_directories(..)
target_include_directories(jsi PUBLIC ..)


set(jsi_compile_flags "")
Expand Down

0 comments on commit f5d00e5

Please sign in to comment.