On 09/08/2010 07:35 PM, Nick Foster wrote:
> 
> Hi there,
> 
> I'm using CMake with SDCC. Currently, support for SDCC in CMake does not also 
> include dialects for its various assemblers. So I've created one, for the 
> asx8051 assembler. The problem is that the asx8051 assembler shows 
> nonstandard behavior, and does not let you arbitrarily name the output. 
> Instead, if you compile myfile.a51, it produces myfile.rel. No option to 
> change that.
> 
> CMake tells the linker to then look for an output file named 
> <source_filename><CMAKE_ASM${ASM_DIALECT}_OUTPUT_EXTENSION>, which ends up 
> looking for myfile.a51.rel. I can add whatever arbitrary extension I want, 
> but I need to strip the .a51 from CMake's expected output filename so it 
> knows to look for myfile.rel. Should I create a custom command which moves 
> myfile.rel to myfile.a51.rel? It seems unnecessarily Byzantine. Is there an 
> easier way?

Possibly, you could tweak the CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT
variable; look at the following CMakeLists.txt for an example in C:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(RENOBJ C)
FILE(WRITE ${CMAKE_BINARY_DIR}/renobj.cmake "
GET_FILENAME_COMPONENT(NAME \${FILE} NAME)
STRING(REGEX REPLACE \"\\\\.c\\\\.o\\$\" \".o\" LINK \${FILE})
EXECUTE_PROCESS(COMMAND
${CMAKE_COMMAND} -E create_symlink \${NAME} \${LINK})
")
SET(CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}"
"${CMAKE_COMMAND} -DFILE=<OBJECT> -P ${CMAKE_BINARY_DIR}/renobj.cmake")
FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")
ADD_EXECUTABLE(main main.c)

The renobj.cmake script takes an object file name, replaces its ".c.o"
suffix by ".o" and creates a symlink to the original file. This script
is invoked as an additional command from the compilation rule variable.
Perhaps, that approach can be adapted to your case. Alternatively, you
might consider to use a link launcher, see RULE_LAUNCH_LINK properties
and [1] for an example.

Regards,

Michael

[1] http://www.mail-archive.com/cmake@cmake.org/msg29622.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to