[CMake] Adding configuration for a new compiler

Hendrik Sattler post at hendrik-sattler.de
Fri Apr 11 11:34:04 EDT 2008


Zitat von Bill Hoffman <bill.hoffman at kitware.com>:

> Hendrik Sattler wrote:
>> Zitat von Brad King <brad.king at kitware.com>:
>>
>>> Hendrik Sattler wrote:
>>>> The C compiler test fails because CMake insists on createing    
>>>> testCCompiler.c.r30  and there doesn't seem to be way to tell it   
>>>> to  not include the source file name extension (here: .c) into   
>>>> the  object file name.
>>>
>>> It's undocumented because I didn't anticipate anyone would need to
>>> change the default, but the variable is
>>> "CMAKE_<lang>_OUTPUT_EXTENSION_REPLACE". Try adding
>>>
>>>  SET(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
>>>  SET(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
>>>
>>> to your compiler configuration file.
>>
>> That works, at least for the file name. There are some remaining   
>> problems, though:
>> That compiler can only handle Windows-like paths (it tries to be   
>> smart but isn't) and thus only works with the "NMake Makefiles"   
>> generator. To specify the output _directory_, the option -dir can   
>> be used and luckily, cmake provides a <OBJECT_DIR>. However, the   
>> content of that is not a Windows path but a cmake path (containing   
>> '/' instead of '\').
>> Additionally, the compiler test assumes that the compiler creates   
>> the directory itself (it doesn't) but that can be worked around in   
>> CMAKE_C_COMPILE_OBJECT. Better would be to not assume that.
>>
> So, does it work with the NMake Makefiles generator right now?

Yes, because the multi-directory is seen as one and the called  
Windows-function can handle it. So it's a minor bug, only.

>> It is possible to fix this for CMake-2.6?
>>
> I am not even clear on what changes you need at this point...

1.
<OBJECT_DIR> gives mit a directory path separated by '/', even for  
nmake generator, should be '\'-separated.

2.
When testing the compiler, the output directory is not created (at  
least it looks like it). Creating it with
"${CMAKE_COMMAND} -E make_directory <OBJECT_DIR>"
works.

3.
I am not sure what the "Compiler info" is about, as it fails for this  
compiler.
Minor though, just looks strange.

I attached Generic-nc30.cmake. That compiles a simple test.c for me.  
It is still missing stuff like looking for CMAKE_SYSTEM_PROCESSOR to  
differ between the supported CPU targets...
I am not sure what value for <LANG> has to be used for assembler, I  
assumed ASSEMBLY (read that somewhere) but ASM would be more logical I  
assume.

HS


-------------- next part --------------
SET (CMAKE_C_FLAGS_INIT "")
SET (CMAKE_C_FLAGS_DEBUG_INIT "-g")
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-OR -DNDEBUG")
SET (CMAKE_C_FLAGS_RELEASE_INIT "-OS -DNDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-OR -g")

SET (CMAKE_ASSEMBLY_OUTPUT_EXTENSION ".a30")
SET (CMAKE_C_OUTPUT_EXTENSION   ".r30")
SET (CMAKE_EXECUTABLE_SUFFIX    ".x30")

SET (CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)

SET (CMAKE_STATIC_LIBRARY_PREFIX )
SET (CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
SET (CMAKE_SHARED_LIBRARY_PREFIX )
SET (CMAKE_SHARED_LIBRARY_SUFFIX )

#
# The following requirements must be met:
#  - the environment variable LIB30 must be set
#  - the directory with as30 and nc30 must be in PATH
#
SET (CMAKE_C_COMPILE_OBJECT
  "${CMAKE_COMMAND} -E make_directory <OBJECT_DIR>"
  "<CMAKE_C_COMPILER> -silent <DEFINES> <FLAGS> -c <SOURCE> -dir <OBJECT_DIR>"
)
SET (CMAKE_C_LINK_EXECUTABLE
  "<CMAKE_C_COMPILER> -silent <FLAGS> -o <TARGET_BASE> <OBJECTS>"
)

SET (CMAKE_C_CREATE_PREPROCESSED_SOURCE
  "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>"
)
SET (CMAKE_C_CREATE_ASSEMBLY_SOURCE
  "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>"
)


More information about the CMake mailing list