Skip to content

CMakeLists.txt: Add FIREBASE_FLATC_CMAKE_COMMAND #1103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 19, 2022
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,20 @@ else()
set(ENV_COMMAND env -i PATH=${firebase_command_line_path})
endif()

# The cmake executable to use when compiling flatc. Normally, the default
# value (finding cmake in the PATH) is fine; however, in cases where cmake is
# *not* in the PATH (e.g. when building from CLion using the Android
# toolchain) it must be specified via via this cache variable.
set(FIREBASE_FLATC_CMAKE_COMMAND "cmake" CACHE FILEPATH
"The cmake command to use when compiling flatc.")

# Build flatc by invoking the cmake build, with only the flatc target.
file(MAKE_DIRECTORY ${firebase_external_flatc_build_dir})
add_custom_command(
OUTPUT ${firebase_external_flatc}
COMMAND cd ${firebase_external_flatc_build_dir} ${COMMAND_CONCAT}
${ENV_COMMAND} cmake ${FLATBUFFERS_SOURCE_DIR} ${COMMAND_CONCAT}
${ENV_COMMAND} cmake --build . --target flatc
${ENV_COMMAND} ${FIREBASE_FLATC_CMAKE_COMMAND} ${FLATBUFFERS_SOURCE_DIR} ${COMMAND_CONCAT}
${ENV_COMMAND} ${FIREBASE_FLATC_CMAKE_COMMAND} --build . --target flatc
COMMENT "Building flatc (the FlatBuffer schema compiler)")

# Add a target so that we can run the custom commands before the code build.
Expand Down