From 5cf404d36f24ed8caebceb7083cef7fb44f179f3 Mon Sep 17 00:00:00 2001 From: Johnny Jazeix Date: Mon, 18 Nov 2019 20:12:49 +0100 Subject: SDCC compiler: use sdar instead of sdcclib as librarian for recent versions Fixes: #19988 --- Help/release/dev/sdcc-new-librarian.rst | 6 ++++++ Modules/Platform/Generic-SDCC-C.cmake | 34 +++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 Help/release/dev/sdcc-new-librarian.rst diff --git a/Help/release/dev/sdcc-new-librarian.rst b/Help/release/dev/sdcc-new-librarian.rst new file mode 100644 index 0000000..93961ce --- /dev/null +++ b/Help/release/dev/sdcc-new-librarian.rst @@ -0,0 +1,6 @@ +sdcc-new-librarian +------------------ + +* Since sdcc 3.2.0, sdcclib has been deprecated in favor of sdar as librarian. + Since sdcc 3.8.6, it has been removed from the distribution. + Use sdar if found, else use sdcclib to keep older compatibility. diff --git a/Modules/Platform/Generic-SDCC-C.cmake b/Modules/Platform/Generic-SDCC-C.cmake index 8f648a1..c51767e 100644 --- a/Modules/Platform/Generic-SDCC-C.cmake +++ b/Modules/Platform/Generic-SDCC-C.cmake @@ -19,14 +19,28 @@ set(CMAKE_DL_LIBS "") set(CMAKE_C_OUTPUT_EXTENSION ".rel") -# find sdcclib as CMAKE_AR -# since cmake may already have searched for "ar", sdcclib has to -# be searched with a different variable name (SDCCLIB_EXECUTABLE) -# and must then be forced into the cache +# find sdar/sdcclib as CMAKE_AR +# since cmake may already have searched for "ar", sdar has to +# be searched with a different variable name (SDCCAR_EXECUTABLE) +# and must then be forced into the cache. +# sdcclib has been deprecated in SDCC 3.2.0 and removed in 3.8.6 +# so we first look for sdar get_filename_component(SDCC_LOCATION "${CMAKE_C_COMPILER}" PATH) -find_program(SDCCLIB_EXECUTABLE sdcclib PATHS "${SDCC_LOCATION}" NO_DEFAULT_PATH) -find_program(SDCCLIB_EXECUTABLE sdcclib) -set(CMAKE_AR "${SDCCLIB_EXECUTABLE}" CACHE FILEPATH "The sdcc librarian" FORCE) +find_program(SDCCAR_EXECUTABLE sdar NAMES sdcclib PATHS "${SDCC_LOCATION}" NO_DEFAULT_PATH) +find_program(SDCCAR_EXECUTABLE sdar NAMES sdcclib) +# for compatibility, in case SDCCLIB_EXECUTABLE is set, we use it +if(DEFINED SDCCLIB_EXECUTABLE) + set(CMAKE_AR "${SDCCLIB_EXECUTABLE}" CACHE FILEPATH "The sdcc librarian" FORCE) +else() + set(CMAKE_AR "${SDCCAR_EXECUTABLE}" CACHE FILEPATH "The sdcc librarian" FORCE) +endif() + + +if("${SDCCAR_EXECUTABLE}" MATCHES "sdcclib") + set(CMAKE_AR_OPTIONS "-a") +else() + set(CMAKE_AR_OPTIONS "-rc") +endif() # CMAKE_C_FLAGS_INIT and CMAKE_EXE_LINKER_FLAGS_INIT should be set in a CMAKE_SYSTEM_PROCESSOR file if(NOT DEFINED CMAKE_C_FLAGS_INIT) @@ -45,10 +59,10 @@ set(CMAKE_C_COMPILE_OBJECT " -o # link object files to an executable set(CMAKE_C_LINK_EXECUTABLE " -o ") -# needs sdcc 2.7.0 + sddclib from cvs +# needs sdcc + sdar/sdcclib set(CMAKE_C_CREATE_STATIC_LIBRARY - "\"${CMAKE_COMMAND}\" -E rm -f " - " -a ") + "\"${CMAKE_COMMAND}\" -E remove " + " ${CMAKE_AR_OPTIONS} ") # not supported by sdcc set(CMAKE_C_CREATE_SHARED_LIBRARY "") -- cgit v0.12