modify cmake build arguments

classic Classic list List threaded Threaded
9 messages Options
Hex
Reply | Threaded
Open this post in threaded view
|

modify cmake build arguments

Hex

hello community,


CMake builds a C project with gcc -o target_name. I have a compiler very similar to GCC and I am trying configure CMake C language for it.


The compiler does not support the -o argument when linking objects. I wonder if there is a way to remove or modify this argument, maybe through one of the properties on targets?


thank you


--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: modify cmake build arguments

CMake mailing list
On Thu, 2019-08-29 at 18:27 +0100, hex wrote:

> hello community,
>
> CMake builds a C project with gcc -o target_name. I have a compiler
> very similar to GCC and I am trying configure CMake C language for
> it.
>
> The compiler does not support the -o argument when linking objects. I
> wonder if there is a way to remove or modify this argument, maybe
> through one of the properties on targets?
>
> thank you

Your best bet would be to modify the CMake source code to support your
compiler. (Upstreaming your changes would be welcome.)

As a matter of interest, what does it use instead of -o?

Kyle
--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: modify cmake build arguments

fdk17


On Thu, Aug 29, 2019, at 2:52 PM, Kyle Edwards via CMake wrote:
On Thu, 2019-08-29 at 18:27 +0100, hex wrote:
> hello community,

> CMake builds a C project with gcc -o target_name. I have a compiler
> very similar to GCC and I am trying configure CMake C language for
> it.

> The compiler does not support the -o argument when linking objects. I
> wonder if there is a way to remove or modify this argument, maybe
> through one of the properties on targets?

> thank you

Your best bet would be to modify the CMake source code to support your
compiler. (Upstreaming your changes would be welcome.)

As a matter of interest, what does it use instead of -o?

Kyle

If you are using the Makefile generator then try:
You may then be able to provide the rules needed, refer to "Modules/CMakeCInformation.cmake".
The way I understand it is that the rule templates are used by the Makefile generator.


--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: modify cmake build arguments

Eric Dönges
On 29.08.2019 22:38, fdk17 wrote:
On Thu, Aug 29, 2019, at 2:52 PM, Kyle Edwards via CMake wrote:
On Thu, 2019-08-29 at 18:27 +0100, hex wrote:
> hello community,

> CMake builds a C project with gcc -o target_name. I have a compiler
> very similar to GCC and I am trying configure CMake C language for
> it.

> The compiler does not support the -o argument when linking objects. I
> wonder if there is a way to remove or modify this argument, maybe
> through one of the properties on targets?

> thank you

Your best bet would be to modify the CMake source code to support your
compiler. (Upstreaming your changes would be welcome.)

As a matter of interest, what does it use instead of -o?

Kyle

If you are using the Makefile generator then try:
You may then be able to provide the rules needed, refer to "Modules/CMakeCInformation.cmake".
The way I understand it is that the rule templates are used by the Makefile generator.


The way I understand the documentation, CMAKE_USER_MAKE_RULES_OVERRIDE applies for all generators, not just the Makefile one. What you are apparently supposed to do is create a file that sets all the "rule variables" as required (in this case, CMAKE_C_COMPILE_OBJECT), and then include that file via CMAKE_USER_MAKE_RULES_OVERRIDE. I'm not sure if these 'rule variables' are documented anywhere - but you can look into "<path where CMake is installed>/share/cmake-<version>/Modules/Compiler" for inspiration. Another good starting point would be "<...>/share/cmake-<version>/Modules/CMakeCInformation.cmake".

With kind regards,
Eric

Dr. Eric Dönges
Senior Software Engineer

MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
[hidden email] | Tel: +49 89 457 695-0 | www.mvtec.com

 Sign up for our MVTec Newsletter!

Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695

 

MVTec Software GmbH Logo

--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: modify cmake build arguments

fdk17


On Fri, Aug 30, 2019, at 1:47 AM, Eric Doenges wrote:
On 29.08.2019 22:38, fdk17 wrote:
On Thu, Aug 29, 2019, at 2:52 PM, Kyle Edwards via CMake wrote:
On Thu, 2019-08-29 at 18:27 +0100, hex wrote:
> hello community,

> CMake builds a C project with gcc -o target_name. I have a compiler
> very similar to GCC and I am trying configure CMake C language for
> it.

> The compiler does not support the -o argument when linking objects. I
> wonder if there is a way to remove or modify this argument, maybe
> through one of the properties on targets?

> thank you

Your best bet would be to modify the CMake source code to support your
compiler. (Upstreaming your changes would be welcome.)

As a matter of interest, what does it use instead of -o?

Kyle

If you are using the Makefile generator then try:
You may then be able to provide the rules needed, refer to "Modules/CMakeCInformation.cmake".
The way I understand it is that the rule templates are used by the Makefile generator.

