Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions apps/bare-expo/android/app/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)

set(PCH_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/pch.h")

set(_pch_owner_src "${CMAKE_CURRENT_BINARY_DIR}/appmodules_pch_owner.cpp")
file(WRITE "${_pch_owner_src}"
"// Generated by CMakeLists.txt. Translation unit exists solely so the\n"
"// owning target can produce a .pch binary that codegen targets reuse.\n")

add_library(appmodules_pch STATIC EXCLUDE_FROM_ALL "${_pch_owner_src}")

# Apply the exact same compile options codegen targets get from RN's
target_compile_reactnative_options(appmodules_pch PRIVATE)

# Link dependencies needed by our PCH header
foreach (_dep IN ITEMS common_flags reactnative jsi folly_runtime fbjni)
if (TARGET ${_dep})
target_link_libraries(appmodules_pch PRIVATE ${_dep})
endif ()
endforeach ()

target_precompile_headers(appmodules_pch PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:${PCH_HEADER}>"
)

function(add_pch_if_eligible target)
if (NOT TARGET ${target})
return()
Expand All @@ -21,9 +42,7 @@ function(add_pch_if_eligible target)
return()
endif ()

target_precompile_headers(${target} PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:${PCH_HEADER}>"
)
target_precompile_headers(${target} REUSE_FROM appmodules_pch)
endfunction()

if (DEFINED AUTOLINKED_LIBRARIES)
Expand Down
Loading
Loading