Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ ethos-u-scratch/
executorch.egg-info
pip-out/

# Dynamically fetched third-party libraries
third-party/gflags

# Any exported models and profiling outputs
*.bin
*.model
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
[submodule "third-party/flatcc"]
path = third-party/flatcc
url = https://github.com/dvidelabs/flatcc.git
[submodule "third-party/gflags"]
path = third-party/gflags
url = https://github.com/gflags/gflags.git
[submodule "third-party/googletest"]
path = third-party/googletest
url = https://github.com/google/googletest.git
Expand Down
10 changes: 2 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ project(executorch)

include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)
include(${PROJECT_SOURCE_DIR}/tools/cmake/Utils.cmake)
include(${PROJECT_SOURCE_DIR}/tools/cmake/EXECUTORCH_FetchContent_Destination.cmake)
include(CMakeDependentOption)
include(ExternalProject)
include(FetchContent)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -456,14 +458,6 @@ endif()

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/configurations)

#
# gflags: Commandline flag host library.
#

if(EXECUTORCH_BUILD_GFLAGS)
add_subdirectory(third-party/gflags)
endif()

# Install `executorch` library as well as `executorch-config.cmake` under
# ${CMAKE_INSTALL_PREFIX}/
install(
Expand Down
3 changes: 1 addition & 2 deletions backends/apple/coreml/scripts/build_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ cmake "$EXECUTORCH_ROOT_PATH" -B"$CMAKE_EXECUTORCH_BUILD_DIR_PATH" \
-DPLATFORM=MAC_UNIVERSAL \
-DDEPLOYMENT_TARGET=13.0 \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DEXECUTORCH_BUILD_XNNPACK=OFF \
-DEXECUTORCH_BUILD_GFLAGS=OFF
-DEXECUTORCH_BUILD_XNNPACK=OFF

cmake --build "$CMAKE_EXECUTORCH_BUILD_DIR_PATH" -j9 -t executorch

Expand Down
1 change: 0 additions & 1 deletion backends/cadence/build_cadence_fusionG3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ if $STEPWISE_BUILD; then
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
-DPYTHON_EXECUTABLE=python3 \
-DEXECUTORCH_FUSION_G3_OPT=ON \
-DEXECUTORCH_BUILD_GFLAGS=ON \
-DHAVE_FNMATCH_H=OFF \
-Bcmake-out/backends/cadence \
backends/cadence
Expand Down
1 change: 0 additions & 1 deletion backends/cadence/build_cadence_hifi4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ if $STEPWISE_BUILD; then
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
-DPYTHON_EXECUTABLE=python3 \
-DEXECUTORCH_NNLIB_OPT=ON \
-DEXECUTORCH_BUILD_GFLAGS=ON \
-DHAVE_FNMATCH_H=OFF \
-Bcmake-out/backends/cadence \
backends/cadence
Expand Down
2 changes: 1 addition & 1 deletion examples/models/llama/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ set(_common_include_directories ${EXECUTORCH_ROOT}/..)

# For some reason android build is not able to find where gflags is and hence
# cannot find corresponding .cmake file
set(gflags_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/gflags)
set(gflags_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../third-party/gflags/gflags-build)
find_package(gflags REQUIRED)

#
Expand Down
2 changes: 1 addition & 1 deletion examples/models/llava/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ set(_common_include_directories ${EXECUTORCH_ROOT}/..)

# For some reason android build is not able to find where gflags is and hence
# cannot find corresponding .cmake file
set(gflags_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/gflags)
set(gflags_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/gflags/gflags-build)
find_package(gflags REQUIRED)

#
Expand Down
5 changes: 2 additions & 3 deletions examples/portable/custom_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC)
set(_common_include_directories ${EXECUTORCH_ROOT}/..)

find_package(executorch CONFIG REQUIRED)
find_package(
gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party
)
set(gflags_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../third-party/gflags/gflags-build)
find_package(gflags REQUIRED)

target_include_directories(executorch INTERFACE ${_common_include_directories})

Expand Down
2 changes: 2 additions & 0 deletions examples/qualcomm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ endif()
# etdump, bundled_program.
find_package(executorch CONFIG REQUIRED)
target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED)

set(gflags_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party/gflags/gflags-build)
find_package(gflags REQUIRED)

set(_common_compile_options -Wno-deprecated-declarations -fPIC)
Expand Down
5 changes: 2 additions & 3 deletions examples/selective_build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC)
set(_common_include_directories ${EXECUTORCH_ROOT}/..)

find_package(executorch CONFIG REQUIRED)
find_package(
gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party
)
set(gflags_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party/gflags/gflags-build)
find_package(gflags REQUIRED)

target_include_directories(executorch_core INTERFACE ${_common_include_directories})

Expand Down
9 changes: 9 additions & 0 deletions third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ if(BUILD_TESTING)
add_subdirectory(googletest)
endif()

EXECUTORCH_FetchContent_Destination("${CMAKE_CURRENT_SOURCE_DIR}/gflags")
FetchContent_Declare(
gflags
GIT_REPOSITORY https://github.com/gflags/gflags.git
GIT_TAG v2.2.2
)
set(GFLAGS_INTTYPES_FORMAT C99)
FetchContent_MakeAvailable(gflags)

