-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
50 lines (41 loc) · 884 Bytes
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
cmake_minimum_required(VERSION 3.10)
project(cpp-static-dynamic-linking CXX)
# Compile as C++17.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(simplecalc_static STATIC
simplecalc.cpp
)
add_library(simplecalc_dynamic SHARED
simplecalc.cpp
)
add_library(simplestr_static STATIC
simplestr.cpp
)
add_library(simplestr_dynamic SHARED
simplestr.cpp
)
# Use static linking
add_executable(main_cmake_static_exe
main.cpp
)
target_link_libraries(main_cmake_static_exe
simplecalc_static
simplestr_static
)
# Use dynamic linking
add_executable(main_cmake_dynamic_exe
main.cpp
)
target_link_libraries(main_cmake_dynamic_exe
simplecalc_dynamic
simplestr_dynamic
)
# Use mixed linking
add_executable(main_cmake_mix_exe
main.cpp
)
target_link_libraries(main_cmake_mix_exe
simplecalc_static
simplestr_dynamic
)