Reputation: 329
I am trying to Dumping a representation of each class's hierarchy and virtual function table layout of my c++ program to a file. I managed to do it with success when I compiled it from a command line with this option:
g++ -fdump-class-hierarchy main.cpp
My problem now is when I tried to make it with cmake I failed. The option -fdump-class-hierarchy was never used.Here is my CmakeList.txt
cmake_minimum_required(VERSION 3.10.2)
project(VTable)
set(CMAKE_CXX_STANDARD 14)
find_path(GCC_PATH g++.exe)
message("GCC_PATH = ${GCC_PATH}")
set(CMAKE_CXX_COMPILER "${GCC_PATH}/g++")
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unused-variable -fdump-class-hierarchy")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
add_executable(VTable main.cpp Grandparent.cpp Parent1.cpp Parent2.cpp Child.cpp)
Can someone help me to get the dump file output from the CmakeList.txt.By the way, does anyone knows any way to dump only my class code
Here is the the problem output
"C:\Program Files\JetBrains\CLion 2018.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" "path"
GCC_PATH = C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin
-- Configuring done
-- Generating done
-- Build files have been written to: path/cmake-build-debug
Problems were encountered while collecting compiler information:
cc1plus.exe: error: unrecognized command line option '-fdump-class-hierarchy'
[Finished]
I'am using CLion IDE
Upvotes: 2
Views: 2650
Reputation: 61550
Your CLion/CMake build invokes the mingw-w64 port of GCC g++
8.1. The C++ compiler optiion -fdump-class-hierarchy
was available in GCC 7.x and earlier but
removed in GCC 8.x. That is why:
cc1plus.exe: error: unrecognized command line option '-fdump-class-hierarchy'
in your CLion build. If the console commandline:
g++ -fdump-class-hierarchy main.cpp
succeeded then it invoked a different and earlier version of g++
from a different
GCC installation - perhaps discovered earlier in your PATH
than C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.exe
,
or perhaps discovered on a different computer (since you do not state that it was
the same one on which your CLion build fails).
Upvotes: 2