我有以下 CMakeLists 文件:
#################
# Com Project #
#################
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CMAKE_MODULE_PATH /home/loay/Desktop/V5)
SET(CMAKE_CXX_FLAGS "-std=c++11")
PROJECT (Sync)
FIND_PACKAGE (OpenSplice REQUIRED)
#####################
# Modele de donnees #
#####################
SET (idls
Communication.idl
)
# Extraction des fichiers a partir du .idl
execute_process(COMMAND idlpp -S -l cpp ./Communication.idl)
FOREACH(idl ${idls})
OpenSplice_IDLGEN (${idl})
STRING (REGEX REPLACE "\(.*\).idl" "\\1.cpp" VARS_1 ${idl})
STRING (REGEX REPLACE "\(.*\).idl" "\\1.h" VARS_2 ${idl})
STRING (REGEX REPLACE "\(.*\).idl" "\\1Dcps.cpp" VARS_3 ${idl})
STRING (REGEX REPLACE "\(.*\).idl" "\\1Dcps.h" VARS_4 ${idl})
STRING (REGEX REPLACE "\(.*\).idl" "\\1Dcps_impl.cpp" VARS_5 ${idl})
STRING (REGEX REPLACE "\(.*\).idl" "\\1Dcps_impl.h" VARS_6 ${idl})
STRING (REGEX REPLACE "\(.*\).idl" "\\1SplDcps.cpp" VARS_7 ${idl})
STRING (REGEX REPLACE "\(.*\).idl" "\\1SplDcps.h" VARS_8 ${idl})
STRING (REGEX REPLACE "\(.*\).idl" "ccpp_\\1.h" VARS_9 ${idl})
SET(OpenSplice_SYNC ${OpenSplice_SYNC} ${VARS_1} ${VARS_2} ${VARS_3} ${VARS_4} ${VARS_5} ${VARS_6} ${VARS_7} ${VARS_8} ${VARS_9})
ENDFOREACH(idl)
###########################
# Fichiers de code source #
###########################
SET (APP_SOURCES
arduino.cpp
Controller.cpp
CheckStatus.cpp
Controller.cpp
ListenerReader.cpp
main.cpp
Publisher.cpp
Subscriber.cpp
rs232.c
)
# Inclure dossier des sources des librairies a linker
INCLUDE_DIRECTORIES(
${OpenSplice_INCLUDE_DIRS}
)
# Inclure dossier des binaires des librairies a linker
link_directories (
${LIBRARY_OUTPUT_PATH}
)
#############################
# Construction des binaires #
#############################
SET (APP_EXE start)
SET (SYNC Sync)
ADD_EXECUTABLE (${APP_EXE} ${APP_SOURCES})
ADD_LIBRARY (${SYNC} SHARED ${OpenSplice_SYNC})
ADD_DEFINITIONS (
${OpenSplice_DEFINITIONS}
${DEFINITIONS}
)
TARGET_LINK_LIBRARIES (${SYNC}
${OpenSplice_LIBRARIES}
)
TARGET_LINK_LIBRARIES (${APP_EXE}
${OpenSplice_LIBRARIES}
${SYNC}
)
如您所见,我添加了此行SET(CMAKE_CXX_FLAGS "-std=c++11")
以启用对 ISO c ++ 2011 的支持。我运行此命令cmake . -G "Unix Makefiles"
来生成我需要的文件并生成makefile。
问题是,当我运行make
命令时,它失败并出现以下错误:
错误:#error此文件需要ISO C ++ 2011标准的编译器和库支持。此支持目前是实验性的,必须使用-std = c ++ 11或-std = gnu ++ 11编译器选项启用。
这是因为我确实包含了旗帜。让事情变得更奇怪的是,当我重新运行cmake . -G "Unix Makefiles"
时,这个问题就解决了,我能够构建我的文件而没有错误!
这个问题的原因是什么?
答案 0 :(得分:3)
可能它被覆盖在其他地方,因为这个CMake文件不是PrismTech的官方文件。将该命令更改为:
=Sumproduct((Data!M5:M6000="")*(Today()-Data!L5:L6000))
并将其放在cmake文件的末尾。
答案 1 :(得分:2)
在project()
调用之前或之后设置编译器标志时存在差异。
在 project()
之前设置标记时,通常会重新定义默认值:
set(CMAKE_CXX_FLAGS_INIT "<new-value>" CACHE STRING
"Flags used by the compiler during all build types.")
# ... some other assignments may be here ...
project(<project-name>)
该变量的 注意 _INIT
后缀:project()
调用的实际上已初始化, CMAKE_CXX_FLAGS_INIT 为它们提供默认值。
在 project()
之后设置标记时,通常会追加到默认或用户提供的标记
project(<project-name>)
# ...
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} <additional-value>")