1# 2# SPDX-License-Identifier: BSD-3-Clause 3# 4# Copyright © 2022 Keith Packard 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 13# 2. Redistributions in binary form must reproduce the above 14# copyright notice, this list of conditions and the following 15# disclaimer in the documentation and/or other materials provided 16# with the distribution. 17# 18# 3. Neither the name of the copyright holder nor the names of its 19# contributors may be used to endorse or promote products derived 20# from this software without specific prior written permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33# OF THE POSSIBILITY OF SUCH DAMAGE. 34# 35 36cmake_minimum_required(VERSION 3.20.0) 37 38project(Picolibc VERSION 1.8.2 LANGUAGES C ASM) 39 40if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64") 41 set(CMAKE_SYSTEM_PROCESSOR "aarch64") 42endif() 43 44set(CMAKE_SYSTEM_SUB_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}) 45 46if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686" OR 47 ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") 48 set(CMAKE_SYSTEM_PROCESSOR "x86") 49endif() 50 51if(ZEPHYR_BASE) 52 if(NOT CONFIG_PICOLIBC_USE_MODULE) 53 return() 54 endif() 55 include(zephyr/zephyr.cmake) 56endif() 57 58include(cmake/picolibc.cmake) 59 60enable_testing() 61 62set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 63 64# Set all configure values to defaults for now 65 66# Use atomics for fgetc/ungetc for re-entrancy 67set(ATOMIC_UNGETC 1) 68 69# Always optimize strcmp for performance 70if(NOT DEFINED FAST_STRCMP) 71 option(FAST_STRCMP "Always optimize strcmp for performance" ON) 72endif() 73 74# Obsoleted. Use regular syscalls 75set(MISSING_SYSCALL_NAMES 0) 76 77# use global errno variable 78if(NOT DEFINED NEWLIB_GLOBAL_ERRNO) 79 option(NEWLIB_GLOBAL_ERRNO "use global errno variable" OFF) 80endif() 81 82# use thread local storage 83if(NOT DEFINED PICOLIBC_TLS) 84 option(PICOLIBC_TLS "use thread local storage for static data" ON) 85endif() 86 87# use thread local storage 88set(NEWLIB_TLS ${PICOLIBC_TLS}) 89 90# Use open/close/read/write in tinystdio 91option(POSIX_IO "Provide fopen/fdopen using POSIX I/O (open, close, read, write, lseek)" ON) 92 93option(POSIX_CONSOLE "Use POSIX I/O for stdin/stdout/stderr" OFF) 94 95# Optimize for space over speed 96 97if(NOT DEFINED PREFER_SIZE_OVER_SPEED) 98 if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") 99 set(default_prefer_size 1) 100 else() 101 set(default_prefer_size 0) 102 endif() 103 option(PREFER_SIZE_OVER_SPEED ${default_prefer_size}) 104endif() 105 106# Obsoleted. Reentrant syscalls provided for us 107set(REENTRANT_SYSCALLS_PROVIDED 0) 108 109# Use tiny stdio from gcc avr 110option(TINY_STDIO "Use tiny stdio from avr libc" ON) 111 112if(NOT TLS_MODEL) 113 set(TLS_MODEL "local-exec") 114endif() 115 116set(_ATEXIT_DYNAMIC_ALLOC 0) 117 118set(_FSEEK_OPTIMIZATION 0) 119 120set(_FVWRITE_IN_STREAMIO 0) 121 122# Compiler supports alias symbol attribute 123picolibc_flag(_HAVE_ALIAS_ATTRIBUTE) 124 125# The compiler REALLY has the attribute __alloc_size__ 126picolibc_flag(_HAVE_ALLOC_SIZE) 127 128# The compiler supports the always_inline function attribute 129picolibc_flag(_HAVE_ATTRIBUTE_ALWAYS_INLINE) 130 131# The compiler supports the gnu_inline function attribute 132picolibc_flag(_HAVE_ATTRIBUTE_GNU_INLINE) 133 134# Use bitfields in packed structs 135picolibc_flag(_HAVE_BITFIELDS_IN_PACKED_STRUCTS) 136 137# The compiler supports __builtin_alloca 138picolibc_flag(_HAVE_BUILTIN_ALLOCA) 139 140# The compiler supports __builtin_copysign 141picolibc_flag(_HAVE_BUILTIN_COPYSIGN) 142 143# The compiler supports __builtin_copysignl 144picolibc_flag(_HAVE_BUILTIN_COPYSIGNL) 145 146# The compiler supports __builtin_ctz 147picolibc_flag(_HAVE_BUILTIN_CTZ) 148 149# The compiler supports __builtin_ctzl 150picolibc_flag(_HAVE_BUILTIN_CTZL) 151 152# The compiler supports __builtin_ctzll 153picolibc_flag(_HAVE_BUILTIN_CTZLL) 154 155# Compiler has __builtin_expect 156picolibc_flag(_HAVE_BUILTIN_EXPECT) 157 158# The compiler supports __builtin_ffs 159picolibc_flag(_HAVE_BUILTIN_FFS) 160 161# The compiler supports __builtin_ffsl 162picolibc_flag(_HAVE_BUILTIN_FFSL) 163 164# The compiler supports __builtin_ffsll 165picolibc_flag(_HAVE_BUILTIN_FFSLL) 166 167# The compiler supports __builtin_finitel 168picolibc_flag(_HAVE_BUILTIN_FINITEL) 169 170# The compiler supports __builtin_isfinite 171picolibc_flag(_HAVE_BUILTIN_ISFINITE) 172 173# The compiler supports __builtin_isinf 174picolibc_flag(_HAVE_BUILTIN_ISINF) 175 176# The compiler supports __builtin_isinfl 177picolibc_flag(_HAVE_BUILTIN_ISINFL) 178 179# The compiler supports __builtin_isnan 180picolibc_flag(_HAVE_BUILTIN_ISNAN) 181 182# The compiler supports __builtin_isnanl 183picolibc_flag(_HAVE_BUILTIN_ISNANL) 184 185# Compiler has __builtin_mul_overflow 186picolibc_flag(_HAVE_BUILTIN_MUL_OVERFLOW) 187 188# Compiler has __builtin_add_overflow 189picolibc_flag(_HAVE_BUILTIN_ADD_OVERFLOW) 190 191# Compiler has support for flag to prevent mis-optimizing memcpy/memset patterns 192picolibc_flag(_HAVE_CC_INHIBIT_LOOP_TO_LIBCALL) 193 194# Compiler supports _Complex 195picolibc_flag(_HAVE_COMPLEX) 196 197# Compiler supports format function attribute 198picolibc_flag(_HAVE_FORMAT_ATTRIBUTE 1) 199 200# Compiler supports weak attribute 201picolibc_flag(_HAVE_WEAK_ATTRIBUTE) 202 203set(_HAVE_FCNTL 0) 204 205# IEEE fp funcs available 206set(_HAVE_IEEEFP_FUNCS 0) 207 208# compiler supports INIT_ARRAY sections 209set(_HAVE_INITFINI_ARRAY 1) 210 211# Support _init() and _fini() functions 212set(_HAVE_INIT_FINI 1) 213 214# Compiler has long double type 215picolibc_flag(_HAVE_LONG_DOUBLE) 216 217# Compiler attribute to prevent the optimizer from adding new builtin calls 218picolibc_flag(_HAVE_NO_BUILTIN_ATTRIBUTE) 219 220# _set_tls and _init_tls functions available 221if(NOT DEFINED _HAVE_PICOLIBC_TLS_API OR NOT PICOLIBC_TLS) 222 set(_HAVE_PICOLIBC_TLS_API 0) 223endif() 224 225set(_HAVE_SEMIHOST 1) 226set(_ICONV_ENABLE_EXTERNAL_CCS 0) 227set(_ICONV_FROM_ENCODING_ 1) 228set(_ICONV_FROM_ENCODING_BIG5 1) 229set(_ICONV_FROM_ENCODING_CP775 1) 230set(_ICONV_FROM_ENCODING_CP850 1) 231set(_ICONV_FROM_ENCODING_CP852 1) 232set(_ICONV_FROM_ENCODING_CP855 1) 233set(_ICONV_FROM_ENCODING_CP866 1) 234set(_ICONV_FROM_ENCODING_EUC_JP 1) 235set(_ICONV_FROM_ENCODING_EUC_KR 1) 236set(_ICONV_FROM_ENCODING_EUC_TW 1) 237set(_ICONV_FROM_ENCODING_ISO_8859_1 1) 238set(_ICONV_FROM_ENCODING_ISO_8859_10 1) 239set(_ICONV_FROM_ENCODING_ISO_8859_11 1) 240set(_ICONV_FROM_ENCODING_ISO_8859_13 1) 241set(_ICONV_FROM_ENCODING_ISO_8859_14 1) 242set(_ICONV_FROM_ENCODING_ISO_8859_15 1) 243set(_ICONV_FROM_ENCODING_ISO_8859_2 1) 244set(_ICONV_FROM_ENCODING_ISO_8859_3 1) 245set(_ICONV_FROM_ENCODING_ISO_8859_4 1) 246set(_ICONV_FROM_ENCODING_ISO_8859_5 1) 247set(_ICONV_FROM_ENCODING_ISO_8859_6 1) 248set(_ICONV_FROM_ENCODING_ISO_8859_7 1) 249set(_ICONV_FROM_ENCODING_ISO_8859_8 1) 250set(_ICONV_FROM_ENCODING_ISO_8859_9 1) 251set(_ICONV_FROM_ENCODING_ISO_IR_111 1) 252set(_ICONV_FROM_ENCODING_KOI8_R 1) 253set(_ICONV_FROM_ENCODING_KOI8_RU 1) 254set(_ICONV_FROM_ENCODING_KOI8_U 1) 255set(_ICONV_FROM_ENCODING_KOI8_UNI 1) 256set(_ICONV_FROM_ENCODING_UCS_2 1) 257set(_ICONV_FROM_ENCODING_UCS_2BE 1) 258set(_ICONV_FROM_ENCODING_UCS_2LE 1) 259set(_ICONV_FROM_ENCODING_UCS_2_INTERNAL 1) 260set(_ICONV_FROM_ENCODING_UCS_4 1) 261set(_ICONV_FROM_ENCODING_UCS_4BE 1) 262set(_ICONV_FROM_ENCODING_UCS_4LE 1) 263set(_ICONV_FROM_ENCODING_UCS_4_INTERNAL 1) 264set(_ICONV_FROM_ENCODING_US_ASCII 1) 265set(_ICONV_FROM_ENCODING_UTF_16 1) 266set(_ICONV_FROM_ENCODING_UTF_16BE 1) 267set(_ICONV_FROM_ENCODING_UTF_16LE 1) 268set(_ICONV_FROM_ENCODING_UTF_8 1) 269set(_ICONV_FROM_ENCODING_WIN_1250 1) 270set(_ICONV_FROM_ENCODING_WIN_1251 1) 271set(_ICONV_FROM_ENCODING_WIN_1252 1) 272set(_ICONV_FROM_ENCODING_WIN_1253 1) 273set(_ICONV_FROM_ENCODING_WIN_1254 1) 274set(_ICONV_FROM_ENCODING_WIN_1255 1) 275set(_ICONV_FROM_ENCODING_WIN_1256 1) 276set(_ICONV_FROM_ENCODING_WIN_1257 1) 277set(_ICONV_FROM_ENCODING_WIN_1258 1) 278set(_ICONV_TO_ENCODING_ 1) 279set(_ICONV_TO_ENCODING_BIG5 1) 280set(_ICONV_TO_ENCODING_CP775 1) 281set(_ICONV_TO_ENCODING_CP850 1) 282set(_ICONV_TO_ENCODING_CP852 1) 283set(_ICONV_TO_ENCODING_CP855 1) 284set(_ICONV_TO_ENCODING_CP866 1) 285set(_ICONV_TO_ENCODING_EUC_JP 1) 286set(_ICONV_TO_ENCODING_EUC_KR 1) 287set(_ICONV_TO_ENCODING_EUC_TW 1) 288set(_ICONV_TO_ENCODING_ISO_8859_1 1) 289set(_ICONV_TO_ENCODING_ISO_8859_10 1) 290set(_ICONV_TO_ENCODING_ISO_8859_11 1) 291set(_ICONV_TO_ENCODING_ISO_8859_13 1) 292set(_ICONV_TO_ENCODING_ISO_8859_14 1) 293set(_ICONV_TO_ENCODING_ISO_8859_15 1) 294set(_ICONV_TO_ENCODING_ISO_8859_2 1) 295set(_ICONV_TO_ENCODING_ISO_8859_3 1) 296set(_ICONV_TO_ENCODING_ISO_8859_4 1) 297set(_ICONV_TO_ENCODING_ISO_8859_5 1) 298set(_ICONV_TO_ENCODING_ISO_8859_6 1) 299set(_ICONV_TO_ENCODING_ISO_8859_7 1) 300set(_ICONV_TO_ENCODING_ISO_8859_8 1) 301set(_ICONV_TO_ENCODING_ISO_8859_9 1) 302set(_ICONV_TO_ENCODING_ISO_IR_111 1) 303set(_ICONV_TO_ENCODING_KOI8_R 1) 304set(_ICONV_TO_ENCODING_KOI8_RU 1) 305set(_ICONV_TO_ENCODING_KOI8_U 1) 306set(_ICONV_TO_ENCODING_KOI8_UNI 1) 307set(_ICONV_TO_ENCODING_UCS_2 1) 308set(_ICONV_TO_ENCODING_UCS_2BE 1) 309set(_ICONV_TO_ENCODING_UCS_2LE 1) 310set(_ICONV_TO_ENCODING_UCS_2_INTERNAL 1) 311set(_ICONV_TO_ENCODING_UCS_4 1) 312set(_ICONV_TO_ENCODING_UCS_4BE 1) 313set(_ICONV_TO_ENCODING_UCS_4LE 1) 314set(_ICONV_TO_ENCODING_UCS_4_INTERNAL 1) 315set(_ICONV_TO_ENCODING_US_ASCII 1) 316set(_ICONV_TO_ENCODING_UTF_16 1) 317set(_ICONV_TO_ENCODING_UTF_16BE 1) 318set(_ICONV_TO_ENCODING_UTF_16LE 1) 319set(_ICONV_TO_ENCODING_UTF_8 1) 320set(_ICONV_TO_ENCODING_WIN_1250 1) 321set(_ICONV_TO_ENCODING_WIN_1251 1) 322set(_ICONV_TO_ENCODING_WIN_1252 1) 323set(_ICONV_TO_ENCODING_WIN_1253 1) 324set(_ICONV_TO_ENCODING_WIN_1254 1) 325set(_ICONV_TO_ENCODING_WIN_1255 1) 326set(_ICONV_TO_ENCODING_WIN_1256 1) 327set(_ICONV_TO_ENCODING_WIN_1257 1) 328set(_ICONV_TO_ENCODING_WIN_1258 1) 329 330# math library does not set errno (offering only ieee semantics) 331set(_IEEE_LIBM 1) 332 333if(NOT DEFINED _IO_FLOAT_EXACT) 334 option(_IO_FLOAT_EXACT "Provide exact binary/decimal conversion for printf/scanf" 1) 335endif() 336 337set(_LITE_EXIT 1) 338 339set(_PICO_EXIT 1) 340 341if(NOT DEFINED _MB_CAPABLE) 342 option(_MB_CAPABLE "Enable multi-byte support" 0) 343endif() 344 345set(_MB_LEN_MAX 1 1) 346 347set(_NANO_FORMATTED_IO 0) 348 349option(_NANO_MALLOC "Use smaller malloc implementation" 1) 350 351set(_REENT_GLOBAL_ATEXIT 0) 352 353set(_UNBUF_STREAM_OPT 0) 354 355if(NOT DEFINED _WANT_IO_C99_FORMATS) 356 option(_WANT_IO_C99_FORMATS "Support C99 formats in printf/scanf" ON) 357endif() 358 359if(NOT DEFINED _WANT_IO_LONG_LONG) 360 option(_WANT_IO_LONG_LONG "Support long long in integer printf/scanf" OFF) 361endif() 362 363if(NOT DEFINED _WANT_IO_POS_ARGS) 364 option(_WANT_IO_POS_ARGS "Support positional args in integer printf/scanf" OFF) 365endif() 366 367option(__IO_FLOAT "Support floating point in printf/scanf by default" OFF) 368 369if(NOT DEFINED _WANT_IO_PERCENT_B) 370 option(_WANT_IO_PERCENT_B "Support %b/%B formats in printf/scanf" OFF) 371endif() 372 373if(NOT DEFINED FORMAT_DEFAULT_DOUBLE) 374 set(FORMAT_DEFAULT_DOUBLE ${__IO_FLOAT}) 375endif() 376 377if(NOT DEFINED FORMAT_DEFAULT_FLOAT) 378 set(FORMAT_DEFAULT_FLOAT 0) 379endif() 380 381if(NOT DEFINED FORMAT_DEFAULT_INTEGER) 382 set(FORMAT_DEFAULT_INTEGER NOT ${__IO_FLOAT}) 383endif() 384 385# math library sets errno 386set(_WANT_MATH_ERRNO 0) 387 388set(_WANT_REENT_SMALL 0) 389 390set(_WANT_REGISTER_FINI 0) 391 392# Obsoleted. Define time_t to long instead of using a 64-bit type 393set(_WANT_USE_LONG_TIME_T 0) 394 395set(_WIDE_ORIENT 0) 396 397# locale support 398if(NOT DEFINED __HAVE_LOCALE_INFO__) 399 option(__HAVE_LOCALE_INFO__ "Provide locale support" 0) 400endif() 401 402# extended locale support 403if(NOT DEFINED __HAVE_LOCALE_INFO_EXTENDED__) 404 option(__HAVE_LOCALE_INFO_EXTENDED__ "Provide even more locale support" 0) 405endif() 406 407if(__HAVE_LOCALE_INFO_EXTENDED__ AND NOT __HAVE_LOCALE_INFO__) 408 message(FATAL_ERROR "Must have locale support to enable extended locale support") 409endif() 410 411# Use old math code for double funcs (0 no, 1 yes) 412set(__OBSOLETE_MATH_FLOAT 1) 413 414# Use old math code for double funcs (0 no, 1 yes) 415set(__OBSOLETE_MATH_DOUBLE 1) 416 417# Compute static memory area sizes at runtime instead of link time 418set(__PICOLIBC_CRT_RUNTIME_SIZE 0) 419 420if(NOT DEFINED __SINGLE_THREAD__) 421 option(__SINGLE_THREAD__ "Disable multithreading support" 0) 422endif() 423 424if(__SINGLE_THREAD__) 425 set(_RETARGETABLE_LOCKING 0) 426else() 427 set(_RETARGETABLE_LOCKING 1) 428endif() 429 430set(NEWLIB_VERSION 4.3.0) 431set(NEWLIB_MAJOR 4) 432set(NEWLIB_MINOR 3) 433set(NEWLIB_PATCH 0) 434 435set(PICOLIBC_INCLUDE ${PROJECT_BINARY_DIR}/picolibc/include) 436 437set(PICOLIBC_SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/scripts") 438 439include(CheckIncludeFile) 440 441CHECK_INCLUDE_FILE(xtensa/config/core-isa.h _XTENSA_HAVE_CONFIG_CORE_ISA_H) 442 443configure_file(picolibc.h.in "${PICOLIBC_INCLUDE}/picolibc.h") 444 445set(INCLUDEDIR include) 446set(LIBDIR .) 447if(PICOLIBC_TLS) 448 set(TLSMODEL "-ftls-model=${TLS_MODEL}") 449endif() 450set(LINK_SPEC "") 451set(CC1_SPEC "") 452set(CC1PLUS_SPEC "") 453set(ADDITIONAL_LIBS "") 454set(SPECS_EXTRA "") 455set(SPECS_ISYSTEM "-isystem ${PROJECT_BINARY_DIR}/${include}") 456set(SPECS_LIBPATH "-L${PROJECT_BINARY_DIR}") 457set(SPECS_STARTFILE "${PROJECT_BINARY_DIR}/crt0.o") 458string(APPEND SPECS_PRINTF "%{DPICOLIBC_FLOAT_PRINTF_SCANF:--defsym=vfprintf=__f_vfprintf}" 459 " %{DPICOLIBC_FLOAT_PRINTF_SCANF:--defsym=vfscanf=__f_vfscanf}" 460 " %{DPICOLIBC_DOUBLE_PRINTF_SCANF:--defsym=vfprintf=__d_vfprintf}" 461 " %{DPICOLIBC_DOUBLE_PRINTF_SCANF:--defsym=vfscanf=__d_vfscanf}" 462 " %{DPICOLIBC_INTEGER_PRINTF_SCANF:--defsym=vfprintf=__i_vfprintf}") 463set(PREFIX "${PROJECT_BINARY_DIR}") 464 465configure_file(picolibc.specs.in "${PROJECT_BINARY_DIR}/picolibc.specs" @ONLY) 466 467set(PICOLIBC_COMPILE_OPTIONS 468 "--include" "${PICOLIBC_INCLUDE}/picolibc.h" 469 "-nostdlib" 470 "-D_LIBC" 471 ${TLSMODEL} 472 ${TARGET_COMPILE_OPTIONS} 473 ${PICOLIBC_EXTRA_COMPILE_OPTIONS} 474 ${PICOLIBC_MATH_FLAGS} 475 ) 476 477# Strip out any generator expressions as those cannot be used with 478# try_compile 479 480foreach(c_option "${PICOLIBC_COMPILE_OPTIONS}") 481 if(NOT "${c_option}" MATCHES "\\$") 482 list(APPEND PICOLIBC_TEST_COMPILE_OPTIONS "${c_option}") 483 endif() 484endforeach() 485 486picolibc_supported_compile_options( 487 "-fno-common" 488 "-fno-stack-protector" 489 "-ffunction-sections" 490 "-fdata-sections" 491 "-Wall" 492 "-Wextra" 493 "-Werror=implicit-function-declaration" 494 "-Werror=vla" 495 "-Warray-bounds" 496 "-Wold-style-definition" 497 "-frounding-math" 498 "-fsignaling-nans" 499 ) 500 501add_library(c STATIC) 502 503target_compile_options(c PRIVATE ${PICOLIBC_COMPILE_OPTIONS}) 504 505set(PICOLIBC_INCLUDE_DIRECTORIES 506 "${PICOLIBC_INCLUDE}") 507 508target_include_directories(c SYSTEM PUBLIC ${PICOLIBC_INCLUDE_DIRECTORIES}) 509 510define_property(GLOBAL PROPERTY PICOLIBC_HEADERS 511 BRIEF_DOCS "Installed header files" 512 FULL_DOCS "These are names of header files which are to be installed.") 513 514add_subdirectory(newlib) 515 516install(TARGETS c 517 LIBRARY DESTINATION lib 518 PUBLIC_HEADER DESTINATION include) 519 520option(TESTS "Enable tests" OFF) 521if(TESTS) 522 523 # This could use some generalization, but it's good enough to do 524 # semihosting-based tests 525 526 add_subdirectory(semihost) 527 add_subdirectory(picocrt) 528 529 set(PICOCRT_OBJ $<TARGET_OBJECTS:picocrt>) 530 set(PICOCRT_SEMIHOST_OBJ $<TARGET_OBJECTS:picocrt-semihost>) 531 532 # semihost and libc have mutual-dependencies, so place them in a 533 # linker group 534 535 set(PICOLIBC_TEST_LINK_LIBRARIES 536 ${PICOCRT_SEMIHOST_OBJ} 537 -Wl,--start-group c semihost -Wl,--end-group 538 ${PICOLIBC_LINK_FLAGS} 539 ) 540 541 add_subdirectory(test) 542 543endif() 544 545install(FILES ${CMAKE_BINARY_DIR}/picolibc.specs DESTINATION lib) 546install(FILES ${CMAKE_BINARY_DIR}/picolibc/include/picolibc.h DESTINATION include) 547