|
12 | 12 | ExternalProject_Add(
|
13 | 13 | flatbuffers_external_project
|
14 | 14 | PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_external_project
|
15 |
| - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_external_project |
16 | 15 | SOURCE_DIR ${PROJECT_SOURCE_DIR}/third-party/flatbuffers
|
17 | 16 | # Always use Make to avoid needing to codesign flatc if the project is using Xcode.
|
18 | 17 | CMAKE_GENERATOR "Unix Makefiles"
|
19 | 18 | CMAKE_ARGS -DFLATBUFFERS_BUILD_FLATC=ON
|
20 |
| - -DFLATBUFFERS_INSTALL=OFF |
| 19 | + -DFLATBUFFERS_INSTALL=ON |
21 | 20 | -DFLATBUFFERS_BUILD_FLATHASH=OFF
|
22 | 21 | -DFLATBUFFERS_BUILD_FLATLIB=OFF
|
23 | 22 | -DFLATBUFFERS_BUILD_TESTS=OFF
|
| 23 | + -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> |
24 | 24 | -DCMAKE_CXX_FLAGS="-DFLATBUFFERS_MAX_ALIGNMENT=${EXECUTORCH_FLATBUFFERS_MAX_ALIGNMENT}"
|
25 | 25 | # Unset the toolchain to build for the host instead of the toolchain set for the project.
|
26 | 26 | -DCMAKE_TOOLCHAIN_FILE=
|
27 | 27 | # If building for iOS, "unset" these variables to rely on the host (macOS) defaults.
|
28 | 28 | $<$<AND:$<BOOL:${APPLE}>,$<BOOL:$<FILTER:${PLATFORM},EXCLUDE,^MAC>>>:-DCMAKE_OSX_SYSROOT=>
|
29 | 29 | -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
|
30 |
| - INSTALL_COMMAND "" |
31 |
| - BUILD_BYPRODUCTS <BINARY_DIR>/flatc |
| 30 | + BUILD_BYPRODUCTS <INSTALL_DIR>/bin/flatc |
32 | 31 | )
|
33 |
| -ExternalProject_Get_Property(flatbuffers_external_project BINARY_DIR) |
| 32 | +ExternalProject_Get_Property(flatbuffers_external_project INSTALL_DIR) |
34 | 33 | add_executable(flatc IMPORTED GLOBAL)
|
35 | 34 | add_dependencies(flatc flatbuffers_external_project)
|
36 | 35 | if(WIN32)
|
37 | 36 | # flatbuffers does not use CMAKE_BUILD_TYPE. Internally, the build forces Release
|
38 | 37 | # config, but from CMake's perspective the build type is always Debug.
|
39 |
| - set_target_properties(flatc PROPERTIES IMPORTED_LOCATION ${BINARY_DIR}/$<CONFIG>/flatc.exe) |
| 38 | + set_target_properties(flatc PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/$<CONFIG>/bin/flatc.exe) |
40 | 39 | else()
|
41 |
| - set_target_properties(flatc PROPERTIES IMPORTED_LOCATION ${BINARY_DIR}/flatc) |
| 40 | + set_target_properties(flatc PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/flatc) |
42 | 41 | endif()
|
43 | 42 |
|
44 | 43 | # TODO: re-enable once flatbuffers is added as a subdirectory.
|
@@ -73,7 +72,7 @@ ExternalProject_Get_Property(flatcc_external_project INSTALL_DIR)
|
73 | 72 | add_executable(flatcc_cli IMPORTED GLOBAL)
|
74 | 73 | add_dependencies(flatcc_cli flatcc_external_project)
|
75 | 74 | if(WIN32)
|
76 |
| - set_target_properties(flatcc_cli PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${CMAKE_BUILD_TYPE}/flatcc) |
| 75 | + set_target_properties(flatcc_cli PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/$<CONFIG>/bin/flatcc.exe) |
77 | 76 | else()
|
78 | 77 | set_target_properties(flatcc_cli PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/flatcc)
|
79 | 78 | endif()
|
|
0 commit comments