@@ -460,7 +460,7 @@ endif()
460460# tools like `flatc`, along with example executables like `executor_runner` and
461461# libraries that it uses, like `gflags`. Disabling this can be helpful when
462462# cross-compiling, but some required tools that would have been built need to be
463- # provided directly (via, for example, FLATC_EXECUTABLE) .
463+ # provided directly.
464464cmake_dependent_option(
465465 EXECUTORCH_BUILD_HOST_TARGETS "Build host-only targets." ON
466466 "NOT CMAKE_TOOLCHAIN_IOS" OFF
@@ -471,10 +471,9 @@ cmake_dependent_option(
471471#
472472cmake_dependent_option(
473473 EXECUTORCH_BUILD_FLATC "Build the flatc executable." ON
474- "NOT FLATC_EXECUTABLE;EXECUTORCH_BUILD_HOST_TARGETS " OFF
474+ "NOT FLATC_EXECUTABLE" OFF
475475)
476476
477-
478477set (FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "" )
479478set (FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "" )
480479set (FLATBUFFERS_BUILD_FLATLIB OFF CACHE BOOL "" )
@@ -507,6 +506,8 @@ if(EXECUTORCH_BUILD_FLATC)
507506 -DFLATBUFFERS_BUILD_TESTS=${FLATBUFFERS_BUILD_TESTS}
508507 -DFLATBUFFERS_INSTALL=${FLATBUFFERS_INSTALL}
509508 -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${FLATBUFFERS_MAX_ALIGNMENT} "
509+ # If building for iOS, "unset" these variables to rely on the host (macOS) defaults.
510+ $<$<AND :$<BOOL :${CMAKE_TOOLCHAIN_IOS} >,$<BOOL :$<FILTER :${PLATFORM} ,EXCLUDE ,^MAC>>>:-DCMAKE_OSX_SYSROOT=>
510511 INSTALL_COMMAND ""
511512 BUILD_BYPRODUCTS <BINARY_DIR>/flatc
512513 )
@@ -515,6 +516,8 @@ if(EXECUTORCH_BUILD_FLATC)
515516 # flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release
516517 # config, but from CMake's perspective the build type is always Debug.
517518 set (FLATC_EXECUTABLE ${BINARY_DIR} /$<CONFIG>/flatc.exe)
519+ elseif (CMAKE_GENERATOR STREQUAL "Xcode" )
520+ set (FLATC_EXECUTABLE ${BINARY_DIR} /$<CONFIG>/flatc)
518521 else ()
519522 set (FLATC_EXECUTABLE ${BINARY_DIR} /flatc)
520523 endif ()
@@ -528,12 +531,7 @@ if(NOT FLATC_EXECUTABLE)
528531 find_program (FLATC_EXECUTABLE flatc)
529532
530533 if (NOT FLATC_EXECUTABLE)
531- message (
532- FATAL_ERROR
533- "FLATC_EXECUTABLE must be set when EXECUTORCH_BUILD_FLATC is disabled. "
534- "Note that EXECUTORCH_BUILD_FLATC may be disabled implicitly when "
535- "cross-compiling or when EXECUTORCH_BUILD_HOST_TARGETS is disabled."
536- )
534+ message (FATAL_ERROR "FLATC_EXECUTABLE must be set when EXECUTORCH_BUILD_FLATC is disabled." )
537535 endif ()
538536endif ()
539537
0 commit comments