Error compiling structmember.h from Python2.7 library - c++

I'm trying to create a Cmake file to compile an old C++ proyect, but when I run the make command I have this compile error:
In file included from /home/leontes/Dropbox/Siadex_Planner_ROS/planner/src/pyAPI.cpp:23:0:
/usr/include/python2.7/structmember.h:40:5: error: ‘Py_ssize_t’ does not name a type
Py_ssize_t offset;
^
/usr/include/python2.7/structmember.h:88:24: error: expected constructor, destructor, or type conversion before ‘PyMember_Get’
PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *);
^
/usr/include/python2.7/structmember.h:89:17: error: expected constructor, destructor, or type conversion before ‘PyMember_Set’
PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *);
^
/usr/include/python2.7/structmember.h:92:24: error: expected constructor, destructor, or type conversion before ‘PyMember_GetOne’
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *);
^
/usr/include/python2.7/structmember.h:93:17: error: expected constructor, destructor, or type conversion before ‘PyMember_SetOne’
PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);
^
make[2]: *** [CMakeFiles/planner.dir/src/pyAPI.cpp.o] Error 1
make[1]: *** [CMakeFiles/planner.dir/all] Error 2
make: *** [all] Error 2
And that is a System Library from Python...
I fixed the old make what was included with the proyect and it works fine, but with the new one no.
And the Cmakelist.txt that I'm building is this:
cmake_minimum_required(VERSION 2.8.3)
project(planner)
#Set headers directory
include_directories(include ${PYTHON_INCLUDE_PATH})
#Set source files
file(GLOB SOURCES "src/*.cpp")
#Set python vars
#Compiler flags
execute_process(COMMAND python-config --cflags OUTPUT_VARIABLE PYTHON_CPPFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
#Libraries
execute_process(COMMAND python-config --libs OUTPUT_VARIABLE PYTHON_EXTRA_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
#Linker flags
execute_process(COMMAND python-config --ldflags OUTPUT_VARIABLE PYTHON_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
#Concatenate the new flags with the old ones
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${PYTHON_CPPFLAGS})
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${PYTHON_LDFLAGS})
#Define preprocessor directives for debugger.cpp
if(EXISTS /usr/include/readline.h)
add_definitions(-DHAVE_LIBREADLINE)
add_definitions(-DHAVE_READLINE_H)
endif(EXISTS /usr/include/readline.h)
if(EXISTS /usr/include/readline/readline.h)
add_definitions(-DHAVE_LIBREADLINE)
add_definitions(-DHAVE_READLINE_READLINE_H)
endif(EXISTS /usr/include/readline/readline.h)
if(EXISTS /usr/include/history.h)
add_definitions(-DHAVE_READLINE_HISTORY)
add_definitions(-DHAVE_HISTORY_H)
endif(EXISTS /usr/include/history.h)
if(EXISTS /usr/include/readline/history.h)
add_definitions(-DHAVE_READLINE_HISTORY)
add_definitions(-DHAVE_READLINE_HISTORY_H)
endif(EXISTS /usr/include/readline/history.h)
#Define preprocessor directives for stacknode.cpp
add_definitions(-DUSE_AC3)
#add_definitions(-DUSE_PC2)
#add_definitions(-DUSE_PC2_CL)
#Add a binary executable
add_executable(planner nodes/planner.cpp ${SOURCES})
#And link it
target_link_libraries(planner python2.7 readline ${PYTHON_EXTRA_LIBS})
I'm missing something??
EDIT:
Command used to compile in the old 'make'
g++ -DHAVE_CONFIG_H -I. -I../.. -Wall -Iheaders -I../xmlrpc/headers -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7 -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -DPYTHON_FOUND -DWITH_XMLRPC -g -O2 -DBUFFER_STACK -MT sources/pyAPI.o -MD -MP -MF $depbase.Tpo -c -o sources/pyAPI.o sources/pyAPI.cpp &&\
Command used to compile in the new 'make'
/usr/bin/c++ -DHAVE_LIBREADLINE -DHAVE_READLINE_HISTORY -DHAVE_READLINE_HISTORY_H -DHAVE_READLINE_READLINE_H -DUSE_PC2_CL -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7 -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/home/leontes/Dropbox/Siadex_Planner_ROS/planner/include -I/usr/include/python2.7 -o CMakeFiles/planner.dir/src/pyAPI.cpp.o -c /home/leontes/Dropbox/Siadex_Planner_ROS/planner/src/pyAPI.cpp

Related

clang-tidy with precompiled headers and cmake does not work

I have a simple setup where CMake produces the following compile command:
cd /workspaces/cmake-general/tests/project/build/examples/hello-world && /usr/local/bin/cmake -E __run_co_compile
--iwyu=/usr/local/bin/include-what-you-use
--tidy="/usr/bin/clang-tidy;-extra-arg=-Wno-unknown-warning-option;-warnings-as-errors=*;--extra-arg-before=--driver-mode=g++"
--source=/workspaces/cmake-general/tests/project/build/examples/hello-world/CMakeFiles/example-hello-world.dir/cmake_pch.hxx.cxx --
/usr/bin/c++
-I/workspaces/cmake-general/tests/project/examples/hello-world/src
-I/workspaces/cmake-general/tests/project/build -O3 -DNDEBUG -stdlib=libc++
-fcolor-diagnostics -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion
-Wsign-conversion -Wnull-dereference -Wdouble-promotion
-Wformat=2 -Werror -std=c++20 -Winvalid-pch -fpch-instantiate-templates
-Xclang -emit-pch -Xclang -include
-Xclang /workspaces/cmake-general/tests/project/build/examples/hello-world/CMakeFiles/example-hello-world.dir/cmake_pch.hxx
-x c++-header -MD -MT examples/hello-world/CMakeFiles/example-hello-world.dir/cmake_pch.hxx.pch -MF
CMakeFiles/example-hello-world.dir/cmake_pch.hxx.pch.d -o CMakeFiles/example-hello-world.dir/cmake_pch.hxx.pch
-c /workspaces/cmake-general/tests/project/build/examples/hello-world/CMakeFiles/example-hello-world.dir/cmake_pch.hxx.cxx
which errors our with not finding
/workspaces/cmake-general/tests/project/build/examples/example-sanitizer/CMakeFiles/example-sanitizer-address.dir/cmake_pch.hxx:5:10: error: 'iostream' file not found [clang-diagnostic-error]
#include <iostream>
^
3 errors generated.
When I take --tidy="..." stuff out of the command. It fully compiles, (also if I dont specify PCHs in the CMakeLists.txt) it works.
I am not sure what the problem is exactly.
Do PCH and clang-tidy somehow not work? Why are the include directories somehow missing? I am using LLVM-12, clang-12 on Ubuntu.
Also adding -I/usr/lib/llvm-12/include/c++/v1 does not help.

While building DRAMPower command "make -j4" gives error UBUNTU

I want to build DRAMPower for GEM5 and it gives error when i run the command "make -j4"
Downloaded DRAMPower.zip and then after unzipping it running the make command
The Error which is get is:
g++ -O -W -pedantic-errors -Wextra -Werror -Wformat -Wformat-
nonliteral -Wpointer-arith -Wcast-align -Wconversion -Wall -Werror -g
-std=c++0x -MMD -MF src/TraceParser.d -iquote src -o src/TraceParser.o
-c src/TraceParser.cc
g++ -O -W -pedantic-errors -Wextra -Werror -Wformat -Wformat-
nonliteral -Wpointer-arith -Wcast-align -Wall -Werror -g -std=c++0x
-MMD -MF src/CmdScheduler.d -iquote src -o src/CmdScheduler.o -c
src/CmdScheduler.cc
g++ -O -W -pedantic-errors -Wextra -Werror -Wformat -Wformat-
nonliteral -Wpointer-arith -Wcast-align -Wconversion -Wall -Werror -g
-std=c++0x -MMD -MF src/cli/drampower.d -iquote src -o
src/cli/drampower.o -c src/cli/drampower.cc
g++ -O -W -pedantic-errors -Wextra -Werror -Wformat -Wformat-
nonliteral -Wpointer-arith -Wcast-align -Wconversion -Wall -Werror -g
-std=c++0x -MMD -MF src/libdrampower/LibDRAMPower.d -iquote src -o
src/libdrampower/LibDRAMPower.o -c src/libdrampower/LibDRAMPower.cc
In file included from src/CommandAnalysis.h:55:0, from
src/TraceParser.h:46,
from src/TraceParser.cc:37:
src/Utils.h:49:1: error: dynamic exception specifications are
deprecated in C++11 [-Werror=deprecated]
throw(std::runtime_error)
In file included from src/CommandAnalysis.h:55:0,
from src/libdrampower/LibDRAMPower.h:48,
from src/libdrampower/LibDRAMPower.cc:42:
src/Utils.h:49:1: error: dynamic exception specifications are
deprecated in C++11 [-Werror=deprecated]
throw(std::runtime_error)
src/Utils.h:49:1: error: dynamic exception specifications are
deprecated in C++11 [-Werror=deprecated]
throw(std::runtime_error)
cc1plus: all warnings being treated as errors
Makefile:106: recipe for target 'src/libdrampower/LibDRAMPower.o'
failed
make: *** [src/libdrampower/LibDRAMPower.o] Error 1
make: *** Waiting for unfinished jobs....
cc1plus: all warnings being treated as errors
Makefile:106: recipe for target 'src/cli/drampower.o' failed
make: *** [src/cli/drampower.o] Error 1
cc1plus: all warnings being treated as errors
Makefile:106: recipe for target 'src/TraceParser.o' failed
make: *** [src/TraceParser.o] Error 1
cc1plus: all warnings being treated as errors
Makefile:102: recipe for target 'src/CmdScheduler.o' failed
make: *** [src/CmdScheduler.o] Error 1

CMAKE thrift generated files compiler options

I'm trying to compile generated thrift code into my source. The thrift stuff is generated into CMAKE_CURRENT_BINARY_DIR then I add generated cpp files into my library, with SET_SOURCE_FILES_PROPERTIES(${ThriftGeneratedFiles} PROPERTIES
GENERATED 1
COMPILE_OPTIONS ""
)
Then I add the include path to generated files using TARGET_INCLUDE_DIRECTORIES with SYSTEM keyword. When I'm trying to compile it, since my module compiles with -Wsuggest-override it fails to compile the generated cpp file with can be marked override [-Werror=suggest-override]. I dont get why, isnt the SET_SOURCE_FILES_PROPERTIES should solve this problem?CMake file snippet
ADD_COMPILE_OPTIONS(
...
...
-Wsuggest-override
...
...
)
FIND_PROGRAM(THRIFT_COMPILER thrift ${_VCPKG_ROOT_DIR}/buildtrees/thrift/x64-linux-rel/compiler/cpp/bin/ NO_DEFAULT_PATH)
SET(ThriftOutputDir ${CMAKE_CURRENT_BINARY_DIR}/thrift/gen/)
FILE(MAKE_DIRECTORY ${ThriftOutputDir})
SET(ThriftGeneratedFiles
${ThriftOutputDir}/MyServer.cpp
${ThriftOutputDir}/My_types.cpp
${ThriftOutputDir}/My_constants.cpp
)
ADD_CUSTOM_COMMAND(
OUTPUT
generated.timestamp
COMMAND
${THRIFT_COMPILER} --gen cpp:no_default_operators -out ${ThriftOutputDir} ${CMAKE_SOURCE_DIR}/protocols/My.thrift
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}
COMMENT "Generating source code from Thrift definition")
ADD_CUSTOM_TARGET(RunThriftCompiler
DEPENDS
generated.timestamp
COMMENT "Checking if re-generation is required")
ADD_LIBRARY(MyProject SHARED
${SOURCES}
${ThriftGeneratedFiles}
)
SET_SOURCE_FILES_PROPERTIES(${ThriftGeneratedFiles} PROPERTIES
GENERATED 1
COMPILE_OPTIONS ""
)
TARGET_INCLUDE_DIRECTORIES(MyProject SYSTEM PRIVATE
${PROTOBUF_INCLUDE_DIR}
${ThriftOutputDir}
)
Compilation message:
cd
/home/user/Development/Project/Project16/cmake-build-debug/lib/MyProject
&& /usr/bin/c++ -DCARES_STATICLIB -DMyProject_EXPORTS
-I/home/user/Development/Project/Project16/lib/include/MyProject -I/home/user/Development/Project/Project16/lib/include -isystem /home/user/Development/Project/Project16/cmake-build-debug/ext/etcd
-isystem /home/user/Development/Project/Project16/cmake-build-debug/protocols
-isystem /home/user/Development/Project/Project16/ext/spdk/include -isystem /home/user/Development/vcpkg/installed/x64-linux/include -isystem /home/user/Development/Project/Project16/cmake-build-debug/lib/MyProject/thrift/gen
-g -fPIC -include MyProject.h -fPIC -fstrict-aliasing -ffunction-sections -fno-omit-frame-pointer -mtune=core-avx-i -mavx -march=core-avx-i -fno-plt -g -fstack-protector-all -fstack-check -rdynamic -Wno-error=unused-parameter -Wno-error=unused -Wno-error=unused-but-set-parameter -Wshadow -Werror=address -Werror=array-bounds -Werror=char-subscripts -Werror=enum-compare -Werror=implicit-int -Werror=implicit-function-declaration -Werror=comment -Werror=format -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-sign -Werror=reorder -Werror=return-type -Werror=sequence-point -Wstrict-aliasing=1 -Werror=strict-overflow=1 -Werror=switch -Werror=trigraphs -Werror=uninitialized -Werror=unknown-pragmas -Wunused-function -Wunused-label -Wunused-value -Werror=volatile-register-var -Werror=clobbered -Werror=empty-body -Werror=ignored-qualifiers -Werror=sign-compare -Werror=type-limits -Werror -Wempty-body -Wuninitialized -Winit-self -Wmissing-declarations -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wtype-limits -Waddress -Wmisleading-indentation -Wshift-negative-value -Wtautological-compare -Wnull-dereference -Wduplicated-cond -Wnonnull -Wnonnull-compare -Wignored-qualifiers -Wmissing-braces -Wmissing-include-dirs -Wparentheses -Wsequence-point -Wno-return-local-addr -Wreturn-type -Wtrigraphs -Wunused-local-typedefs -Winvalid-memory-model -Wmaybe-uninitialized -Wunknown-pragmas -Wframe-address -Wtrampolines -Wfloat-equal -Wno-free-nonheap-object -Wold-style-cast -Wunused-parameter -Wunused -Wunused-but-set-parameter -Wframe-larger-than=1100000 -Wpointer-arith -Wwrite-strings -Wclobbered -Wenum-compare -Wsizeof-pointer-memaccess -Wmemset-transposed-args -Wlogical-op -Wredundant-decls -Winvalid-pch -Wvarargs -Wvector-operation-performance -Wvolatile-register-var -Wdisabled-optimization -Wcast-align -Wcast-qual -Wnon-virtual-dtor -Woverloaded-virtual -Wodr -Wplacement-new=2 -Wdelete-incomplete -Wsized-deallocation -Wno-virtual-move-assign -Wsuggest-override -DBOOST_COROUTINES_NO_DEPRECATION_WARNING -DGTEST_LINKED_AS_SHARED_LIBRARY -D_GNU_SOURCE -DIGNORE_VALIDATION= -std=gnu++1z -o CMakeFiles/MyProject.dir/thrift/gen/MyProject_constants.cpp.o -c
/home/user/Development/Project/Project16/cmake-build-debug/lib/MyProject/thrift/gen/MyProject_constants.cpp
In file included from
/home/user/Development/Project/Project16/cmake-build-debug/lib/MyProject/thrift/gen/MyProject_types.cpp:7:0:
/home/user/Development/Project/Project16/cmake-build-debug/lib/MyProject/thrift/gen/MyProject_types.h:72:15:
error: ‘virtual const char* MyProject::ThriftCapiException::what()
const’ can be marked override [-Werror=suggest-override] const
char* what() const throw();
As seen, all compilation flags are applied.
Properties on source files like COMPILE_DEFINITIONS and COMPILE_FLAGS may only add a compile option. Using these properties it is impossible to overwrite (delete) compile options for the target. (And options added by ADD_COMPILE_OPTIONS are eventually assigned for the target).
You may create an OBJECT library from thrift-generated sources. For that library you may set (that is, clear) COMPILE_OPTIONS property. Resulted object files can be used then in your main library:
# Object files for thrift-generated sources
add_library(thriftGenerated OBJECT ${ThriftGeneratedFiles})
# For these files clear compile options which has been set before
set_property(TARGET thriftGenerated PROPERTY COMPILE_OPTIONS)
# Then use object files for thrift-generated sources in other library
add_library(MyProject SHARED
${SOURCES}
$<TARGET_OBJECTS:thriftGenerated>
)

