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:
74
74
75
75
76
76
# Get the key/value pair listed in a CMakeCache.txt file.
77
- @cache
78
77
def _list_cmake_cache (cache_path : str ) -> Dict [str , _CacheValue ]:
79
78
result = {}
80
79
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)
76
76
message (FATAL_ERROR "Invalid option (${NAME} ) value type '${VALUE_TYPE} ', must be either STRING or BOOL" )
77
77
endif ()
78
78
79
- if (DEFINED ${NAME} )
79
+ if (DEFINED ${NAME} AND NOT DEFINED CACHE {${NAME}} )
80
80
set (${NAME} ${${NAME}} CACHE ${VALUE_TYPE} ${DESCRIPTION} FORCE )
81
81
else ()
82
82
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):
201
201
# Setting the value after should not affect the cache.
202
202
self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "default value" , "STRING" )
203
203
204
- def test_define_overridable_option_cli_override_with_set_override (self ):
204
+ def test_define_overridable_option_override_existing_cache (self ):
205
205
_cmake_lists_txt = """
206
206
cmake_minimum_required(VERSION 3.24)
207
207
project(test_preset)
208
208
include(${PROJECT_SOURCE_DIR}/preset.cmake)
209
- set(EXECUTORCH_TEST_MESSAGE "set value")
210
209
add_subdirectory(example)
211
210
"""
212
211
_example_cmake_lists_txt = """
@@ -220,9 +219,11 @@ def test_define_overridable_option_cli_override_with_set_override(self):
220
219
},
221
220
}
222
221
)
222
+ self .run_cmake ()
223
+ self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "default value" , "STRING" )
224
+
223
225
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" )
226
227
227
228
def test_set_overridable_option_before (self ):
228
229
_cmake_lists_txt = """
You can’t perform that action at this time.
0 commit comments