@@ -12,7 +12,7 @@ include(FetchContent)
1212# buck. Unfortunately, FetchContent bakes in generator information in the
1313# fetched content. Thus, if the generator is changed, it causes build failures.
1414# So, if the generator has changed, then nuke the content.
15- function (_refresh_cache_if_necessary DIR)
15+ function (_invalidate_cache_if_generator_mismatch DIR)
1616 set (_generator_stamp_file "${DIR} /.executorch_cmake_generator_stamp" )
1717 set (_current_generator "${CMAKE_GENERATOR} " )
1818
@@ -24,13 +24,17 @@ function(_refresh_cache_if_necessary DIR)
2424 endif ()
2525 endif ()
2626
27- file (WRITE "${_generator_stamp_file} " "${_current_generator} " )
2827endfunction ()
2928
29+ # Fetch gflags, and make a symlink to third-party/gflags in the source tree.
30+ # Doing this to satisfy BUCK query for gflags. Also try to invalidate the cmake
31+ # cache if the generator has changed. Notice that symlink won't be created again
32+ # if it's already there.
3033function (FetchContent_gflags)
31- if (NOT ${gflags_SOURCE_DIR} STREQUAL "" )
32- _refresh_cache_if_necessary(${gflags_SOURCE_DIR} )
33- endif ()
34+ # set(_symlink_target ${CMAKE_CURRENT_LIST_DIR}/../../third-party/gflags)
35+ # if(IS_DIRECTORY ${_symlink_target})
36+ # _invalidate_cache_if_generator_mismatch(${_symlink_target})
37+ # endif()
3438
3539 FetchContent_Declare(
3640 gflags
@@ -39,4 +43,12 @@ function(FetchContent_gflags)
3943 )
4044 set (GFLAGS_INTTYPES_FORMAT C99)
4145 FetchContent_MakeAvailable(gflags)
46+
47+ # if(NOT IS_DIRECTORY ${_symlink_target})
48+ # message(STATUS "Creating a symlink from ${gflags_SOURCE_DIR} to third-party/gflags")
49+ # execute_process(
50+ # COMMAND ${CMAKE_COMMAND} -E create_symlink "${gflags_SOURCE_DIR}" "${_symlink_target}"
51+ # )
52+ # file(WRITE "${_symlink_target}/.executorch_cmake_generator_stamp" "${CMAKE_GENERATOR}")
53+ # endif()
4254endfunction ()
0 commit comments