我有一个cmake项目,其中包含许多不同的目标。首先它构建一个用于处理一些数据文件的可执行文件(让我们调用这个DataProcessor)。然后它用可执行文件处理这些数据文件。然后,构建第二个可执行文件(我们称之为MyApp),并与处理后的数据文件一起运行。策略CMP0026未设置:禁止使用LOCATION目标属性
还有一个目标,它将所有已处理的数据文件和MyApp都捆绑到一个tar文件中,以便我们分发它们。
在我的CMakeLists.txt文件中,有我有以下行:
get_target_property(DATA_PROCESSOR_EXE DataProcessor LOCATION)
get_target_property(MY_APP_EXE MyApp LOCATION)
我需要这些在我CMakeLists文件运行各种其他命令。例如,DATA_PROCESSOR_EXE在自定义命令用于处理数据文件,就像这样:
add_custom_command(
OUTPUT ${DATA_OUT}
COMMAND ${DATA_PROCESSOR_EXE} -o ${DATA_OUT} ${DATA_IN}
DEPENDS DataProcessor)
当我捆了一切我使用MyApp的位置,以及:
# Convert executable paths to relative paths.
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" MY_APP_EXE_RELATIVE
"${MY_APP_EXE}")
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" DATA_PROCESSOR_EXE_RELATIVE
"${DATA_PROCESSOR_EXE}")
# The set of files and folders to export
set(EXPORT_FILES
assets
src/rawdata
${MY_APP_EXE_RELATIVE}
${DATA_PROCESSOR_EXE_RELATIVE})
# Create a zipped tar of all the necessary files to run the game.
add_custom_target(export
COMMAND cd ${CMAKE_SOURCE_DIR} && tar -czvf myapp.tar.gz ${EXPORT_FILES}
DEPENDS splat
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
的问题是,试图现在得到目标的位置特性将导致警告说法:
CMake Warning (dev) at CMakeLists.txt:86 (get_target_property):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "DataProcessor".
Use the target name directly with add_custom_command, or use the generator
expression $<TARGET_FILE>, as appropriate.
我不明白它是如何想我使用add_custome_command
或意味着什么由use the generator expression $<TARGET_FILE>
这似乎解决了我刚刚处理数据的第一种情况,但我无法弄清楚如何获得调用tar的相对路径,如果甚至可能的话。似乎我需要做一些字符串替换,据我所知,这是不支持的。 – Alex 2014-09-19 23:05:03