7
7
8
8
# MARK: - flatbuffers
9
9
10
+ if (WIN32 )
11
+ set (_executorch_external_project_additional_args )
12
+ else ()
13
+ # Always use Make to avoid needing to codesign flatc if the project is using Xcode.
14
+ set (_executorch_external_project_additional_args CMAKE_GENERATOR "Unix Makefiles" )
15
+ endif ()
16
+
10
17
# We use ExternalProject to build flatc from source to force it target the host.
11
18
# Otherwise, flatc will target the project's toolchain (i.e. iOS, or Android).
12
19
ExternalProject_Add (
13
20
flatbuffers_external_project
14
21
PREFIX ${CMAKE_CURRENT_BINARY_DIR} /flatbuffers_external_project
15
22
SOURCE_DIR ${PROJECT_SOURCE_DIR} /third-party/flatbuffers
16
- # Always use Make to avoid needing to codesign flatc if the project is using Xcode.
17
- CMAKE_GENERATOR "Unix Makefiles"
18
23
CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON
19
24
-DFLATBUFFERS_INSTALL=ON
20
25
-DFLATBUFFERS_BUILD_FLATHASH=OFF
@@ -35,7 +40,7 @@ add_dependencies(flatc flatbuffers_external_project)
35
40
if (WIN32 )
36
41
# flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release
37
42
# config, but from CMake's perspective the build type is always Debug.
38
- set_target_properties (flatc PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR} /$<CONFIG>/ bin/flatc.exe )
43
+ set_target_properties (flatc PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR} /bin/flatc.exe )
39
44
else ()
40
45
set_target_properties (flatc PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR} /bin/flatc )
41
46
endif ()
@@ -49,13 +54,22 @@ endif()
49
54
50
55
# MARK: - flatcc
51
56
57
+ if (WIN32 )
58
+ # For some reason, when configuring the external project during build
59
+ # CMAKE_C_SIMULATE_ID is set to MSVC, but CMAKE_CXX_SIMULATE_ID is not set.
60
+ # To make sure the external project is configured correctly, set it explicitly
61
+ # here.
62
+ set (_flatcc_extra_cmake_args -DCMAKE_CXX_SIMULATE_ID=MSVC )
63
+ else ()
64
+ set (_flatcc_extra_cmake_args )
65
+ endif ()
66
+
52
67
# Similar to flatbuffers, we want to build flatcc for the host. See inline comments
53
68
# in the flatbuffers ExternalProject_Add for more details.
54
69
ExternalProject_Add (
55
70
flatcc_external_project
56
71
PREFIX ${CMAKE_CURRENT_BINARY_DIR} /flatcc_external_project
57
72
SOURCE_DIR ${PROJECT_SOURCE_DIR} /third-party/flatcc
58
- CMAKE_GENERATOR "Unix Makefiles"
59
73
CMAKE_ARGS -DFLATCC_RTONLY=OFF
60
74
-DFLATCC_TEST=OFF
61
75
-DFLATCC_REFLECTION=OFF
@@ -66,13 +80,15 @@ ExternalProject_Add(
66
80
-DCMAKE_TOOLCHAIN_FILE=
67
81
$< $< AND:$< BOOL:${APPLE} > ,$< BOOL:$< FILTER:${PLATFORM} ,EXCLUDE,^MAC> > > :-DCMAKE_OSX_SYSROOT=>
68
82
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
83
+ ${_flatcc_extra_cmake_args}
69
84
BUILD_BYPRODUCTS <INSTALL_DIR>/bin/flatcc
85
+ {_executorch_external_project_additional_args}
70
86
)
71
87
ExternalProject_Get_Property (flatcc_external_project INSTALL_DIR )
72
88
add_executable (flatcc_cli IMPORTED GLOBAL )
73
89
add_dependencies (flatcc_cli flatcc_external_project )
74
90
if (WIN32 )
75
- set_target_properties (flatcc_cli PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR} /$<CONFIG>/ bin/flatcc.exe )
91
+ set_target_properties (flatcc_cli PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR} /bin/flatcc.exe )
76
92
else ()
77
93
set_target_properties (flatcc_cli PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR} /bin/flatcc )
78
94
endif ()
0 commit comments