tinyusb/examples/cmake/toolchain/set_flags.cmake

21 lines
765 B
CMake
Raw Normal View History

2023-04-24 11:54:58 +07:00
include(CMakePrintHelpers)
2023-04-20 14:09:38 +07:00
foreach(LANG IN ITEMS C CXX ASM)
2023-04-24 11:54:58 +07:00
# join the toolchain flags into a single string
list(APPEND TOOLCHAIN_${LANG}_FLAGS ${TOOLCHAIN_COMMON_FLAGS})
list(JOIN TOOLCHAIN_${LANG}_FLAGS " " TOOLCHAIN_${LANG}_FLAGS)
set(CMAKE_${LANG}_FLAGS_INIT "${TOOLCHAIN_${LANG}_FLAGS}")
2023-04-20 14:09:38 +07:00
2023-04-24 11:54:58 +07:00
#cmake_print_variables(CMAKE_${LANG}_FLAGS_INIT)
# optimization flags
set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og")
2023-04-20 14:09:38 +07:00
endforeach()
2023-04-24 11:54:58 +07:00
# try_compile is cmake test compiling its own example,
# pass -nostdlib to skip stdlib linking
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
if(IS_IN_TRY_COMPILE)
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib")
endif()