我的CMake代码如下所示:
macro(macro_name target_name)
add_custom_command(TARGET ${target_name}
POST_BUILD
COMMAND MyCommand)
endmacro()
运行这个程序,我会得到以下消息:
CMake Warning (dev) at ... (add_custom_command):
Policy CMP0040 is not set: The target in the TARGET signature of
add_custom_command() m
我能从CMake macro中间回来吗?下面是我想到的一个用例。
macro (my_macro a b c)
if (NOT USE_${a})
# I WANT TO RETURN FROM HERE.
endif ()
if (NOT USE_${b})
# I WANT TO RETURN FROM HERE.
endif ()
# Do something to c...
endmacro()
我经常遇到这个问题:
[idf@localhost EasyCL]$ mkdir build
[idf@localhost EasyCL]$ cd build/
[idf@localhost build]$ cmake ..
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 7.2.1
-- Check for working C compiler: /usr/bin/g++
-- Check for working C compiler: /usr/bin/g++ --
我使用CMake在C中进行编码,我想在一个单独的文件中定义sobre预处理器宏。这样做的目的是为我的应用程序提供一个主配置文件。
我正在修改类似于内核.config文件的操作,但是我没有找到如何将带有定义的文件传递给编译器。我知道gcc的-D选项是定义一个宏,但它不接受文件作为输入。我也知道ADD_DEFINITIONS的CMake实用工具,但它的用法,但它也是预期将用于一定数量的宏,而不是一个文件。
总之,我想用宏定义来定义一个文件.config:
CONFIG_MACRO_A=y
CONFIG_MACRO_B=y
# CONFIG_MACRO_C is not set
CONFIG_MAC
我正在尝试配置使用bcl2fastq的CMake程序。我找到了触发此错误消息的行。
file:bcl2fastq/src/cmake/cxxConfigure.cmake
############## content ####################
..... # ignoring many lines
bcl2fastq_find_header_or_die(HAVE_SYS_STAT_H sys/stat.h)
......# more lines following
错误信息:
-- time.h found as /usr/include/time.h
-- unistd.
我试着制作PCL示例项目。我用cmake来构建。但是cmake给出了如下错误
Could NOT find Boost
CMake Error at C:/Program Files/PCL 1.5.1/cmake/PCLConfig.cmake:38 (message):
common is required but boost was not found
Call Stack (most recent call first):
C:/Program Files/PCL 1.5.1/cmake/PCLConfig.cmake:346 (pcl_report_not_found)
我正在通过进行工作,并与相关的进行交叉检查,而且还停留在步骤4上。
这些说明将这些行添加到顶级CMakeLists.txt文件中:
# does this system provide the log and exp functions?
include (CheckFunctionExists)
check_function_exists (log HAVE_LOG)
check_function_exists (exp HAVE_EXP)
如前所述,这是一个微不足道的测试,因为地球上几乎每个系统都有log和exp。但失败了。生成Makefile时,我看到
-- Looking for lo
CMake允许像这样屏蔽任何函数
function(add_executable)
#...custom code, that may use _add_executable(${ARGN}) to call the original function
endfunction()
但似乎一旦CMake解析了该函数定义,它就不支持在全局CMake作用域和函数定义的嵌套中设置:
function(echo)
message(STATUS "Original function")
endfunction()
echo() #Original function
func
我正在尝试构建/编译一些Boost Local_functions。
我有一个CMakeLists.txt文件,它为我希望从Python中访问的C++函数构建了一个库,但是我还需要定义一些BOOST_LOCAL_FUNCTIONS,但是当我尝试将它们添加到我的构建中时,我得到了以下错误
In file included from /usr/include/boost/preprocessor /seq/cat.hpp:18:0,
from /usr/include/boost/local_function/aux_/symbol.hpp:12,