Skip to content

Commit

Permalink
Merge pull request #9 from daixtrose/add-library-refinements
Browse files Browse the repository at this point in the history
Add library refinements
  • Loading branch information
daixtrose authored Jul 3, 2024
2 parents 53def92 + 46acc4f commit 572aa33
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
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.

0 comments on commit 572aa33

Please sign in to comment.