-
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.
- Loading branch information
1 parent
241cf4b
commit a1bed76
Showing
40 changed files
with
243 additions
and
48 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
|
||
## Create simple executable | ||
|
||
Exercise: | ||
|
||
Comment out the first line (cmake_minimum_required) and execute `./run.sh` |
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 |
---|---|---|
@@ -1,2 +1,16 @@ | ||
|
||
## Create simple executable and configure it as a test via ctest | ||
|
||
Exercise: | ||
|
||
Add to run.sh | ||
|
||
``` | ||
export CXX=ccg | ||
``` | ||
|
||
or to cmake command | ||
|
||
``` | ||
-DCMAKE_CXX_COMPILER=ccg | ||
``` |
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
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 |
---|---|---|
@@ -1,2 +1,17 @@ | ||
|
||
## Create static library and link it to executable | ||
|
||
Scope keywords | ||
|
||
PRIVATE - Only used for target | ||
INTERFACE - Only used for targets that consume this target | ||
PUBLIC - Both | ||
|
||
https://cmake.org/cmake/help/latest/command/target_link_libraries.html#command:target_link_libraries | ||
|
||
|
||
Exercise: try add in `src/CMakeLists.txt` | ||
|
||
``` | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE ABC=1 INTERFACE XYZ=2) | ||
``` |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
project(project_library) | ||
|
||
cmake_minimum_required (VERSION 3.18) | ||
|
||
set(SOURCE_CPP src.cpp) | ||
|
||
add_library(${PROJECT_NAME} STATIC ${SOURCE_CPP} ${SOURCE_INC}) | ||
project(project_library) | ||
|
||
add_library(${PROJECT_NAME} STATIC src.cpp) | ||
# target_compile_definitions(${PROJECT_NAME} PRIVATE ABC=1 INTERFACE XYZ=2) |
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
project(project_library) | ||
|
||
cmake_minimum_required (VERSION 3.18) | ||
|
||
set(SOURCE_CPP src.cpp) | ||
|
||
add_library(${PROJECT_NAME} SHARED ${SOURCE_CPP} ${SOURCE_INC}) | ||
project(project_library) | ||
|
||
add_library(${PROJECT_NAME} SHARED src.cpp) |
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
cmake_minimum_required (VERSION 3.18) | ||
|
||
project(project_library) | ||
|
||
set(SOURCE_CPP src.cpp) | ||
|
||
add_library(${PROJECT_NAME} STATIC ${SOURCE_CPP} ${SOURCE_INC}) | ||
add_library(${PROJECT_NAME} STATIC src.cpp) | ||
|
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
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
cmake_minimum_required (VERSION 3.18) | ||
|
||
project(project_library) | ||
|
||
|
||
set(SOURCE_CPP src.cpp) | ||
|
||
add_library(${PROJECT_NAME} STATIC ${SOURCE_CPP} ${SOURCE_INC}) | ||
add_library(${PROJECT_NAME} STATIC src.cpp) | ||
|
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
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
cmake_minimum_required (VERSION 3.18) | ||
|
||
project(project_library) | ||
|
||
|
||
set(SOURCE_CPP src.cpp) | ||
|
||
add_library(${PROJECT_NAME} STATIC ${SOURCE_CPP} ${SOURCE_INC}) | ||
add_library(${PROJECT_NAME} STATIC src.cpp) | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
project(project_library) | ||
cmake_minimum_required (VERSION 3.18) | ||
|
||
project(project_library) | ||
|
||
set(SOURCE_CPP src.cpp) | ||
|
||
add_library(${PROJECT_NAME} STATIC ${SOURCE_CPP} ${SOURCE_INC}) | ||
add_library(${PROJECT_NAME} STATIC src.cpp) | ||
|
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
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,24 @@ | ||
{ | ||
"version": 3, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 19, | ||
"patch": 0 | ||
}, | ||
"configurePresets": [ | ||
{ | ||
"name": "default", | ||
"description": "Base preset for library developers", | ||
"binaryDir": "${sourceDir}/build" | ||
}, | ||
{ | ||
"name": "dev-werror", | ||
"description": "Linux preset for library developers", | ||
"hidden": false, | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wsign-conversion -Wcast-align -Wcast-qual -Wnull-dereference -Woverloaded-virtual -Wformat=2 -Werror" | ||
} | ||
} | ||
] | ||
} |
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
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 @@ | ||
.run.sh.* |
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,10 @@ | ||
cmake_minimum_required (VERSION 3.18) | ||
project(linkage) | ||
|
||
SET(CMAKE_SKIP_RPATH FALSE) | ||
|
||
add_subdirectory(lib1) | ||
add_subdirectory(lib2) | ||
|
||
add_executable(${PROJECT_NAME} main.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE lib2) |
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,6 @@ | ||
|
||
|
||
# Multi library link chain visibility | ||
|
||
Here we will demonstrate how private shared linking works. | ||
And how it can minimize project configuration complexity |
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,5 @@ | ||
project(lib1) | ||
|
||
|
||
add_library(${PROJECT_NAME} SHARED src/src.cpp inc/lib1.hpp) | ||
target_include_directories( ${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) |
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,10 @@ | ||
#ifndef _LIB1_NS_INC_HPP_ | ||
#define _LIB1_NS_INC_HPP_ | ||
|
||
namespace lib1_ns{ | ||
|
||
void func(); | ||
|
||
} | ||
|
||
#endif /*_LIB1_NS_INC_HPP_*/ |
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,11 @@ | ||
|
||
#include "lib1.hpp" | ||
|
||
#include <iostream> | ||
|
||
namespace lib1_ns{ | ||
|
||
void func(){ std::cout << __FILE__ << " " << __LINE__ << std::endl; } | ||
|
||
} | ||
|
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,7 @@ | ||
project(lib2) | ||
|
||
|
||
add_library(${PROJECT_NAME} SHARED src/src.cpp inc/lib2.hpp) | ||
target_include_directories( ${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) | ||
|
||
target_link_libraries(${PROJECT_NAME} PRIVATE lib1) |
Oops, something went wrong.