4

I would like to create a "post-install" script for my CMake build, but for this I need the install location for a given target.

For example:

function(post_install_target target)
    set(target_install_loc ???) # Somehow
    message("Target install location is ${target_install_loc}")
endfunction(post_install_target)

# ...

post_install_target(A) # Some target defined elsewhere.

This could print:

-- Target install location is /usr/local/lib/libA.so

I already tried this answer, (by using $<TARGET_FILE:tgt>) but the result is the location in the build tree, not in the install tree (i.e. it prints /home/me/project/build/libA.so).

Hugal31
  • 1,610
  • 1
  • 14
  • 27

1 Answers1

-2

The variable responsible for the installation path is CMAKE_INSTALL_PREFIX, try it, its default value should be /usr/local/ cmake documentation

Silerus
  • 36
  • 6
  • Yes, CMAKE_INSTALL_PREFIX is part of the answer. But I also need the path after the CMAKE_INSTALL_PREFIX, the DESTINATION directory, for example, `lib`, `bin`, etc... I am using a framework which store some of my targets in `${CMAKE_PREFIX_PATH}/lib/framework-${SOMEVAR}/plugins` that I would like to retreive. – Hugal31 Oct 18 '19 at 11:48
  • In this section of the documentation you will find all the minor variables used during installation. [cmake install documentations](https://cmake.org/cmake/help/latest/command/install.html#command:install). For example CMAKE_INSTALL_BIN - bin folder. But if you install in specific directories - you will have to save these paths to variables in advance and manually. – Silerus Oct 18 '19 at 12:02