CMAKE_C_OUTPUT_EXTENSION does not work when doing add_library(${component_name} OBJECT ${SOURCES})
When I create a new OBJECT library with add_library(${component_name} OBJECT ${SOURCES})
it will successfully compile all sources that come in. What also works is set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
. Instead of .c.obj, the extension is only .obj.
BUT when using
set(CMAKE_C_OUTPUT_EXTENSION .o)
It will still remain as .obj, not .o.
The replacement was tried before project() definition and after. Doing it after project definition usually works when using add_Executable and passing source files directly, but not with
add_executable(elf)
add_library(mylib OBJECT ${SOURCES})
target_link_libraries(elf mylib)
Is there any other option for OBJECT libs to change the extension setting, or is it a bug or intended by some reason?
Edited by Matthias Eggert