File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,6 @@ class _CacheValue:
7474
7575
7676# Get the key/value pair listed in a CMakeCache.txt file.
77- @cache
7877def _list_cmake_cache (cache_path : str ) -> Dict [str , _CacheValue ]:
7978 result = {}
8079 with open (cache_path , "r" ) as cache_file :
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ macro(define_overridable_option NAME DESCRIPTION VALUE_TYPE DEFAULT_VALUE)
7676 message (FATAL_ERROR "Invalid option (${NAME} ) value type '${VALUE_TYPE} ', must be either STRING or BOOL" )
7777 endif ()
7878
79- if (DEFINED ${NAME} )
79+ if (DEFINED ${NAME} AND NOT DEFINED CACHE { ${NAME} } )
8080 set (${NAME} ${${NAME} } CACHE ${VALUE_TYPE} ${DESCRIPTION} FORCE)
8181 else ()
8282 set (${NAME} ${DEFAULT_VALUE} CACHE ${VALUE_TYPE} ${DESCRIPTION} )
Original file line number Diff line number Diff line change @@ -201,12 +201,11 @@ def test_define_overridable_option_set_override_after_with_cache(self):
201201 # Setting the value after should not affect the cache.
202202 self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "default value" , "STRING" )
203203
204- def test_define_overridable_option_cli_override_with_set_override (self ):
204+ def test_define_overridable_option_override_existing_cache (self ):
205205 _cmake_lists_txt = """
206206 cmake_minimum_required(VERSION 3.24)
207207 project(test_preset)
208208 include(${PROJECT_SOURCE_DIR}/preset.cmake)
209- set(EXECUTORCH_TEST_MESSAGE "set value")
210209 add_subdirectory(example)
211210 """
212211 _example_cmake_lists_txt = """
@@ -220,9 +219,11 @@ def test_define_overridable_option_cli_override_with_set_override(self):
220219 },
221220 }
222221 )
222+ self .run_cmake ()
223+ self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "default value" , "STRING" )
224+
223225 self .run_cmake (cmake_args = ["-DEXECUTORCH_TEST_MESSAGE='cli value'" ])
224- # If an option is set through cmake, it should NOT be overridable from the CLI.
225- self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "set value" , "STRING" )
226+ self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "cli value" , "STRING" )
226227
227228 def test_set_overridable_option_before (self ):
228229 _cmake_lists_txt = """
You can’t perform that action at this time.
0 commit comments