如何从CMake获取目标安装位置?
我想为我的CMake构建创建一个“安装后”脚本,但为此,我需要给定目标的安装位置 例如:如何从CMake获取目标安装位置?,cmake,Cmake,我想为我的CMake构建创建一个“安装后”脚本,但为此,我需要给定目标的安装位置 例如: 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
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.
这可以打印:
-- Target install location is /usr/local/lib/libA.so
我已经尝试过(使用
$
),但结果是生成树中的位置,而不是安装树中的位置(即它打印/home/me/project/build/libA.so
)。负责安装路径的变量是CMAKE\u install\u PREFIX,请尝试,其默认值应为/usr/local/是,CMAKE_INSTALL_前缀是答案的一部分。但我还需要CMAKE_INSTALL_前缀后面的路径,目标目录,例如,lib
,bin
,等等。。。我使用的框架将我的一些目标存储在我想检索的${CMAKE_PREFIX_PATH}/lib/framework-${SOMEVAR}/plugins
中。例如,CMAKE_INSTALL_BIN-BIN文件夹。但是,如果您安装在特定的目录中,您必须提前手动将这些路径保存到变量。