0

I have a main file and two classes in C++, all of which use VTK libraries.

I know how to compile one file, how should my CMakeLists look like to compile them all?

Example of the code:

Main:

#include <vtkImageData.h> #include <vtkMetaImageReader.h> #include <vtkSmartPointer.h> #include "ClassA.h" #include "ClassB.h" 

ClassA.cpp:

#include "ClassA.h" 

ClassB.cpp:

#include "ClassB.h" 

ClassA.h:

#include <vector> #include "vtkImageData.h" 

ClassB.h:

#include <vector> #include <string> #include <sstream> #include "vtkImageData.h" #include "vtkMetaImageWriter.h" 

1 Answer 1

1

Your CMakeLists.txt could look like this:

cmake_minimum_required(VERSION 2.8) PROJECT(MyProject) find_package(VTK REQUIRED) include(${VTK_USE_FILE}) add_executable(MyExecutable main.cpp ClassA.cpp ClassB.cpp) target_link_libraries(MyExecutable ${VTK_LIBRARIES}) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.