- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在转换 boost-build
构建系统到 cmake。
boost-build 的一个特性是您可以指定一个路径到一个 Jamfile
(相当于一个 CMakeLists.txt
文件)和指定的所有目标将在其中 build 。
例如,具有以下项目结构:
root
|
+--- foo
| |
| +--- test
|
+--- bar
| |
| +--- test
|
+--- app
如果输入以下命令:
$ b2 foo
root/foo
下的Jamfile
将被执行,导致foo
库被构建,test
正在构建和运行测试
这是一个使用 boost-build
的简单构建配置:
Jamroot
:
using gcc ;
project proj : requirements
<link>static
<include>.
;
build-project foo ;
foo/Jamfile
:
lib foo : [ glob *.cpp ] ;
build-project test ;
foo/test/Jamfile
:
import testing ;
unit-test foo-tests
: [ glob *.cpp ]
..//foo
;
你会注意到在 foo 的 Jamfile
中有一个指令 build-project test
这意味着如果我键入 b2 foo
然后 lib/Jamfile
中的所有内容都将被执行,导致 foo
和 foo/test
正在构建中。
此外,在 Jamroot
中有一个指令 build-project foo
这意味着如果我只输入 b2
那么 Jamroot
中的所有内容都会被执行,导致 foo
和 foo/test
正在构建中。
因此很容易构建整个项目并获得构建的所有源和所有测试。
构建只是一个子目录并只获取它的源代码和测试构建也很容易。
我正试图复制这种行为。
root/CMakeLists.txt
:
cmake_minimum_required(VERSION 3.2.2)
project(proj CXX)
add_subdirectory(foo)
foo/CMakeLists.txt
:
file(GLOB src "*.cpp")
add_library(foo STATIC ${src})
add_subdirectory(test)
foo/test/CMakeLists.txt
:
file(GLOB src "*.cpp")
add_executable(foo_test ${src})
add_test(foo_test foo_test foo)
# run tests if foo_test.passed is missing or outdated
add_custom_command(
OUTPUT foo_test.passed
COMMAND foo_test
COMMAND ${CMAKE_COMMAND} -E touch foo_test.passed
DEPENDS foo_test
)
# make tests run as part of ALL target
add_custom_target(run_foo_test
ALL
DEPENDS foo_test.passed)
上面的 CMakeLists.txt
结构允许我make
并同时构建了 foo
和 foo_test
。
但是,如果我指定make foo
,只有 foo
会被构建,但是foo_test
不会是,测试将不会运行。
问题:
make foo
时构建 foo/CMakeLists.txt
中的所有内容?foo_test.passed
构建为更新目标 foo
的一部分 AND 构建为 ALL
目标?最佳答案
这是一个实现要求的实现。
它有点复杂,因为它需要几个虚假目标和依赖链。
第 1 步:
ALL
,以便将其构建为全局构建过程的一部分foo/CMakeLists.txt
:
# create a phony target which all 'foo' related items will be added to
add_custom_target(foo
ALL
)
第 2 步:
libfoo
:
foo
重命名为 libfoo
,因为我们现在已将 foo
用于我们之前的假目标。 liblibfoo.a
,这有点难看)foo/CMakeLists.txt
:
add_library(libfoo STATIC ${src})
# add libfoo as a dependency of foo, so 'make foo' will build libfoo
add_dependencies(foo
libfoo)
foo_test
:
让测试作为构建的一部分自动运行有点复杂。
你必须:
custom_command
来运行测试并在测试通过时生成一个哨兵文件 (foo_test.passed
)custom_target
(foo_test.run
) 依赖于哨兵 (foo_test.passed
)foo
和foo_test.run
之间添加依赖关系>foo_test/CMakeLists.txt
:
add_executable (foo_test main.cpp)
target_link_libraries(foo_test libfoo ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
# create foo_test.passed command which generates the sentinel file when the tests pass
add_custom_command(
OUTPUT foo_test.passed
COMMAND foo_test
COMMAND ${CMAKE_COMMAND} -E touch foo_test.passed
DEPENDS foo_test
)
# create foo_test.run target which depends on foo_test.passed
add_custom_target(foo_test.run
DEPENDS foo_test.passed
)
# add foo_test.run as a dependency of foo, so 'make foo' will build foo_test.run
add_dependencies(foo
foo_test.run
)
因此,目标 foo
具有 libfoo
和 foo_test.run
作为依赖项。
因此,make
和 make foo
都构建了 libfoo
并构建并运行了 foo_test
(通过 foo_test.run
和 foo_test.passed
)
感知笨拙:
foo
-> foo_test.run
-> foo_test.passed
-> foo_test
依赖链。
在 boost-build
中,您可以将库命名为 foo
而不会导致 foo
虚假目标与 foo
库(b2 foo
构建了 foo
库及其测试)
但是,它有效,并且在没有更优雅的解决方案的情况下,会给我想要的东西。
关于c++ - cmake:复制 boost-build 的 "build everything in Jamfile"行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36701286/
我正在编写一个应用程序,允许用户创建一个“问卷”,然后向其中添加问题。我正在使用核心数据来存储信息。我创建了一个问卷实体,并与问题实体建立了“一对多”关系。我的问题是,如果要允许用户复制(复制)整个调
有没有办法复制或复制 SharedPreference?或者我需要从一个变量中获取每个变量,然后将它们放入另一个变量中吗? 最佳答案 尝试这样的事情: //sp1 is the shared pref
下面的(A)和(B)有区别吗? (假设 NON ARC,如果重要的话) // --- (A) --- @interface Zoo : NSObject{} @property (copy) Dog
我正在尝试将 mysql SELECT 查询保存到文件中,如下所示: $result = mysqli_query($db,$sql); $out = fopen('tmp/csv.csv', 'w'
我需要创建一个 CVPixelBufferRef 的副本,以便能够使用副本中的值以按位方式操作原始像素缓冲区。我似乎无法使用 CVPixelBufferCreate 或 CVPixelBufferCr
我在 Source 文件夹中有一个 Active wave 录音 wave-file.wav。我需要使用新名称 wave-file-copy.wav 将此文件复制到 Destination 文件夹。
在使用 GNU Autotools 构建的项目中,我有一个脚本需要通过 make 修改以包含安装路径。这是一个小例子: configure.ac: AC_INIT(foobar, 1.0) AC_PR
我想将 SQL 的行复制到同一个表中。但是在我的表中,我有一个“文本”列。 使用此 SQL: CREATE TEMPORARY TABLE produit2 ENGINE=MEMORY SELECT
谁能给我解释一下 df2 = df1 df2 = df1.copy() df3 = df1.copy(deep=False) 我已经尝试了所有选项并执行了以下操作: df1 = pd.DataFram
Hazelcast 是否具有类似于 Ehcache 的复制? http://www.ehcache.org/generated/2.9.0/pdf/Ehcache_Replication_Guide.
我有以下拓扑。一个 Ubuntu 16.04。运行我的全局 MySQL 服务器的 Amazon AWS 上的实例。我想将此服务器用作许多本地主服务器(Windows 机器 MySQL 服务器)的从服务
使用 SQLyog,我正在测试表中是否设置了正确的值。我尝试过 SELECT type_service FROM service WHERE email='test@gmail.com' 因此,只输出
有人可以提供一些关于如何配置 ElasticSearch 进行复制的说明。我在 Windows 中运行 ES,并且了解如果我在同一台服务器上多次运行 bat 文件,则会启动一个单独的 ES 实例,并且
一 点睛 ThreadGroup 复制线程的两个方法。 public int enumerate(Thread list[]) // 会将 ThreadGroup 中的 active 线程全部复制到
一 点睛 ThreadGroup 复制线程组的两个方法。 public int enumerate(ThreadGroup list[]) // 相对于 enumerate(list,true) pu
官方documentation Cassandra 说: Configure the keyspace and create the new datacenter: Use ALTER KEYSPAC
This question already has answers here: How to weight smoothing by arbitrary factor in ggplot2? (2个答
我们有一个表格来表明对各种俱乐部的兴趣。输出将数据记录在 Excel 电子表格中,其中列有他们的首选姓名、姓氏、电子邮件、代词,以及他们感兴趣的俱乐部的相应列中的“1”(下面的模型)。 我们希望为俱乐
This question already has answers here: Closed 8 years ago. Possible Duplicate: In vim, how do I get
如何复制形状及其所在的单元格?当我手动复制时,形状会跟随单元格,但是当我使用宏进行复制时,我会得到除形状之外的所有其他内容。 Cells(sourceRow, sourceColumn).Copy C
我是一名优秀的程序员,十分优秀!