Improve config lib.

This commit is contained in:
fancy 2023-10-26 08:03:52 -07:00
parent fac9558524
commit 3dc608da22
4 changed files with 38 additions and 5 deletions

View File

@ -63,4 +63,18 @@ add_custom_target(
# WORKING_DIRECTORY ${PROJECT_ROOT_PATH}/cmake-shell
# )
function(config_owner target)
get_target_property(source_files "${target}" SOURCES)
foreach(source_file ${source_files})
get_property(defs SOURCE "${source_file}"
PROPERTY COMPILE_DEFINITIONS)
get_filename_component(file_name "${source_file}" NAME)
list(APPEND defs "CONFIG_OWNER")
set_property(
SOURCE "${source_file}"
PROPERTY COMPILE_DEFINITIONS ${defs})
endforeach()
endfunction()
define_file_name(${TARGET_NAME})
config_owner(${TARGET_NAME})

13
utils/Config/config.cmake Normal file
View File

@ -0,0 +1,13 @@
function(config_owner target)
get_target_property(source_files "${target}" SOURCES)
foreach(source_file ${source_files})
get_property(defs SOURCE "${source_file}"
PROPERTY COMPILE_DEFINITIONS)
get_filename_component(file_name "${source_file}" NAME)
list(APPEND defs "CONFIG_OWNER")
set_property(
SOURCE "${source_file}"
PROPERTY COMPILE_DEFINITIONS ${defs})
endforeach()
endfunction()

View File

@ -18,6 +18,9 @@
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef CONFIG_OWNER
#error This is internal file, never include it.
#endif
const StatusCode CreateConfigCode(const long int code);
#ifdef __cplusplus

View File

@ -19,6 +19,9 @@
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef CONFIG_OWNER
#error This is internal file, never include it.
#endif
typedef struct config Config;
typedef struct config