@@ -223,3 +223,70 @@ def test_define_overridable_option_cli_override_with_set_override(self):
223223 self .run_cmake (cmake_args = ["-DEXECUTORCH_TEST_MESSAGE='cli value'" ])
224224 # If an option is set through cmake, it should NOT be overridable from the CLI.
225225 self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "set value" , "STRING" )
226+
227+ def test_set_overridable_option_before (self ):
228+ _cmake_lists_txt = """
229+ cmake_minimum_required(VERSION 3.24)
230+ project(test_preset)
231+ include(${PROJECT_SOURCE_DIR}/preset.cmake)
232+ set_overridable_option(EXECUTORCH_TEST_MESSAGE "from set_overridable_option")
233+ add_subdirectory(build)
234+ """
235+ _build_cmake_lists_txt = """
236+ define_overridable_option(EXECUTORCH_TEST_MESSAGE "test message" STRING "move fast")
237+ """
238+ self .create_workspace (
239+ {
240+ "CMakeLists.txt" : _cmake_lists_txt ,
241+ "build" : {
242+ "CMakeLists.txt" : _build_cmake_lists_txt ,
243+ },
244+ }
245+ )
246+ self .run_cmake ()
247+ self .assert_cmake_cache (
248+ "EXECUTORCH_TEST_MESSAGE" , "from set_overridable_option" , "STRING"
249+ )
250+
251+ def test_set_overridable_option_after (self ):
252+ _cmake_lists_txt = """
253+ cmake_minimum_required(VERSION 3.24)
254+ project(test_preset)
255+ include(${PROJECT_SOURCE_DIR}/preset.cmake)
256+ add_subdirectory(build)
257+ set_overridable_option(EXECUTORCH_TEST_MESSAGE "from set_overridable_option")
258+ """
259+ _build_cmake_lists_txt = """
260+ define_overridable_option(EXECUTORCH_TEST_MESSAGE "test message" STRING "move fast")
261+ """
262+ self .create_workspace (
263+ {
264+ "CMakeLists.txt" : _cmake_lists_txt ,
265+ "build" : {
266+ "CMakeLists.txt" : _build_cmake_lists_txt ,
267+ },
268+ }
269+ )
270+ self .run_cmake ()
271+ self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "move fast" , "STRING" )
272+
273+ def test_set_overridable_option_with_cli_override (self ):
274+ _cmake_lists_txt = """
275+ cmake_minimum_required(VERSION 3.24)
276+ project(test_preset)
277+ include(${PROJECT_SOURCE_DIR}/preset.cmake)
278+ add_subdirectory(build)
279+ """
280+ _build_cmake_lists_txt = """
281+ define_overridable_option(EXECUTORCH_TEST_MESSAGE "test message" STRING "move fast")
282+ """
283+ self .create_workspace (
284+ {
285+ "CMakeLists.txt" : _cmake_lists_txt ,
286+ "build" : {
287+ "CMakeLists.txt" : _build_cmake_lists_txt ,
288+ },
289+ }
290+ )
291+ self .run_cmake (cmake_args = ["-DEXECUTORCH_TEST_MESSAGE='from the cli'" ])
292+ self .assert_cmake_cache ("EXECUTORCH_TEST_MESSAGE" , "from the cli" , "STRING" )
0 commit comments