参考
实例
PATH.h.in
#ifndef PATH_H
#define PATH_H
#include <string>
static const std::string WORK_SPACE_PATH = "${WORK_SPACE_PATH}";
#endif
PATH.h
#ifndef PATH_H
#define PATH_H
#include <string>
static const std::string WORK_SPACE_PATH = "/home/jinzedong/桌面/catkin/src/create_cone";
#endif
PATH.h是由PATH.h.in自动生成的。这样WORK_SPACE_PATH变量会随着文件的具体位置不同而改变,可移植性更好。
除了编写.in文件之外,还需要在项目所在的CMakeLists.txt文件中添加下列代码
configure_file(
${PROJECT_SOURCE_DIR}/include/PATH.h.in
${PROJECT_SOURCE_DIR}/include/PATH.h
)
具体语法要求以及其他功能,请查看参考链接link。