我正在尝试在CLion上创建一个简单的项目.它使用CMake(我是新来的)生成Makefile来构建项目(或某种类型)
我需要的是每次运行我的代码时将一些非项目文件(某种资源文件)传输到二进制目录.
该文件包含测试数据,应用程序将其打开以读取它们.我尝试了几种方法:
通过 file(COPY ...
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/input.txt
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/input.txt
Run Code Online (Sandbox Code Playgroud)
看起来很好,但它只工作一次,而不是下次运行后重新复制文件.
通过 add_custom_command
OUTPUT 版
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/input.txt
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/input.txt
${CMAKE_CURRENT_BINARY_DIR}/input.txt)
Run Code Online (Sandbox Code Playgroud)TARGET 版
add_custom_target(foo)
add_custom_command(
TARGET foo
COMMAND ${CMAKE_COMMAND} copy
${CMAKE_CURRENT_BINARY_DIR}/test/input.txt
${CMAKE_SOURCE_DIR})
Run Code Online (Sandbox Code Playgroud)但没有人工作.
我究竟做错了什么?
我正在尝试开发一个简单的chrome扩展.有一个pageAction的默认图标应该出现在具有特定URL(http://www.example.com/*)的页面上.
有两个文件
manifest.json
{
"manifest_version": 2,
"name": "name",
"description": "description",
"version": "1.0",
"background": {
"scripts": [
"background.js"
],
"persistent": false
},
"page_action": {
"default_icon" : "images/icons/19.png"
},
"permissions": [
"declarativeContent"
]
}
Run Code Online (Sandbox Code Playgroud)
background.js
chrome.runtime.onInstalled.addListener(function () {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function () {
chrome.declarativeContent.onPageChanged.addRules([
{
// rule1
conditions : [
new chrome.declarativeContent.PageStateMatcher({
pageUrl : {urlPrefix : 'http://www.example.com/'}
})
],
actions : [
new chrome.declarativeContent.ShowPageAction()
]
},
{
// rule2
conditions : [
new chrome.declarativeContent.PageStateMatcher({
pageUrl : {queryContains : 'q1=green'} …Run Code Online (Sandbox Code Playgroud)