SomeLibraryName/
|
|--- src/
| |--- main.cpp
| |--- main.hpp # add aditional files here
|--- include/
| |--- SomeLibraryname.hpp #The main library file you will ship.
|--- CMakeLists.txt
|--- README.md #recommended, not mandatory
PLEASE refrain from declaring any logic in the include/SomeLibraryname.h
, just declare method name, parameters, and return type.
Your logic for the methods declared in include/SomeLibraryname.h
, should be in src/main.cpp
, you can also use src/main.hpp
to add logic
mkdir build && cd build
After running the above command now, run
cmake ..
This will run CMake to build the debug version of library.
To package the library into library headers
cmake --build . --target install
You will get something like this
../install/
├── cmake
│ ├── SomeLibraryConfig-debug.cmake
│ ├── SomeLibraryConfig-release.cmake
│ └── SomeLibraryConfig.cmake
├── include
│ └── PhyC
│ └── PhyC.hpp
└── lib64
└── libPhyC.a
4 directories, 6 files
The libPhyCd.a is static library file
Use cmake -DCMAKE_BUILD_TYPE={DEBUG or RELEASE} ..
to change between release and debug mode
After the generating install
folder, zip the folder and ship it.
For more Configurations , Please Refer this blog