0

I use CMake 3.10. Previously I've used 3.5. According manual i can use $ to get some path to output file. In fact anything isn't printed.

Status is "-- lib_location == $" I looked into examples of

But if I use next construction, it works well.

add_custom_target(
  testTartgetFile ALL
  COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:tgt1>"
  VERBATIM
)

The question is how to get target object? I need it for further handling, not for print out.

My code:

cmake_minimum_required(VERSION 3.0)

project(libtest_project)

function(add_txbundle)
    set(options NONE)
    set(oneValueArgs TARGET)
    set(multiValueArgs EXTRA_MAPPINGS  DEPENDENCIES)
    set(txPrefix "TxBundle")
    cmake_parse_arguments(${txPrefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    message(status " TARGET ${${txPrefix}_TARGET}")
    message(status " EXTRA_MAPPINS ${TxBundle_EXTRA_MAPPINGS}")

    set(TxBundleTarget "${${txPrefix}_TARGET}.txbundle")
    set(TxParentTarget "${${txPrefix}_TARGET}")

    message(status " TX TARGET ${TxBundleTarget}")
    #..... some actions ...

endfunction(add_txbundle)

add_library(testlb SHARED testlib.cpp)
message (STATUS "lib_location == $<TARGET_FILE:testlb>")    
add_txbundle(TARGET testlb EXTRA_MAPPINGS "1:1")
Tuxford
  • 1
  • 1
  • 1
  • `$` is not a variable reference, but a [generator expression](https://cmake.org/cmake/help/v3.11/manual/cmake-generator-expressions.7.html). These expressions are allowed only in specific options, which are described explicitely in CMake documentation for the commands. Otherwise, you [cannot get a value](https://stackoverflow.com/questions/51353110/how-do-i-output-the-result-of-a-generator-expression-in-cmake) of such expression. – Tsyvarev Mar 10 '19 at 18:12
  • In single-configuration CMake generators, like `Makefile`, you may "construct" absolute path to the output library file using following [target properties](https://cmake.org/cmake/help/v3.11/manual/cmake-properties.7.html): `LIBRARY_OUTPUT_DIRECTORY`, `PREFIX`, `OUTPUT_NAME`, `SUFFIX`. (The first property assumes you doesn't build the project on Windows). – Tsyvarev Mar 10 '19 at 18:16

0 Answers0