The way I understand the documentation, CMAKE_USER_MAKE_RULES_OVERRIDE applies for all generators, not just the Makefile one. What you are apparently supposed to do is create a file that sets all the "rule variables" as required (in this case, CMAKE_C_COMPILE_OBJECT), and then include that file via CMAKE_USER_MAKE_RULES_OVERRIDE. I'm not sure if these 'rule variables' are documented anywhere - but you can look into "<path where CMake is installed>/share/cmake-<version>/Modules/Compiler" for inspiration. Another good starting point would be "<...>/share/cmake-<version>/Modules/CMakeCInformation.cmake".


With kind regards,
Eric


Dr. Eric Dönges
Senior Software Engineer



I could have been clearer about the use of CMAKE_USER_MAKE_RULES_OVERRIDE.  It wasn't my intention to suggest that only the Makefile generator makes use of this variable.

In a quick check I only saw the CMAKE_C_COMPILE_OBJECT rule being used by the Makefile (and maybe the Ninja) generator and I know that it isn't used by the GHS Multi generator.  Which is why I mentioned the Makefile generator specifically in regards to changing a "-o" to something else.

If you look at Modules/CMakeCInformation.cmake it will only define a rule if it hasn't already been previously set either by the definitions in the compiler / platform files that get included first and then by the override file.

You won't need to define all the rules in the override file just the ones you care to change.  Also not all of the rules that get defined applies to all of generators (such as CMAKE_C_COMPILE_OBJECT as already mentioned).

A good example to follow is Modules/Compiler/TI-C.cmake to change a "-o" to something else.  From TI-C.cmake:
set(CMAKE_C_COMPILE_OBJECT  "<CMAKE_C_COMPILER> --compile_only --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<OBJECT>")

Then as suggested the override file could be the basis of a new compiler file that gets submitted upstream.

--
F

--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: modify cmake build arguments

fdk17


On Thu, 2019-08-29 at 18:27 +0100, hex wrote:
> hello community,

> CMake builds a C project with gcc -o target_name. I have a compiler
> very similar to GCC and I am trying configure CMake C language for
> it.

> The compiler does not support the -o argument when linking objects. I
> wonder if there is a way to remove or modify this argument, maybe
> through one of the properties on targets?

> thank you

Your best bet would be to modify the CMake source code to support your
compiler. (Upstreaming your changes would be welcome.)

As a matter of interest, what does it use instead of -o?

Kyle


For linking objects it would be overriding CMAKE_C_LINK_EXECUTABLE:

For example from the TI-C.cmake file:
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET>.map <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>")

--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Hex
Reply | Threaded
Open this post in threaded view
|

Re: modify cmake build arguments

Hex
thank you this is exactly what I am looking for. It is working well.

From the documentation:

«It is loaded after CMake’s builtin compiler and platform information
modules have been loaded but before the information is used.»

since CMakeCInformation.cmake:

# compile a C file into an object file
if(NOT CMAKE_C_COMPILE_OBJECT)
  set(CMAKE_C_COMPILE_OBJECT
    "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o    -c <SOURCE>")
endif()


CMAKE_USER_MAKE_RULES_OVERRIDE_C must be set before the language is set,
i.e. before any `enable_language()` or `project()` instruction.



--
Sent from: http://cmake.3232098.n2.nabble.com/
--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Hex
Reply | Threaded
Open this post in threaded view
|

Re: modify cmake build arguments

Hex
I am still facing a problem: The build step is skipped only the link
step is performed (I missed that in the beginning). It seems like the
build step does not have any dependencies.


This is because different file extension are used. I cannot set
CMAKE_C_SOURCE_FILE_EXTENSIONS because I believe `project` redefines the
variable. If I set it afterwards it does not take effect. For now it
works if I change the source file extension.

--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Hex
Reply | Threaded
Open this post in threaded view
|

Re: modify cmake build arguments

Hex

It does work after setting CMAKE_C_SOURCE_FILE_EXTENSIONS inside the override. It should be set in a CMakeDetermineCompiler file though. I'll add language support for it next.


As a side note, wouldn't it be better to replace

CMake/Modules/CMakeCCompiler.cmake.in:

set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)


with:

list(APPEND CMAKE_C_SOURCE_FILE_EXTENSIONS c;m )

?


On 30/08/2019 12:41, hex wrote:
I am still facing a problem: The build step is skipped only the link step is performed (I missed that in the beginning). It seems like the build step does not have any dependencies.


This is because different file extension are used. I cannot set CMAKE_C_SOURCE_FILE_EXTENSIONS because I believe `project` redefines the variable. If I set it afterwards it does not take effect. For now it works if I change the source file extension.


--

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

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