0

How can i add variable to the linker command? I need to add a path where libraries are located. This path may change and should be configured:

Toolchain File (OSLIBS_DIR is defines is as a cli argument in cmake call)

set(OSLIBS_DIR ${OSLIBS_DIR} CACHE PATH "Specify the path to OS_Libs")
set(CMAKE_EXE_LINKER_FLAGS "-L${OSLIBS_DIR}/libs" CACHE INTERNAL "" FORCE)
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>"

But the compiler checks result in:

Linking C executable cmTC_543b2.vxe

gcc.exe -L/libs "CMakeFiles/cmTC_543b2.dir/testCCompiler.c.obj" -o cmTC_543b2.elf

${OSLIBS_DIR} is expanded empty.

Btw: Is there any documentation what this <brackets> mean in the CMake language?

kuga
  • 1,483
  • 1
  • 17
  • 38
  • `` things are called "generator expressions". https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html – arrowd Aug 04 '17 at 07:56
  • `${OSLIBS_DIR} is expanded empty.` - According to toolchain file, this variable is actually empty. Unless you have specified it in `cmake` call. Common pattern for user-specified variables is `set(OSLIBS_DIR "" CACHE PATH "Specify the path to OS_Libs")`. That is, no needs to assign any value to such variable. If CMake cache already have this variable defined, this statement does nothing; as intended. – Tsyvarev Aug 04 '17 at 17:09
  • @arrowd: Generator expressions use `$<...>` notation. Substitution `<...>` works for some CMake variables or parameters, and possible values are specific for such variable or parameter. – Tsyvarev Aug 04 '17 at 17:11
  • @Tsyvarev: OSLIBS_DIR is indeed defined with the as a command line argumenrt. Is there a documentation which varaibles support which substitution parameters? – kuga Aug 07 '17 at 14:53
  • As for [CMAKE__LINK_EXECUTABLE](https://cmake.org/cmake/help/v3.7/variable/CMAKE_LANG_LINK_EXECUTABLE.html) variable, all I know is this [answer](https://stackoverflow.com/a/1964191/3440745) and references from it. – Tsyvarev Aug 07 '17 at 17:43

0 Answers0