# MARK: - flatbuffers

if(WIN32)
Expand Down
1 change: 0 additions & 1 deletion third-party/gflags
Submodule gflags deleted from a738fd
27 changes: 16 additions & 11 deletions third-party/gflags_defs.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# ------------------------------------------------------------------------------

# gflags is materialized during build time by cmake. See third-party/CMakeLists.txt.
def _path(relative_path):
return "gflags/gflags-src/{}".format(relative_path)

# Add native rules to configure source files
# Not tested for building on windows platforms
def gflags_sources(namespace = ["google", "gflags"]):
Expand All @@ -7,7 +12,7 @@ def gflags_sources(namespace = ["google", "gflags"]):
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.genrule(
name = "gflags_declare_h",
srcs = ["gflags/src/gflags_declare.h.in"],
srcs = [_path("src/gflags_declare.h.in")],
out = "gflags/gflags_declare.h",
cmd = (common_preamble + "awk '{ " +
"gsub(/@GFLAGS_NAMESPACE@/, \"" + namespace[0] + "\"); " +
Expand All @@ -22,7 +27,7 @@ def gflags_sources(namespace = ["google", "gflags"]):
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.genrule(
name = gflags_ns_h_file.replace(".", "_"),
srcs = ["gflags/src/gflags_ns.h.in"],
srcs = [_path("src/gflags_ns.h.in")],
out = "gflags/" + gflags_ns_h_file,
cmd = (common_preamble + "awk '{ " +
"gsub(/@ns@/, \"" + ns + "\"); " +
Expand All @@ -34,7 +39,7 @@ def gflags_sources(namespace = ["google", "gflags"]):
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.genrule(
name = "gflags_h",
srcs = ["gflags/src/gflags.h.in"],
srcs = [_path("src/gflags.h.in")],
out = "gflags/gflags.h",
cmd = (common_preamble + "awk '{ " +
"gsub(/@GFLAGS_ATTRIBUTE_UNUSED@/, \"\"); " +
Expand All @@ -45,15 +50,15 @@ def gflags_sources(namespace = ["google", "gflags"]):
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
native.genrule(
name = "gflags_completions_h",
srcs = ["gflags/src/gflags_completions.h.in"],
srcs = [_path("src/gflags_completions.h.in")],
out = "gflags/gflags_completions.h",
cmd = common_preamble + "awk '{ gsub(/@GFLAGS_NAMESPACE@/, \"" + namespace[0] + "\"); print; }' $SRCS > $OUT",
)
headers = {
"config.h": "gflags/src/config.h",
"mutex.h": "gflags/src/mutex.h",
"util.h": "gflags/src/util.h",
"windows_port.h": "gflags/src/windows_port.h",
"config.h": _path("src/config.h"),
"mutex.h": _path("src/mutex.h"),
"util.h": _path("src/util.h"),
"windows_port.h": _path("src/windows_port.h"),
}
exported_headers = {
"gflags/gflags.h": ":gflags_h",
Expand All @@ -62,9 +67,9 @@ def gflags_sources(namespace = ["google", "gflags"]):
}
exported_headers.update({"gflags/" + hdr: ":" + hdr.replace(".", "_") for hdr in gflags_ns_h_files})
srcs = [
"gflags/src/gflags.cc",
"gflags/src/gflags_completions.cc",
"gflags/src/gflags_reporting.cc",
_path("src/gflags.cc"),
_path("src/gflags_completions.cc"),
_path("src/gflags_reporting.cc"),
]
return [exported_headers, headers, srcs]

Expand Down
30 changes: 30 additions & 0 deletions tools/cmake/EXECUTORCH_FetchContent_Destination.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# Some third-party libraries need to be materialized in the source tree for
# buck. Unfortunately, FetchContent bakes in generator information in the
# fetched content. Thus, if the generator is changed, it causes build failures.
# So, if the generator has changed, then nuke the content.
function(_refresh_cache_if_necessary DIR)
set(_generator_stamp_file "${DIR}/.executorch_cmake_generator_stamp")
set(_current_generator "${CMAKE_GENERATOR}")

if(EXISTS "${_generator_stamp_file}")
file(READ "${_generator_stamp_file}" _previous_generator)
string(STRIP "${_previous_generator}" _previous_generator)
if(NOT _previous_generator STREQUAL _current_generator)
file(REMOVE_RECURSE ${DIR})
endif()
endif()

file(WRITE "${_generator_stamp_file}" "${_current_generator}")
endfunction()

# Declare the content to be fetched in a specific location.
macro(EXECUTORCH_FetchContent_Destination DIR)
_refresh_cache_if_necessary(${DIR})
set(FETCHCONTENT_BASE_DIR ${DIR})
endmacro()
5 changes: 0 additions & 5 deletions tools/cmake/preset/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,6 @@ define_overridable_option(
"Build the Cortex-M backend"
BOOL OFF
)
define_overridable_option(
EXECUTORCH_BUILD_GFLAGS
"Build the gflags library."
BOOL ON
)
define_overridable_option(
EXECUTORCH_COREML_BUILD_EXECUTOR_RUNNER
"Build CoreML executor runner."
Expand Down
Loading