@@ -114,24 +114,24 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
114114# Instead please use `find_package(executorch REQUIRED)` in the example
115115# directory and add a new executable in the example `CMakeLists.txt`.
116116
117+ # Store compile definitions to apply to core targets
118+ set (_executorch_core_compile_definitions)
119+
117120if (NOT EXECUTORCH_ENABLE_LOGGING)
118- # Avoid pulling in the logging strings, which can be large. Note that this
119- # will set the compiler flag for all targets in this directory, and for all
120- # subdirectories included after this point.
121- add_definitions (-DET_LOG_ENABLED=0)
121+ # Avoid pulling in the logging strings, which can be large.
122+ list (APPEND _executorch_core_compile_definitions ET_LOG_ENABLED=0)
122123endif ()
123124
124- add_definitions (-DET_MIN_LOG_LEVEL =${ET_MIN_LOG_LEVEL} )
125+ list ( APPEND _executorch_core_compile_definitions ET_MIN_LOG_LEVEL =${ET_MIN_LOG_LEVEL} )
125126
126127if (NOT EXECUTORCH_ENABLE_PROGRAM_VERIFICATION)
127128 # Avoid pulling in the flatbuffer data verification logic, which can add about
128- # 20kB. Note that this will set the compiler flag for all targets in this
129- # directory, and for all subdirectories included after this point.
130- add_definitions (-DET_ENABLE_PROGRAM_VERIFICATION=0)
129+ # 20kB.
130+ list (APPEND _executorch_core_compile_definitions ET_ENABLE_PROGRAM_VERIFICATION=0)
131131endif ()
132132
133133if (EXECUTORCH_ENABLE_EVENT_TRACER)
134- add_definitions (-DET_EVENT_TRACER_ENABLED )
134+ list ( APPEND _executorch_core_compile_definitions ET_EVENT_TRACER_ENABLED )
135135endif ()
136136
137137# -ffunction-sections -fdata-sections: breaks function and data into sections so
@@ -358,7 +358,10 @@ target_include_directories(
358358 executorch_core PUBLIC ${_common_include_directories}
359359)
360360target_compile_definitions (
361- executorch_core PUBLIC C10_USING_CUSTOM_GENERATED_MACROS
361+ executorch_core
362+ PUBLIC
363+ C10_USING_CUSTOM_GENERATED_MACROS
364+ ${_executorch_core_compile_definitions}
362365)
363366target_compile_options (executorch_core PUBLIC ${_common_compile_options} )
364367if (MAX_KERNEL_NUM)
@@ -401,7 +404,12 @@ endif()
401404add_library (executorch ${_executorch__srcs} )
402405target_link_libraries (executorch PRIVATE executorch_core)
403406target_include_directories (executorch PUBLIC ${_common_include_directories} )
404- target_compile_definitions (executorch PUBLIC C10_USING_CUSTOM_GENERATED_MACROS)
407+ target_compile_definitions (
408+ executorch
409+ PUBLIC
410+ C10_USING_CUSTOM_GENERATED_MACROS
411+ ${_executorch_core_compile_definitions}
412+ )
405413target_compile_options (executorch PUBLIC ${_common_compile_options} )
406414target_link_options_shared_lib(executorch)
407415
0 commit comments