Cannot get Makefile to use g++ instead of clang++ on Mac OS

I'm trying to compile a C++ library on Mac OS which compiles on Linux. (This is done via installing an R package via a Makevars file, see: https://cran.r-project.org/doc/manuals/r-release/R-exts.html) On Linux, I see the following when I do make:
g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/ -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=c++11 -I/usr/share/R/include -DNDEBUG -I../inst/include/ -I"/usr/lib/R/site-library/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c packagename.cpp -o packagename.o
g++ -std=c++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o packagename.so RcppExports.o packagename.o -llib1 -llib2 -llib3 -L/usr/lib/R/lib -lR
installing to /home/username/R/x86_64-pc-linux-gnu-library/3.2/packagename/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (packagename)
When doing this with Mac OS, I notice it's using clang++ instead, which appears to cause errors:
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c packagename.cpp -o packagename.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c rcpp_hello_world.cpp -o rcpp_hello_world.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o packagename.so RcppExports.o packagename.o rcpp_hello_world.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/packagename/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘packagename’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/packagename/libs/packagename.so':
Error: loading failed
Execution halted
ERROR: loading failed
How do I specify in the Makefile to use g++ and not clang++?
I have tried CXX=g++ but this doesn't appear to work.

Creating Xcode project from Cmake contains unwanted compiler flags

