-1

How set CMAKE_STATIC_LINKER_FLAGS in CMakeLists.txt immediately after the executable file?

for example: I need:

tcc.exe-arqc staticRun.lib CMakeFiles/staticRun.dir/utils/system.c.obj

but cmake after this settings:

set (CMAKE_AR C:/run/code/toolchains/c++/MinGW-tcc/bin/tcc.exe CACHE FILEPATH "" FORCE)

set (CMAKE_STATIC_LINKER_FLAGS -ar CACHE STRING "" FORCE)

add -ar key like this:

tcc.exe qc staticRun.lib CMakeFiles/staticRun.dir/utils/system.c.obj-ar

so, building the static library failed.

P.S.

tcc.exe -ar - mean

Tools: create library : tcc -ar [rcsv] lib.a files

ilw
  • 2,499
  • 5
  • 30
  • 54

1 Answers1

2

The simplest is just to change the line that is used to run the static library with your custom semantics:

set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -ar qc <TARGET> <LINK_FLAGS> <OBJECTS>")
KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • 1
    because https://github.com/Kitware/CMake/blob/4b266927c7556f74d11d6f499360d682117e0a60/Modules/CMakeCInformation.cmake#L159 – ilw Jun 12 '20 at 08:09