diff options
author | Johnny Jazeix <jazeix@gmail.com> | 2019-11-18 19:12:49 (GMT) |
---|---|---|
committer | Johnny Jazeix <jazeix@gmail.com> | 2019-11-18 19:12:49 (GMT) |
commit | 5cf404d36f24ed8caebceb7083cef7fb44f179f3 (patch) | |
tree | 9a7bd84b4b70d901663e6b917ebe2ca598ce436f /Modules/Platform/Generic-SDCC-C.cmake | |
parent | cbedead9a25c12272918f1f70c8a1e1417605728 (diff) | |
download | CMake-5cf404d36f24ed8caebceb7083cef7fb44f179f3.zip CMake-5cf404d36f24ed8caebceb7083cef7fb44f179f3.tar.gz CMake-5cf404d36f24ed8caebceb7083cef7fb44f179f3.tar.bz2 |
SDCC compiler: use sdar instead of sdcclib as librarian for recent versions
Fixes: #19988
Diffstat (limited to 'Modules/Platform/Generic-SDCC-C.cmake')
-rw-r--r-- | Modules/Platform/Generic-SDCC-C.cmake | 34 |
1 files changed, 24 insertions, 10 deletions
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 "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o # link object files to an executable set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <OBJECTS> -o <TARGET> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>") -# needs sdcc 2.7.0 + sddclib from cvs +# needs sdcc + sdar/sdcclib set(CMAKE_C_CREATE_STATIC_LIBRARY - "\"${CMAKE_COMMAND}\" -E rm -f <TARGET>" - "<CMAKE_AR> -a <TARGET> <LINK_FLAGS> <OBJECTS> ") + "\"${CMAKE_COMMAND}\" -E remove <TARGET>" + "<CMAKE_AR> ${CMAKE_AR_OPTIONS} <TARGET> <LINK_FLAGS> <OBJECTS> ") # not supported by sdcc set(CMAKE_C_CREATE_SHARED_LIBRARY "") |