Search code examples
cmakecmake-language

How can I remove the file extension from the object name in the build step?


CMAKE_<LANG>_COMPILE_OBJECT is a variable to set compile rules.

set("<CMAKE_MY_COMPILER> <DEFINES> <INCLUDES> -o <OBJECT> -c <FLAGS> <SOURCE>")

This variable is set in CMake<LANG>Information.cmake. The source file is build and produces an object file build/hello_world.o. CMake is expecting the compiler to produce a different object name.

[ 95%] Building object CMakeFiles/hello_world.dir/src/hello_world.my.o
[100%] Linking executable hello_world
[100%] Built target hello_world

How can I remove the source file extension my from the object name in the build step?


Solution

  • Set the following variable:

    set(CMAKE_<LANG>_OUTPUT_EXTENSION_REPLACE 1)

    I set this in the file CMakeLANGInformation.cmake for a new cmake language.