the tasking compiler is a little different from gcc,
for a normal compiling command would be
E.g gcc -c xx.c -o xx.o
but in Tasking
-c is used for iso-c standard selection.
while using self-defined toolchain-file,
the ninja default generator generated the rules in ninja.build as
" ctc.exe -c xx.c -o xx.o"
(I could not find or modify the Ninja generating template Orz,
so I have to use custom command)
the generated default command “ctc.exe -c xx.c -o xx.o”
would be recognized as wrong argument.
the correct command would be " ctc.exe -o xx.o xx.c"
does there any compiling rule setting existed,
which could be defined by user as a new rule template?
just like CMAKE_C_LINK_EXECUTABLE
hi,
I have another question while editing the rule,
would you please give me some advice?
my target is to set the the command like the following
command1:
"cc -o ./aa_path/xxxx.asm -d ./bb_path/xxxx.d -c ./cc_path/xxxx.c -e ./dd_path/xxxx.c_err_log "
command2:
"ss -o ./oo_path/xxxx.o -s ./aa_path/xxxx.asm "
force to compiler the file in the raw folder(not copied into cmakefile folder)
and output the .asm .obj .dep, .error_log file into my target tmp folder.
I could modify the variable which you offered me before,
set(CMAKE_C_COMPILE_OBJECT
“<CMAKE_C_COMPILER> < DEFINES> < INCLUDES> < FLAGS> -o < OBJECT> -c < SOURCE>”
my question ares:
is there any rule like $(c_files:.c=.d) function in cmake?
how to force the output to my target path, not CMakeFiles folder?
how to add “-e ./dd_path/xxxx.c_err_log” into CMAKE_C_COMPILE_OBJECT?
Why do you want to generate temporary asm file? Your compiler is not able to directly generate object file?
For 1., No, there is no such possibility. For dependencies, see Modules/Compiler/GNU.cmake, the setting of variable CMAKE_DEPFILE_FLAGS_${lang}. The expected dependency file should be in a format compatible with GNU. See also CMAKE_DEPENDS_USE_COMPILER.
2. I think it is not possible.Why do you want this, anyway?
3. I think it is not possible
4. CMAKE_C_COMPILE_OBJECT is a CMake list. So multiple commands can be specified.
The tasking C compiler is just generating assembler source, like its macro assembler does. And afterwards the assembler is used to generate an object file. And C++ is first converted to C.
About 2. You should not care too much about the location of intermediate files. I think CMake does not provide any settings to change this.
About 3. -e is not a documented flag. I assume you want to create the error file. Here again, you should adopt to the naming that CMake uses, then you can do something like --error-file=<OBJECT>.err.log.
But be aware that those messages are not shown on STDERR anymore AFAIR.
About 4.
For CMake it’s a lot better to use the control program cctc instead of the separate tools. Otherwise you can’t easily define the flags of the several tools at the same time.
Example: For a .cpp <FLAGS> will be expanded to the C++ Flags, but you can’t access those needed for the intermediate C file or the assembler.
Why do you want to generate temporary asm file? Your compiler is not able to directly generate object file?
Answer:You know, in MCU development, sometimes the asm files are useful for the debugging if necessary. The object files actually could be generate directly in another way. I just want to know, by CMake, if it is possible to do all the process what I did in makefile before .
I think it is not possible.Why do you want this, anyway?
Answer: I just want to know whether there existed a way to set the rule, because I am a new CMake user, I hope to grasp more
CMAKE_C_COMPILE_OBJECT is a CMake list. So multiple commands can be specified.
Answer: I used ‘&&’ to connect the two command, but failed. I thought the < test_variable> in CMAKE_C_COMPILE_OBJECT could be a defined cmake-variable, but some of them doesn’t work.
please correct me if I misunderstood it. and I 'd be appreciated that if you could offer me some advice about the definition of < variable>'s in the command, and how to find their definitions. ( like “CMAKE_C_COMPILE_OBJECT” could be found int Modules/CMakeCInformation.cmake )
< test_variable> and ${test_variable} seems different, what’s the difference?
In build.ninja file, only "CMAKE_ASM_COMPILER " could NOT be replaced by the actual path, I don’t know the reason why… (while c/cxx/link works well)
I used ${CMAKE_ASM_COMPILER} instead of < CMAKE_ASM_COMPILER>, it seems that it could works, but I want to know the difference, the system ASM compiler did not be correctly defined like C compiler in my env. it might be some settings missing in my CMakelist.txt
For CMake it’s a lot better to use the control program cctc instead of the separate tools. Otherwise you can’t easily define the flags of the several tools at the same time.
Example: For a .cpp <FLAGS> will be expanded to the C++ Flags, but you can’t access those needed for the intermediate C file or the assembler.
yes, CMake did a lot for users, It’s convenient for GCC users, as all the settings are unambiguous.
But for some compiler like Tasking, if you have some customed setting, you have to know lot of setting’s source to let the CMake do the same things as MAKE, which drives me crazy cause I could not find all the information by online-document. Fortunately, I could be helped by some warm-hearted users like you and @ Marc Chevrier
Thanks again for your warm reply
“cctc” is a sample way, and I am a new CMake user, so I hope to know more about “What I can do” in CMake.
Variable CMAKE_<LANG>_COMPILE_OBJECT is for ONE language. You cannot use patterns (i.e. names insides <>) of different languages inside this variable.
What you are trying to do is quite an advanced CMake usage. May I recommend to you to have a look at this book which covers many aspects of CMake, including advanced features.
For getting the assembler files you can use the flag --keep-temporary-files on the control program.
If everything is configured correctly the control program produces hex-identical builds. In fact it’s internally calling the separate tools itself, you can check this with --verbose.
Using the control program, Tasking behaves more or less like other compilers do.