1# SPDX-License-Identifier: Apache-2.0
2
3if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/${CMAKE_HOST_SYSTEM_NAME}.${CMAKE_HOST_SYSTEM_PROCESSOR}.cmake)
4  # @Intent: Set necessary compiler & linker options for this specific host architecture & OS
5  include(${CMAKE_HOST_SYSTEM_NAME}.${CMAKE_HOST_SYSTEM_PROCESSOR}.cmake)
6else()
7  if (CONFIG_64BIT)
8    # some gcc versions fail to build without -fPIC
9    zephyr_compile_options(-m64 -fPIC)
10    zephyr_link_libraries(-m64)
11  else ()
12    zephyr_compile_options(-m32)
13    zephyr_link_libraries(-m32)
14  endif ()
15endif()
16
17zephyr_compile_options(
18  ${ARCH_FLAG}
19  -include ${ZEPHYR_BASE}/arch/posix/include/posix_cheats.h
20  )
21
22# @Intent: Obtain compiler specific flags for no freestanding compilation
23zephyr_compile_options($<TARGET_PROPERTY:compiler,hosted>)
24
25zephyr_include_directories(${BOARD_DIR})
26
27if (CONFIG_ASAN)
28  zephyr_compile_options($<TARGET_PROPERTY:compiler,sanitize_address>)
29  zephyr_link_libraries($<TARGET_PROPERTY:linker,sanitize_address>)
30endif ()
31
32if (CONFIG_UBSAN)
33  zephyr_compile_options($<TARGET_PROPERTY:compiler,sanitize_undefined>)
34  zephyr_link_libraries($<TARGET_PROPERTY:linker,sanitize_undefined>)
35endif ()
36
37zephyr_compile_definitions(_POSIX_C_SOURCE=200809 _XOPEN_SOURCE=600 _XOPEN_SOURCE_EXTENDED)
38
39zephyr_ld_options(
40  -ldl
41  -pthread
42)
43
44# About the -include directive: The reason to do it this way, is because in this
45# manner it is transparent to the application. Otherwise posix_cheats.h needs to
46# be included in all the applications' files which define main( ), and in any
47# app file which uses the pthreads like API provided by Zephyr
48# ( include/posix/pthread.h / kernel/pthread.c ) [And any future API added to
49# Zephyr which will clash with the native POSIX API] . It would also need to
50# be included in a few zephyr kernel files.
51
52
53add_subdirectory(core)
54