我正在尝试更改flatbuffers 库CMakeLists.txt 以使 PUBLIC 一些标志。然后,我重写了这些行:
原始代码
elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra")
endif()
新代码
elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_compile_definitions(flatbuffers PUBLIC "-std=c++0x -Wall -pedantic -Werror -Wextra")
endif()
目标名称是flatc,当我开始构建项目时,我收到以下信息:
Scanning dependencies of target flatc
[ 7%] Building CXX object CMakeFiles/flatc.dir/src/idl_parser.cpp.obj
<command-line>:0:1: error: macro names must be identifiers
使用这些标志将“set(CMAKE_CXX_FLAGS)”转换为“target_compile_definitions()”是错误的吗?