nanosm/cmake/ProjectFuncs.cmake

27 lines
981 B
CMake

function(nanosm_target target)
target_compile_definitions(${target} PRIVATE "$<$<CONFIG:DEBUG>:NANOSM_DEBUG>")
target_compile_features(${target} PUBLIC cxx_std_20)
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
endfunction()
function(nanosm_set_alternate_linker)
find_program(LINKER_EXECUTABLE ld.${NANOSM_LINKER} ${NANOSM_LINKER})
if(LINKER_EXECUTABLE)
message(STATUS "Using ${NANOSM_LINKER} as argument to -fuse-ld=")
else()
message(FATAL_ERROR "Linker ${NANOSM_LINKER} does not exist on your system. Please specify one which does or omit this option from your configure command.")
endif()
endfunction()
# set the default linker based on compiler id, if one is not provided
# This is provided so that it can be overridden
if(NOT NANOSM_LINKER AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(NANOSM_LINKER "lld")
elseif(NOT NANOSM_LINKER)
set(NANOSM_LINKER "bfd")
endif()
nanosm_set_alternate_linker()