Difference between revisions of "Including this library in your project"
From Medusa: Coordinate Free Mehless Method implementation
Line 14: | Line 14: | ||
add_executable(my_name my_name.cpp) | add_executable(my_name my_name.cpp) | ||
target_link_libraries(my_name medusa) # link to our library | target_link_libraries(my_name medusa) # link to our library | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | Next to the <code>CMakeLists.txt</code> file, you should put your source file <code>my_name.cpp</code>, | ||
+ | which can now use the Medusa library. Sample contents of the file are shown below: | ||
+ | |||
+ | <syntaxhighlight lang="cpp"> | ||
+ | #include <medusa/Medusa.hpp> | ||
+ | #include <iostream> | ||
+ | |||
+ | using namespace mm; | ||
+ | |||
+ | int main() { | ||
+ | BoxShape<Vec2d> box(0, 1); | ||
+ | std::cout << box << std::endl; | ||
+ | return 0; | ||
+ | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 08:45, 28 August 2018
Integration with our library is very simple if you are using cmake
.
Your basic CMakeLists.txt
file should look something like this:
project(your_project_name)
cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_CXX_FLAGS "-O3 -Wall -fopenmp -DNDEBUG")
add_subdirectory(${CMAKE_SOURCE_DIR}/path/to/medusa/ medusa) # add our library's CMakeLists.txt as a subfolder
include_directories(${CMAKE_SOURCE_DIR}/path/to/medusa/include/) # include medusa headers directory
# define your own executables below
add_executable(my_name my_name.cpp)
target_link_libraries(my_name medusa) # link to our library
Next to the CMakeLists.txt
file, you should put your source file my_name.cpp
,
which can now use the Medusa library. Sample contents of the file are shown below:
#include <medusa/Medusa.hpp>
#include <iostream>
using namespace mm;
int main() {
BoxShape<Vec2d> box(0, 1);
std::cout << box << std::endl;
return 0;
}