@@ -460,7 +460,7 @@ endif()
460
460
# tools like `flatc`, along with example executables like `executor_runner` and
461
461
# libraries that it uses, like `gflags`. Disabling this can be helpful when
462
462
# 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.
464
464
cmake_dependent_option(
465
465
EXECUTORCH_BUILD_HOST_TARGETS "Build host-only targets." ON
466
466
"NOT CMAKE_TOOLCHAIN_IOS" OFF
@@ -471,10 +471,9 @@ cmake_dependent_option(
471
471
#
472
472
cmake_dependent_option(
473
473
EXECUTORCH_BUILD_FLATC "Build the flatc executable." ON
474
- "NOT FLATC_EXECUTABLE;EXECUTORCH_BUILD_HOST_TARGETS " OFF
474
+ "NOT FLATC_EXECUTABLE" OFF
475
475
)
476
476
477
-
478
477
set (FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "" )
479
478
set (FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "" )
480
479
set (FLATBUFFERS_BUILD_FLATLIB OFF CACHE BOOL "" )
@@ -498,15 +497,15 @@ if(EXECUTORCH_BUILD_FLATC)
498
497
include (ExternalProject)
499
498
ExternalProject_Add(
500
499
flatbuffers
501
- PREFIX ${CMAKE_CURRENT_BINARY_DIR} /third-party/flatbuffers
502
- BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} /third-party/flatbuffers
503
500
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /third-party/flatbuffers
504
501
CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON
505
502
-DFLATBUFFERS_BUILD_FLATHASH=${FLATBUFFERS_BUILD_FLATHASH}
506
503
-DFLATBUFFERS_BUILD_FLATLIB=${FLATBUFFERS_BUILD_FLATLIB}
507
504
-DFLATBUFFERS_BUILD_TESTS=${FLATBUFFERS_BUILD_TESTS}
508
505
-DFLATBUFFERS_INSTALL=${FLATBUFFERS_INSTALL}
509
506
-DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${FLATBUFFERS_MAX_ALIGNMENT} "
507
+ # If building for iOS, "unset" these variables to rely on the host (macOS) defaults.
508
+ $<$<AND :$<BOOL :${CMAKE_TOOLCHAIN_IOS} >,$<BOOL :$<FILTER :${PLATFORM} ,EXCLUDE ,^MAC>>>:-DCMAKE_OSX_SYSROOT=>
510
509
INSTALL_COMMAND ""
511
510
BUILD_BYPRODUCTS <BINARY_DIR>/flatc
512
511
)
@@ -515,6 +514,8 @@ if(EXECUTORCH_BUILD_FLATC)
515
514
# flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release
516
515
# config, but from CMake's perspective the build type is always Debug.
517
516
set (FLATC_EXECUTABLE ${BINARY_DIR} /$<CONFIG>/flatc.exe)
517
+ elseif (CMAKE_GENERATOR STREQUAL "Xcode" )
518
+ set (FLATC_EXECUTABLE ${BINARY_DIR} /$<CONFIG>/flatc)
518
519
else ()
519
520
set (FLATC_EXECUTABLE ${BINARY_DIR} /flatc)
520
521
endif ()
@@ -528,12 +529,7 @@ if(NOT FLATC_EXECUTABLE)
528
529
find_program (FLATC_EXECUTABLE flatc)
529
530
530
531
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
- )
532
+ message (FATAL_ERROR "FLATC_EXECUTABLE must be set when EXECUTORCH_BUILD_FLATC is disabled." )
537
533
endif ()
538
534
endif ()
539
535
0 commit comments