-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add install rather than readme to release archive
- Loading branch information
1 parent
bd30fd8
commit 64b0911
Showing
3 changed files
with
184 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
# Building and Installation | ||
|
||
## Quick Start | ||
|
||
Use the provided defaults, build the library, install the library, include the library. | ||
|
||
### Build the library | ||
|
||
Use GCC to compile the library. | ||
|
||
```zsh | ||
make gcc-rel [OPTIONAL INSTALL PATH] | ||
``` | ||
|
||
Use Clang to compile the library. | ||
|
||
```zsh | ||
make clang-rel [OPTIONAL INSTALL PATH] | ||
``` | ||
|
||
### Install the library | ||
|
||
By default, this library does not touch your system paths and it is installed in the `install/` directory of this folder. This is best for testing the library out while pointing `cmake` to the install location. Then, deleting the `install/` folder deletes any trace of this library from your system. | ||
|
||
```zsh | ||
make install | ||
``` | ||
Then, in your `CMakeLists.txt`: | ||
|
||
```cmake | ||
find_package(str_view HINTS "~/path/to/str_view-v[VERSION]/install") | ||
``` | ||
|
||
If you want to simply write the following command in your `CMakeLists.txt`, | ||
|
||
```cmake | ||
find_package(str_view) | ||
``` | ||
|
||
specify that this library shall be installed to a location CMake recognizing by default. For example, my preferred location is as follows: | ||
|
||
```zsh | ||
make gcc-rel ~/.local | ||
make install | ||
``` | ||
|
||
Then the installation looks like this. | ||
|
||
```txt | ||
.local | ||
├── include | ||
│ └── str_view | ||
│ └── str_view.h | ||
└── lib | ||
├── cmake | ||
│ └── str_view | ||
│ ├── str_viewConfig.cmake | ||
│ ├── str_viewConfigVersion.cmake | ||
│ ├── str_viewTargets.cmake | ||
│ └── str_viewTargets-release.cmake | ||
└── str_view | ||
└── libstr_view_release.a | ||
``` | ||
|
||
Now to delete the library if needed, simply find all the `str_view` folders and delete them. You can also check the `build/install_manifest.txt` to confirm the locations of any files installed with this library. | ||
|
||
## Include the Library | ||
|
||
Once CMake can find the package, link against it and include the `str_view.h` header. | ||
|
||
The `CMakeLists.txt` file. | ||
|
||
```cmake | ||
add_executable(my_exe my_exe.c) | ||
target_link_libraries(my_exe str_view::str_view) | ||
``` | ||
|
||
The C code. | ||
|
||
```.c | ||
#include "str_view/str_view.h" | ||
``` | ||
|
||
## Alternative Builds | ||
|
||
If you do not like the default presets, create a `CMakeUserPresets.json` in this folder and place your preferred configuration in that file. Here is my preferred configuration to get you started. I like to use a newer gcc version than the default presets specify. | ||
|
||
```json | ||
{ | ||
"version": 3, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 21, | ||
"patch": 0 | ||
}, | ||
"configurePresets": [ | ||
{ | ||
"name": "gdeb", | ||
"displayName": "GMake GCC Debug", | ||
"description": "Generated by GMake with GCC base debug preset.", | ||
"generator": "Unix Makefiles", | ||
"inherits": [ | ||
"gcc-deb" | ||
], | ||
"cacheVariables": { | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON", | ||
"CMAKE_C_STANDARD": "11", | ||
"CMAKE_C_COMPILER": "gcc-12", | ||
"CMAKE_BUILD_TYPE": "Debug", | ||
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/build/deb", | ||
"CMAKE_C_FLAGS": | ||
"-g3 -Wall -Wextra -Wfloat-equal -Wtype-limits -Wpointer-arith -Wshadow -Winit-self -fno-diagnostics-show-option -Wno-nonnull-compare -Wno-pointer-bool-conversion" | ||
} | ||
}, | ||
{ | ||
"name": "grel", | ||
"displayName": "GMake GCC Release", | ||
"description": "Generated by GMake with GCC base release preset.", | ||
"generator": "Unix Makefiles", | ||
"inherits": [ | ||
"gcc-rel" | ||
], | ||
"cacheVariables": { | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON", | ||
"CMAKE_C_STANDARD": "11", | ||
"CMAKE_C_COMPILER": "gcc-12", | ||
"CMAKE_BUILD_TYPE": "Release", | ||
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/build/rel", | ||
"CMAKE_C_FLAGS": | ||
"-Wall -Wextra -Wfloat-equal -Wtype-limits -Wpointer-arith -Wshadow -Winit-self -fno-diagnostics-show-option -Wno-nonnull-compare -Wno-pointer-bool-conversion" | ||
} | ||
}, | ||
{ | ||
"name": "cdeb", | ||
"displayName": "Ninja clang Debug", | ||
"description": "Generated by Ninja with clang base debug preset.", | ||
"generator": "Ninja", | ||
"inherits": [ | ||
"clang-deb" | ||
], | ||
"cacheVariables": { | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON", | ||
"CMAKE_C_STANDARD": "11", | ||
"CMAKE_C_COMPILER": "clang", | ||
"CMAKE_BUILD_TYPE": "Debug", | ||
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/build/deb", | ||
"CMAKE_C_FLAGS": | ||
"-g3 -Wall -Wextra -Wfloat-equal -Wtype-limits -Wpointer-arith -Wshadow -Winit-self -fno-diagnostics-show-option -Wno-pointer-bool-conversion" | ||
} | ||
}, | ||
{ | ||
"name": "crel", | ||
"displayName": "Ninja clang Release", | ||
"description": "Generated by Ninja with clang base release preset.", | ||
"generator": "Ninja", | ||
"inherits": [ | ||
"clang-rel" | ||
], | ||
"cacheVariables": { | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON", | ||
"CMAKE_C_STANDARD": "11", | ||
"CMAKE_C_COMPILER": "clang", | ||
"CMAKE_BUILD_TYPE": "Release", | ||
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/build/rel", | ||
"CMAKE_C_FLAGS": | ||
"-Wall -Wextra -Wfloat-equal -Wtype-limits -Wpointer-arith -Wshadow -Winit-self -fno-diagnostics-show-option -Wno-pointer-bool-conversion" | ||
} | ||
} | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters