2026-02-05 09:54:46 +00:00
|
|
|
function(rosetta_add_executable)
|
|
|
|
|
set(options)
|
2026-02-19 19:25:44 +00:00
|
|
|
set(one_value_args NAME)
|
2026-02-05 09:54:46 +00:00
|
|
|
set(multi_value_args
|
|
|
|
|
SUBDIRS
|
|
|
|
|
EXTRA_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})
|
|
|
|
|
|
|
|
|
|
file(GLOB sources *.c *.h)
|
|
|
|
|
|
|
|
|
|
foreach (dir ${arg_SUBDIRS})
|
|
|
|
|
file(GLOB dir_sources ${dir}/*.c ${dir}/*.h)
|
|
|
|
|
set(sources ${sources} ${dir_sources})
|
|
|
|
|
endforeach (dir)
|
|
|
|
|
|
|
|
|
|
message(STATUS "Building program ${exec_name}")
|
|
|
|
|
add_executable(${exec_name}
|
|
|
|
|
${sources}
|
|
|
|
|
${arg_EXTRA_SOURCES})
|
|
|
|
|
|
|
|
|
|
set_target_properties(${exec_name} PROPERTIES
|
|
|
|
|
POSITION_INDEPENDENT_CODE ON
|
|
|
|
|
sys_bin_dir ${arg_SYSROOT_PATH})
|
|
|
|
|
install(TARGETS ${exec_name}
|
|
|
|
|
DESTINATION ${arg_SYSROOT_PATH})
|
|
|
|
|
endfunction(rosetta_add_executable)
|
|
|
|
|
|
|
|
|
|
function(rosetta_add_library)
|
2026-02-19 19:25:44 +00:00
|
|
|
set(options STATIC SHARED)
|
|
|
|
|
set(one_value_args NAME)
|
2026-02-05 09:54:46 +00:00
|
|
|
set(multi_value_args
|
2026-02-19 19:25:44 +00:00
|
|
|
PUBLIC_INCLUDE_DIRS
|
|
|
|
|
SOURCES
|
|
|
|
|
HEADERS)
|
2026-02-05 09:54:46 +00:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
|
|
|
|
"${options}"
|
|
|
|
|
"${one_value_args}"
|
|
|
|
|
"${multi_value_args}")
|
|
|
|
|
|
|
|
|
|
set(lib_name ${arg_NAME})
|
2026-02-19 19:25:44 +00:00
|
|
|
set(targets)
|
2026-02-05 09:54:46 +00:00
|
|
|
|
2026-02-19 19:25:44 +00:00
|
|
|
if ((NOT ${arg_STATIC}) AND (NOT ${arg_SHARED}))
|
|
|
|
|
message(FATAL_ERROR "rosetta_add_library(${arg_NAME}): must specified SHARED and/or STATIC")
|
|
|
|
|
endif ()
|
2026-02-05 09:54:46 +00:00
|
|
|
|
2026-02-19 19:25:44 +00:00
|
|
|
set(static_lib_name ${lib_name})
|
|
|
|
|
set(shared_lib_name ${lib_name})
|
2026-02-05 09:54:46 +00:00
|
|
|
|
2026-02-19 19:25:44 +00:00
|
|
|
if (${arg_STATIC} AND ${arg_SHARED})
|
|
|
|
|
set(static_lib_name ${lib_name}-static)
|
|
|
|
|
endif ()
|
2026-02-05 09:54:46 +00:00
|
|
|
|
|
|
|
|
message(STATUS "Building library ${lib_name}")
|
2026-02-19 19:25:44 +00:00
|
|
|
if (${arg_STATIC})
|
|
|
|
|
add_library(${static_lib_name} STATIC
|
|
|
|
|
${arg_SOURCES}
|
|
|
|
|
${arg_HEADERS})
|
2026-03-06 20:15:05 +00:00
|
|
|
set_target_properties(${static_lib_name} PROPERTIES OUTPUT_NAME "${lib_name}")
|
2026-03-10 19:14:00 +00:00
|
|
|
target_compile_definitions(${static_lib_name} PRIVATE
|
|
|
|
|
BUILD_STATIC=1)
|
2026-02-19 19:25:44 +00:00
|
|
|
set(targets ${targets} ${static_lib_name})
|
|
|
|
|
|
|
|
|
|
if (arg_PUBLIC_INCLUDE_DIRS)
|
|
|
|
|
meta_target_add_header_directory(
|
|
|
|
|
TARGET ${static_lib_name}
|
|
|
|
|
PATH ${arg_PUBLIC_INCLUDE_DIRS})
|
|
|
|
|
endif ()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (${arg_SHARED})
|
|
|
|
|
add_library(${shared_lib_name} SHARED
|
|
|
|
|
${arg_SOURCES}
|
|
|
|
|
${arg_HEADERS})
|
|
|
|
|
set(targets ${targets} ${shared_lib_name})
|
|
|
|
|
set(soname ${shared_lib_name}.so)
|
|
|
|
|
|
|
|
|
|
if (arg_PUBLIC_INCLUDE_DIRS)
|
|
|
|
|
meta_target_add_header_directory(
|
|
|
|
|
TARGET ${shared_lib_name}
|
|
|
|
|
PATH ${arg_PUBLIC_INCLUDE_DIRS})
|
|
|
|
|
endif ()
|
|
|
|
|
|
2026-03-10 19:14:00 +00:00
|
|
|
target_compile_definitions(${shared_lib_name} PRIVATE
|
|
|
|
|
BUILD_SHARED=1)
|
2026-02-19 19:25:44 +00:00
|
|
|
set_target_properties(${shared_lib_name} PROPERTIES
|
|
|
|
|
SOVERSION 1)
|
|
|
|
|
target_link_options(${shared_lib_name} PRIVATE -Wl,--soname,${soname})
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-03-06 20:15:05 +00:00
|
|
|
foreach (target ${targets})
|
|
|
|
|
target_include_directories(${target} PUBLIC ${arg_PUBLIC_INCLUDE_DIRS})
|
|
|
|
|
endforeach (target)
|
|
|
|
|
|
2026-02-19 19:25:44 +00:00
|
|
|
set_target_properties(${targets} PROPERTIES
|
|
|
|
|
POSITION_INDEPENDENT_CODE ON
|
|
|
|
|
src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
|
PREFIX "")
|
|
|
|
|
endfunction(rosetta_add_library)
|
|
|
|
|
|
|
|
|
|
function(rosetta_add_object_library)
|
|
|
|
|
set(options)
|
|
|
|
|
set(one_value_args NAME)
|
|
|
|
|
set(multi_value_args
|
|
|
|
|
PUBLIC_INCLUDE_DIRS
|
|
|
|
|
SOURCES
|
|
|
|
|
HEADERS)
|
|
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
|
|
|
|
"${options}"
|
|
|
|
|
"${one_value_args}"
|
|
|
|
|
"${multi_value_args}")
|
|
|
|
|
|
|
|
|
|
set(lib_name ${arg_NAME})
|
|
|
|
|
|
|
|
|
|
message(STATUS "Building library ${lib_name}")
|
|
|
|
|
add_library(${lib_name} OBJECT
|
|
|
|
|
${arg_SOURCES}
|
|
|
|
|
${arg_HEADERS})
|
|
|
|
|
|
|
|
|
|
target_include_directories(${lib_name} PUBLIC ${arg_PUBLIC_INCLUDE_DIRS})
|
|
|
|
|
set_target_properties(${lib_name} PROPERTIES
|
|
|
|
|
POSITION_INDEPENDENT_CODE ON
|
|
|
|
|
src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
|
PREFIX "")
|
|
|
|
|
endfunction(rosetta_add_object_library)
|
|
|
|
|
|
|
|
|
|
function(rosetta_wrap_library)
|
|
|
|
|
set(options)
|
|
|
|
|
set(one_value_args NAME)
|
|
|
|
|
set(multi_value_args
|
|
|
|
|
PUBLIC_INCLUDE_DIRS)
|
|
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
|
|
|
|
"${options}"
|
|
|
|
|
"${one_value_args}"
|
|
|
|
|
"${multi_value_args}")
|
|
|
|
|
|
|
|
|
|
set(lib_name ${arg_NAME})
|
|
|
|
|
|
|
|
|
|
message(STATUS "Building library ${lib_name}")
|
|
|
|
|
|
|
|
|
|
if (arg_PUBLIC_INCLUDE_DIRS)
|
|
|
|
|
meta_target_add_header_directory(
|
|
|
|
|
TARGET ${lib_name}
|
|
|
|
|
PATH ${arg_PUBLIC_INCLUDE_DIRS})
|
2026-02-05 09:54:46 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
set_target_properties(${lib_name} PROPERTIES
|
|
|
|
|
POSITION_INDEPENDENT_CODE ON
|
|
|
|
|
src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
|
PREFIX "")
|
2026-02-19 19:25:44 +00:00
|
|
|
endfunction(rosetta_wrap_library)
|
|
|
|
|
|
|
|
|
|
function(rosetta_add_object_library)
|
|
|
|
|
set(options)
|
|
|
|
|
set(one_value_args NAME)
|
|
|
|
|
set(multi_value_args
|
|
|
|
|
PUBLIC_INCLUDE_DIRS
|
|
|
|
|
SOURCES
|
|
|
|
|
HEADERS)
|
|
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
|
|
|
|
"${options}"
|
|
|
|
|
"${one_value_args}"
|
|
|
|
|
"${multi_value_args}")
|
|
|
|
|
|
|
|
|
|
set(lib_name ${arg_NAME})
|
|
|
|
|
|
|
|
|
|
message(STATUS "Building library ${lib_name}")
|
|
|
|
|
add_library(${lib_name} OBJECT
|
|
|
|
|
${arg_SOURCES}
|
|
|
|
|
${arg_HEADERS})
|
|
|
|
|
#add_library(${lib_name} STATIC
|
|
|
|
|
# ${sources}
|
|
|
|
|
# ${headers}
|
|
|
|
|
# ${arg_EXTRA_SOURCES})
|
|
|
|
|
|
|
|
|
|
target_include_directories(${lib_name} PUBLIC ${arg_PUBLIC_INCLUDE_DIRS})
|
|
|
|
|
set_target_properties(${lib_name} PROPERTIES
|
|
|
|
|
POSITION_INDEPENDENT_CODE ON
|
|
|
|
|
src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
|
PREFIX "")
|
|
|
|
|
endfunction(rosetta_add_object_library)
|