Question summary.
I have a project A that I build using CMake, which compiles cleanly.
However, when I pull A into another project B using CMake's ExternalProject_Add command, compilation fails when it reaches the point of building A.
The kind of errors I get.
Compiling B gives errors like this one
warning: rvalue references are a C++11 extension [-Wc++11-extensions]
when it starts compiling A (which again, is brought in by ExternalProject_Add).
Note that -std=c++11
is set in all involved CMakeList.txt files.
Note that I am also pulling a google project using ExternalProject_Add, but it does not cause any problems.
Some specifics from the CMakeLists.txt files involved.
The following excerpt is from A's CMakeLists.txt:
# Use the C++11 standard.
set (CC_FLAGS "-std=c++11")
# Figure out the warning flags to use.
CHECK_CXX_COMPILER_FLAG("-pedantic-errors" SUPPORTS_PEDANTIC_ERRORS)
CHECK_CXX_COMPILER_FLAG("-Wall" SUPPORTS_WALL)
CHECK_CXX_COMPILER_FLAG("-Wextra" SUPPORTS_WEXTRA)
if (SUPPORTS_PEDANTIC)
set (CC_FLAGS "${CC_FLAGS} -pedantic")
endif()
# [omitted]... similarly for the rest of the flags.
set (CMAKE_CXX_FLAGS_RELEASE "-O3 ${CC_FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g ${CC_FLAGS}")
The following is from B's CMakeLists.txt. The part that differs comes after the asterisks (*).
# Use the C++11 standard.
set (CC_FLAGS "-std=c++11")
# Figure out the warning flags to use.
CHECK_CXX_COMPILER_FLAG("-pedantic-errors" SUPPORTS_PEDANTIC_ERRORS)
CHECK_CXX_COMPILER_FLAG("-Wall" SUPPORTS_WALL)
CHECK_CXX_COMPILER_FLAG("-Wextra" SUPPORTS_WEXTRA)
if (SUPPORTS_PEDANTIC)
set (CC_FLAGS "${CC_FLAGS} -pedantic")
endif()
# [omitted]... similarly for the rest of the flags.
set (CMAKE_CXX_FLAGS_RELEASE "-O3 ${CC_FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g ${CC_FLAGS}")
# ************* DIFFERS HERE ************
ExternalProject_Add (
projectA
PREFIX "${projectA_prefix}"
GIT_REPOSITORY "[omitted]"
INSTALL_COMMAND ""
)
ExternalProject_Add (
google_benchmark
PREFIX "${GoogleBenchmarkPrefix}"
GIT_REPOSITORY "https://github.com/google/benchmark.git"
UPDATE_COMMAND ""
BUILD_COMMAND make benchmark
INSTALL_COMMAND ""
)
-std=c++11
set when built viaExternalProject_Add
. Probably, in that case the project has other build type than RELEASE or DEBUG. You may check that by output build type in the project A. – Rotgut