2018-05-22 23:08:13 +01:00
cmake_minimum_required ( VERSION 3.2 )
2018-06-14 12:23:45 +01:00
# Links against wutnewlib
2018-05-27 12:12:49 +01:00
macro ( wut_enable_newlib target )
2019-04-23 20:37:47 +10:00
message ( DEPRECATION "wut_enable_newlib is deprecated and has no effect - it is always enabled; and the macro will be removed in a future release. Please remove it from your CMakeLists." )
2018-06-14 12:23:45 +01:00
endmacro ( )
2018-05-27 12:12:49 +01:00
2018-06-14 12:23:45 +01:00
# Links against stdc++ wutstdc++ and set -std=c++17
2018-05-25 17:21:59 +01:00
macro ( wut_enable_stdcpp target )
2019-04-23 20:37:47 +10:00
message ( DEPRECATION "wut_enable_stdcpp is deprecated and has no effect - it is always enabled when using C++; and the macro will be removed in a future release. Please remove it from your CMakeLists." )
2018-06-14 12:23:45 +01:00
endmacro ( )
2018-05-25 17:21:59 +01:00
2018-07-19 08:42:12 +01:00
# Links against devoptab
macro ( wut_enable_devoptab target )
2019-04-23 20:37:47 +10:00
message ( DEPRECATION "wut_enable_devoptab is deprecated and has no effect - it is always enabled; and the macro will be removed in a future release. Please remove it from your CMakeLists." )
2018-06-14 12:23:45 +01:00
endmacro ( )
# Links against wutmalloc
macro ( wut_default_malloc target )
2019-04-23 20:37:47 +10:00
message ( DEPRECATION "wut_default_malloc is deprecated and has no effect - it is always enabled; and the macro will be removed in a future release. Please remove it from your CMakeLists." )
2018-06-14 12:23:45 +01:00
endmacro ( )
2018-05-25 17:21:59 +01:00
2018-06-14 12:23:45 +01:00
# Generates ${target}_exports.s from an exports file and adds it to the build
2019-11-23 10:10:43 +00:00
function ( wut_add_exports target exports_file )
2018-05-30 18:54:41 +01:00
set ( RPL_EXPORTS_FILE ${ exports_file } )
if ( NOT IS_ABSOLUTE ${ exports_file } )
set ( RPL_EXPORTS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${exports_file}" )
endif ( )
2018-05-31 10:30:58 +01:00
set ( RPL_EXPORT_GEN_OUTPUT ${ target } _exports.s )
2018-05-30 18:54:41 +01:00
add_custom_command (
2018-05-31 10:30:58 +01:00
O U T P U T $ { R P L _ E X P O R T _ G E N _ O U T P U T }
C O M M A N D $ { W U T _ R P L E X P O R T G E N } $ { R P L _ E X P O R T S _ F I L E } $ { R P L _ E X P O R T _ G E N _ O U T P U T }
2018-05-30 18:54:41 +01:00
D E P E N D S $ { R P L _ E X P O R T S _ F I L E } )
2018-05-31 10:30:58 +01:00
target_sources ( ${ target } PRIVATE ${ RPL_EXPORT_GEN_OUTPUT } )
2018-05-30 18:54:41 +01:00
2018-05-31 10:30:58 +01:00
set_source_files_properties ( ${ RPL_EXPORT_GEN_OUTPUT } PROPERTIES LANGUAGE C )
2019-11-23 10:10:43 +00:00
endfunction ( )
2018-05-30 18:54:41 +01:00
2019-11-22 17:43:31 +00:00
function ( wut_create_rpl_deprecated target source )
2018-05-30 15:07:10 +01:00
set ( RPL_OPTIONS IS_RPX )
2018-05-30 18:54:41 +01:00
set ( RPL_SINGLE_ARGS "" )
2018-05-30 15:07:10 +01:00
set ( RPL_MULTI_ARGS "" )
cmake_parse_arguments ( RPL "${RPL_OPTIONS}" "${RPL_SINGLE_ARGS}" "${RPL_MULTI_ARGS}" "${ARGN}" )
2018-05-30 21:56:18 +01:00
if ( RPL_IS_RPX )
2019-05-03 18:02:15 +10:00
# Do nothing - the defaults are good for RPX
2018-05-30 21:56:18 +01:00
else ( )
2018-05-30 15:07:10 +01:00
set ( ELF2RPL_FLAGS ${ ELF2RPL_FLAGS } --rpl )
2019-04-23 20:39:58 +10:00
set_property ( TARGET ${ source } APPEND_STRING PROPERTY
L I N K _ F L A G S " - s p e c s = $ { W U T _ R O O T } / s h a r e / r p l . s p e c s " )
2018-05-30 15:07:10 +01:00
endif ( )
2018-05-25 11:31:38 +01:00
add_custom_target ( ${ target } ALL
2018-11-06 20:21:40 +01:00
C O M M A N D $ { C M A K E _ S T R I P } - g $ { s o u r c e }
2018-05-30 15:07:10 +01:00
C O M M A N D $ { W U T _ E L F 2 R P L } $ { E L F 2 R P L _ F L A G S } $ { s o u r c e } $ { t a r g e t }
2018-05-27 12:12:49 +01:00
D E P E N D S $ { s o u r c e }
2019-11-23 10:10:18 +00:00
C O M M E N T " C r e a t i n g $ { t a r g e t } " )
2018-05-25 11:31:38 +01:00
2018-05-30 15:07:10 +01:00
add_dependencies ( ${ target } ${ source } )
endfunction ( )
2019-11-22 17:43:31 +00:00
function ( wut_create_rpl target )
set ( RPL_OPTIONS IS_RPX )
set ( RPL_SINGLE_ARGS "" )
set ( RPL_MULTI_ARGS "" )
cmake_parse_arguments ( RPL "${RPL_OPTIONS}" "${RPL_SINGLE_ARGS}" "${RPL_MULTI_ARGS}" "${ARGN}" )
if ( ${ ARGC } GREATER 1 AND NOT "${ARGV1}" STREQUAL "IS_RPX" )
2019-11-23 10:10:18 +00:00
message ( DEPRECATION "wut_create_rpl(dest source) is deprecated, prefer using wut_create_rpl(target) or wut_create_rpx(target)" )
wut_create_rpl_deprecated ( ${ ARGV } )
2019-11-22 17:43:31 +00:00
return ( )
endif ( )
if ( RPL_IS_RPX )
# Do nothing - the defaults are good for RPX
2019-11-23 10:10:18 +00:00
set ( RPL_SUFFIX "rpx" )
2019-11-22 17:43:31 +00:00
else ( )
set ( ELF2RPL_FLAGS ${ ELF2RPL_FLAGS } --rpl )
set_property ( TARGET ${ target } APPEND_STRING PROPERTY
L I N K _ F L A G S " - s p e c s = $ { W U T _ R O O T } / s h a r e / r p l . s p e c s " )
2019-11-23 10:10:18 +00:00
set ( RPL_SUFFIX "rpl" )
2019-11-22 17:43:31 +00:00
endif ( )
add_custom_command ( TARGET ${ target } POST_BUILD
C O M M A N D $ { C M A K E _ S T R I P } - g $ < T A R G E T _ F I L E : $ { t a r g e t } >
2019-11-23 10:10:18 +00:00
C O M M A N D $ { W U T _ E L F 2 R P L } $ { E L F 2 R P L _ F L A G S } $ < T A R G E T _ F I L E : $ { t a r g e t } > $ < T A R G E T _ F I L E _ D I R : $ { t a r g e t } > / $ { t a r g e t } . $ { R P L _ S U F F I X }
C O M M E N T " C r e a t i n g $ { t a r g e t } . $ { R P L _ S U F F I X } " )
2019-11-22 17:43:31 +00:00
endfunction ( )
2018-05-30 15:07:10 +01:00
function ( wut_create_rpx )
wut_create_rpl ( ${ ARGV } IS_RPX )
endfunction ( )