I want to have my own little library and collect any useful code that I manage to write in the future. My idea is to have it structured like lib-boost and whenever I start a new project, I also use this library if necessary. Lets call this "lib-ezpz"
I also want it to be modular that is every category has its own lib file (e.g. libEzPzFileIO.lib for file stuff and LibEzPzMath.lib for math stuff.
Here is my folder structure:
The problems that I am looking for answers for:
- After building the project, only the compiled library end up in build folder but I also need to ship the HEADERs as well. Like on Linux or windows when one says make install and then the lib and header files get copied into /usr/lib or something
- I want to have a good folder structure in the output too...also every library should end up in its own subdirectory... but at the moment cmake just drops everything in the root folder of build dir
- My HEADER ONLY math template library compiles fine but there are NO resulting library ending up in the build directory
And here are file contents:
fileio/parser.h
#pragma once
#include <iostream>
#include <vector>
namespace EzPz::FileIO::Parser {
std::vector<std::vector<std::string>> parseCsvFile();
}
fileio/parser.cpp
#include "parser.h"
namespace EzPz::FileIO::Parser {
std::vector<std::vector<std::string>> parseCsvFile() {
return {
{"line one", "haha", "hoho"},
{"line two", "hihi", "weewee"}
};
}
}
math/basicops.h
#pragma once
namespace EzPz::Math::BasicOperations {
template<typename T>
T addValues(const T& lhs, const T& rhs) {
return (lhs + rhs);
}
}
** And here is the CMAKE file **
cmake_minimum_required(VERSION 3.0)
project(EzPz)
set(CMAKE_CXX_STANDARD 17)
# Library for FILE IO Oeprations
add_library(EzPzFileIo fileio/parser.cpp)
# Library for MATH stuff (header only)
add_library(EzPzMath STATIC math/basicops.h)
set_target_properties(EzPzMath PROPERTIES LINKER_LANGUAGE CXX)
target_compile_definitions(EzPzMath PRIVATE "haha")