Reputation: 3606
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"
Upvotes: 0
Views: 335
Reputation: 5229
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})
Upvotes: 1