function(rosetta_add_executable) set(options) set(one_value_args NAME SYSROOT_PATH) 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) set(options SHARED) set(one_value_args NAME SYSROOT_PATH) set(multi_value_args SOURCE_DIRS EXTRA_SOURCES) cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${one_value_args}" "${multi_value_args}") set(lib_name ${arg_NAME}) get_property(libs GLOBAL PROPERTY rosetta_library_list) set_property(GLOBAL PROPERTY rosetta_library_list ${libs} ${lib_name}) file(GLOB sources *.c *.h) file(GLOB_RECURSE headers include/*.h) foreach (dir ${arg_SOURCE_DIRS}) file(GLOB dir_sources ${dir}/*.c ${dir}/*.h) set(sources ${sources} ${dir_sources}) endforeach (dir) message(STATUS "Building library ${lib_name}") if (arg_SHARED) add_library(${lib_name} SHARED ${sources} ${headers} ${arg_EXTRA_SOURCES}) else () add_library(${lib_name} STATIC ${sources} ${headers} ${arg_EXTRA_SOURCES}) endif () target_include_directories(${lib_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) set_target_properties(${lib_name} PROPERTIES POSITION_INDEPENDENT_CODE ON src_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/include sys_header_dir ${arg_SYSROOT_PATH}/include sys_bin_dir ${arg_SYSROOT_PATH}/lib PREFIX "") endfunction(rosetta_add_library)