I've been unable to find a definitive answer, so apologies if the answer is out there.
I use cmake to generate project files as I tend to work cross-platform. On OSX/Xcode, I'm seeing unwanted compiler flags being used, specifically warning enable/disable. I like to compile with as many warnings on as possible, and set warnings as errors.
Consider the following:
File: CMakeLists.txt
cmake_minimum_required( VERSION 3.0 )
project( test )
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++14 )
add_compile_options( "-Werror" )
add_compile_options( "-Weverything" )
add_compile_options( "-Wno-c++98-compat-pedantic" )
add_compile_options( "-Wno-padded" )
add_executable( Test main.cpp )
target_link_libraries( Test libstdc++.dylib libc++.dylib )
File: main.cpp
#include <iostream>
int main( int argc, char * const argv[] )
{
(void)argc;
(void)argv;
std::cout << "Kittens." << std::endl;
return 0;
}
If I then run cmake:
cmake -G Xcode .
(normally I'd use a builds directory, but not here for simplicity).
Then build (from the command line):
cmake --build . --config Debug --target ALL_BUILD
The simple sample will compile. If I now look at the command used to compile main.cpp I see the following:
CompileC test.build/Debug/Test.build/Objects-normal/x86_64/main.o main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/username/Development/test
export LANG=en_US.US-ASCII
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=101 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DCMAKE_INTDIR=\"Debug\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.11 -g -Wno-sign-conversion -I/Users/username/Development/test/Debug/include -I/Users/username/Development/test/test.build/Debug/Test.build/DerivedSources/x86_64 -I/Users/username/Development/test/test.build/Debug/Test.build/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -F/Users/username/Development/test/Debug -std=c++14 -Werror -Weverything -Wno-c++98-compat-pedantic -Wno-padded -MMD -MT dependencies -MF /Users/username/Development/test/test.build/Debug/Test.build/Objects-normal/x86_64/main.d --serialize-diagnostics /Users/username/Development/test/test.build/Debug/Test.build/Objects-normal/x86_64/main.dia -c /Users/username/Development/test/main.cpp -o /Users/username/Development/test/test.build/Debug/Test.build/Objects-normal/x86_64/main.o
The really annoying thing here is any of the -W options.
In my CMakeLists.txt I've clearly said I want all warnings, warnings treated as errors, and whitelisted a couple of warnings.
However, if I strip out all the -W options in the compile command, I see (in addition to what I asked for):
-Wno-trigraphs
-Wno-missing-field-initializers
-Wno-missing-prototypes
-Wno-return-type
-Wno-non-virtual-dtor
-Wno-overloaded-virtual
-Wno-exit-time-destructors
-Wno-missing-braces
-Wparentheses
-Wswitch
-Wno-unused-function
-Wno-unused-label
-Wno-unused-parameter
-Wno-unused-variable
-Wunused-value
-Wno-empty-body
-Wno-uninitialized
-Wno-unknown-pragmas
-Wno-shadow
-Wno-four-char-constants
-Wno-conversion
-Wno-constant-conversion
-Wno-int-conversion
-Wno-bool-conversion
-Wno-enum-conversion
-Wno-shorten-64-to-32
-Wno-newline-eof
-Wno-c++11-extensions
-Winvalid-offsetof
-Wno-sign-conversion
-Wmost
-Wno-four-char-constants
-Wno-unknown-pragmas
Some of those things listed I really do not want disabled. I really want just the -W options I specified in the cmake file being used for compilation, but I can't see who is injecting all these extra things and from where.
Is there any way I can get cmake to tell xcode not to include all these extra -W options from compilation?
Note: using:
cmake 3.5.2
Apple LLVM version 7.3.0 (clang-703.0.31)
At project() call, CMake detects compiler (you may see corresponded messages when cmake is executed) and sets default flags for it. These flags are stored in variables CMAKE_CXX_FLAGS (common) and CMAKE_CXX_FLAGS_<CONFIG> (configuration-specific).
You may modify these variables as you want:
1) completely rewrite them
set(CMAKE_CXX_FLAGS "<desired-value>")
2) append new flags to them
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} <additional-flags>")
3) remove specific values from them
string(REPLACE "<unwanted-flag>" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# or
string(REGEX REPLACE "<unwanted-flag-regex>" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
and so on.