cmake: support services that are not based on cmake executable targets
This commit is contained in:
@@ -16,6 +16,7 @@ include(BSP)
|
|||||||
include(Arch)
|
include(Arch)
|
||||||
include(Msg-Interface)
|
include(Msg-Interface)
|
||||||
include(Templates)
|
include(Templates)
|
||||||
|
include(Service)
|
||||||
|
|
||||||
bsp_reset()
|
bsp_reset()
|
||||||
sysroot_reset()
|
sysroot_reset()
|
||||||
|
|||||||
+29
-5
@@ -115,19 +115,43 @@ function(bsp_add_service)
|
|||||||
|
|
||||||
get_property(bsp_targets GLOBAL PROPERTY bsp_target_list)
|
get_property(bsp_targets GLOBAL PROPERTY bsp_target_list)
|
||||||
get_property(cfg_file TARGET ${arg_NAME} PROPERTY service_cfg_path)
|
get_property(cfg_file TARGET ${arg_NAME} PROPERTY service_cfg_path)
|
||||||
|
get_property(file_list TARGET ${arg_NAME} PROPERTY service_file_list)
|
||||||
|
get_property(target_type TARGET ${arg_NAME} PROPERTY TYPE)
|
||||||
|
|
||||||
list(LENGTH bsp_targets nr_bsp_targets)
|
list(LENGTH bsp_targets nr_bsp_targets)
|
||||||
|
list(LENGTH file_list nr_service_files)
|
||||||
if (${nr_bsp_targets} GREATER 0)
|
if (${nr_bsp_targets} GREATER 0)
|
||||||
math(EXPR serialiser_index "${nr_bsp_targets}-1")
|
math(EXPR serialiser_index "${nr_bsp_targets}-1")
|
||||||
list(GET bsp_targets ${serialiser_index} serialiser)
|
list(GET bsp_targets ${serialiser_index} serialiser)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_custom_target(${bsp_target_name}
|
set(commands
|
||||||
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
|
|
||||||
add-binary ${bsp_manifest} ${target_name}
|
|
||||||
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>
|
|
||||||
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
|
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
|
||||||
add-binary ${bsp_manifest} ${target_name}-cfg
|
add-binary ${bsp_manifest} ${target_name}-cfg
|
||||||
${arg_SVC_DIR} ${cfg_file}
|
${arg_SVC_DIR} ${cfg_file})
|
||||||
|
|
||||||
|
if (target_type STREQUAL "EXECUTABLE")
|
||||||
|
set(commands ${commands}
|
||||||
|
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
|
||||||
|
add-binary ${bsp_manifest} ${target_name}
|
||||||
|
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (nr_service_files GREATER 0)
|
||||||
|
math(EXPR nr_service_files "${nr_service_files}-1")
|
||||||
|
foreach (i RANGE 0 ${nr_service_files} 2)
|
||||||
|
math(EXPR i2 "${i}+1")
|
||||||
|
list(GET file_list ${i} src_file)
|
||||||
|
list(GET file_list ${i2} dest_dir)
|
||||||
|
set(commands ${commands}
|
||||||
|
COMMAND ${Python_EXECUTABLE} ${bsp_tool}
|
||||||
|
add-binary ${bsp_manifest} ${target_name}-${i}
|
||||||
|
${dest_dir} ${src_file})
|
||||||
|
endforeach (i)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_custom_target(${bsp_target_name}
|
||||||
|
${commands}
|
||||||
COMMENT "Preparing bsp component: ${target_name}"
|
COMMENT "Preparing bsp component: ${target_name}"
|
||||||
DEPENDS ${target_name} ${serialiser})
|
DEPENDS ${target_name} ${serialiser})
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
function(rosetta_add_service)
|
||||||
|
set(options)
|
||||||
|
set(one_value_args NAME CFG_FILE)
|
||||||
|
set(multi_value_args SOURCES)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||||
|
"${options}"
|
||||||
|
"${one_value_args}"
|
||||||
|
"${multi_value_args}")
|
||||||
|
|
||||||
|
set(exec_name ${arg_NAME})
|
||||||
|
get_property(programs GLOBAL PROPERTY rosetta_program_list)
|
||||||
|
set_property(GLOBAL PROPERTY rosetta_program_list ${programs} ${exec_name})
|
||||||
|
|
||||||
|
message(STATUS "Building service ${exec_name}")
|
||||||
|
add_executable(${exec_name} ${arg_SOURCES})
|
||||||
|
|
||||||
|
set_target_properties(${exec_name} PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
service_cfg_path ${arg_CFG_FILE})
|
||||||
|
install(TARGETS ${exec_name}
|
||||||
|
DESTINATION ${arg_SYSROOT_PATH})
|
||||||
|
endfunction(rosetta_add_service)
|
||||||
|
|
||||||
|
function(rosetta_add_misc_service)
|
||||||
|
set(options)
|
||||||
|
set(one_value_args NAME CFG_FILE)
|
||||||
|
set(multi_value_args SOURCES)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||||
|
"${options}"
|
||||||
|
"${one_value_args}"
|
||||||
|
"${multi_value_args}")
|
||||||
|
|
||||||
|
message(STATUS "Building service ${arg_NAME}")
|
||||||
|
add_custom_target(${arg_NAME})
|
||||||
|
|
||||||
|
set_target_properties(${arg_NAME} PROPERTIES
|
||||||
|
service_cfg_path ${arg_CFG_FILE})
|
||||||
|
endfunction(rosetta_add_misc_service)
|
||||||
|
|
||||||
|
function(rosetta_service_add_file)
|
||||||
|
set(options)
|
||||||
|
set(one_value_args NAME SRC_FILE DEST_DIR)
|
||||||
|
set(multi_value_args)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||||
|
"${options}"
|
||||||
|
"${one_value_args}"
|
||||||
|
"${multi_value_args}")
|
||||||
|
|
||||||
|
get_property(file_list TARGET ${arg_NAME} PROPERTY service_file_list)
|
||||||
|
set(file_list ${file_list} ${arg_SRC_FILE} ${arg_DEST_DIR})
|
||||||
|
set_property(TARGET ${arg_NAME} PROPERTY service_file_list ${file_list})
|
||||||
|
endfunction(rosetta_service_add_file)
|
||||||
+30
-5
@@ -170,19 +170,44 @@ function(sysroot_add_service)
|
|||||||
|
|
||||||
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)
|
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)
|
||||||
get_property(cfg_file TARGET ${arg_NAME} PROPERTY service_cfg_path)
|
get_property(cfg_file TARGET ${arg_NAME} PROPERTY service_cfg_path)
|
||||||
|
get_property(file_list TARGET ${arg_NAME} PROPERTY service_file_list)
|
||||||
|
get_property(target_type TARGET ${arg_NAME} PROPERTY TYPE)
|
||||||
|
|
||||||
list(LENGTH sysroot_targets nr_sysroot_targets)
|
list(LENGTH sysroot_targets nr_sysroot_targets)
|
||||||
|
list(LENGTH file_list nr_service_files)
|
||||||
if (${nr_sysroot_targets} GREATER 0)
|
if (${nr_sysroot_targets} GREATER 0)
|
||||||
math(EXPR serialiser_index "${nr_sysroot_targets}-1")
|
math(EXPR serialiser_index "${nr_sysroot_targets}-1")
|
||||||
list(GET sysroot_targets ${serialiser_index} serialiser)
|
list(GET sysroot_targets ${serialiser_index} serialiser)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_custom_target(${sysroot_target_name}
|
set(commands
|
||||||
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
|
||||||
add-binary ${sysroot_manifest} ${target_name}
|
|
||||||
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>
|
|
||||||
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
||||||
add-binary ${sysroot_manifest} ${target_name}-cfg
|
add-binary ${sysroot_manifest} ${target_name}-cfg
|
||||||
${arg_SVC_DIR} ${cfg_file}
|
${arg_SVC_DIR} ${cfg_file})
|
||||||
|
|
||||||
|
if (target_type STREQUAL "EXECUTABLE")
|
||||||
|
set(commands ${commands}
|
||||||
|
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
||||||
|
add-binary ${sysroot_manifest} ${target_name}
|
||||||
|
${arg_BIN_DIR} $<TARGET_FILE:${target_name}>)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (nr_service_files GREATER 0)
|
||||||
|
math(EXPR nr_service_files "${nr_service_files}-1")
|
||||||
|
foreach (i RANGE 0 ${nr_service_files} 2)
|
||||||
|
math(EXPR i2 "${i}+1")
|
||||||
|
list(GET file_list ${i} src_file)
|
||||||
|
list(GET file_list ${i2} dest_dir)
|
||||||
|
|
||||||
|
set(commands ${commands}
|
||||||
|
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
||||||
|
add-binary ${sysroot_manifest} ${target_name}-${i}
|
||||||
|
${dest_dir} ${src_file})
|
||||||
|
endforeach (i)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_custom_target(${sysroot_target_name}
|
||||||
|
${commands}
|
||||||
COMMENT "Preparing sysroot component: ${target_name}"
|
COMMENT "Preparing sysroot component: ${target_name}"
|
||||||
DEPENDS ${target_name} ${serialiser})
|
DEPENDS ${target_name} ${serialiser})
|
||||||
|
|
||||||
|
|||||||
@@ -32,29 +32,6 @@ function(rosetta_add_executable)
|
|||||||
DESTINATION ${arg_SYSROOT_PATH})
|
DESTINATION ${arg_SYSROOT_PATH})
|
||||||
endfunction(rosetta_add_executable)
|
endfunction(rosetta_add_executable)
|
||||||
|
|
||||||
function(rosetta_add_service)
|
|
||||||
set(options)
|
|
||||||
set(one_value_args NAME CFG_FILE)
|
|
||||||
set(multi_value_args SOURCES)
|
|
||||||
cmake_parse_arguments(PARSE_ARGV 0 arg
|
|
||||||
"${options}"
|
|
||||||
"${one_value_args}"
|
|
||||||
"${multi_value_args}")
|
|
||||||
|
|
||||||
set(exec_name ${arg_NAME})
|
|
||||||
get_property(programs GLOBAL PROPERTY rosetta_program_list)
|
|
||||||
set_property(GLOBAL PROPERTY rosetta_program_list ${programs} ${exec_name})
|
|
||||||
|
|
||||||
message(STATUS "Building service ${exec_name}")
|
|
||||||
add_executable(${exec_name} ${arg_SOURCES})
|
|
||||||
|
|
||||||
set_target_properties(${exec_name} PROPERTIES
|
|
||||||
POSITION_INDEPENDENT_CODE ON
|
|
||||||
service_cfg_path ${arg_CFG_FILE})
|
|
||||||
install(TARGETS ${exec_name}
|
|
||||||
DESTINATION ${arg_SYSROOT_PATH})
|
|
||||||
endfunction(rosetta_add_service)
|
|
||||||
|
|
||||||
function(rosetta_add_library)
|
function(rosetta_add_library)
|
||||||
set(options STATIC SHARED)
|
set(options STATIC SHARED)
|
||||||
set(one_value_args NAME)
|
set(one_value_args NAME)
|
||||||
|
|||||||
Reference in New Issue
Block a user