Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add library refinements #9

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ A short introduction to C++. The examples build on top of each other. A special

## Useful Weblinks

### C++

- [C++ Reference](https://en.cppreference.com/)
- This is a carefully crafted encyclopedia of C++ features with examples
- The first stop for any question
- [Matt Godbolt's Compiler Explorer](https://godbolt.org/)
- An online compiler tester
- Use for testing small C++ code snippets

### CMake

- [Craig Scott: "Professional CMake"](https://crascit.com/professional-cmake/)
- The one and only book you need about build systems
- [HSF - More Modern CMake](https://hsf-training.github.io/hsf-training-cmake-webpage/index.html)
- [Building a Dual Shared and Static Library with CMake](https://alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html)

## List of Subprojects

Expand Down
11 changes: 8 additions & 3 deletions library_1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ cmake_minimum_required(VERSION 3.29)

project(library_1 VERSION 1.0.0 LANGUAGES CXX DESCRIPTION "my description")

add_library(${PROJECT_NAME} SHARED)
# This option changes the implicit behavior of CMake
# See https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html
option(BUILD_SHARED_LIBS "Build as shared library" ON)

add_library(${PROJECT_NAME})
add_library(demo::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

# add_library(MyStuff SHARED source1.cpp ...)
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION 2.0.0
SOVERSION 2
# This is for the Windows platform.

# This is for the Windows platform.
# Check Craig Scott "Professional CMake", Chapter "Shared Library Versioning"
DLL_NAME_WITH_SOVERSION TRUE
DLL_NAME_WITH_SOVERSION TRUE
)

target_sources(${PROJECT_NAME}
Expand Down
14 changes: 13 additions & 1 deletion library_1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ This example shows a minimal configuration for a C++ project yielding a library.

## Build Instructions

### Build a Static Library

```bash
mkdir build_library_1
cd build_library_1/
cmake ../library_1/
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=FALSE ../library_1
make
```

### Build a Shared Library

```bash
mkdir build_library_1
cd build_library_1/
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=TRUE ../library_1
make
```


Hint: there are more options to be considered for building stuff, see the other examples.