-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (73 loc) · 2.38 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
##A template for a package containing multiple projects, in this case: Hello and Bye.
PROJECT(Words)
set(PROJECT_VERSION_MAJOR 1)
set(PROJECT_VERSION_MINOR 1)
############################################################
## Versioning/installation information
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
set(PROJECT_DIRNAME "${PROJECT_NAME}-${PROJECT_VERSION}")
set(PROJECT_DIRNAME_lib "lib/${PROJECT_DIRNAME}")
set(PROJECT_DIRNAME_include "include/${PROJECT_DIRNAME}")
############################################################
add_library(Hello SHARED Hello/Hello.cpp )
add_library(Bye STATIC Bye/Bye.cpp )
##List of libraries in the project
set(PROJECT_LIBRARIES
Hello
Bye)
##Installation target for Headers for the libraries.
install(
FILES
Hello/Hello.h
DESTINATION
${PROJECT_DIRNAME_include}/Hello
)
install(
FILES
Bye/Bye.h
DESTINATION
${PROJECT_DIRNAME_include}/Bye
)
##Installation target for the Libraries exported from this package.
install(
TARGETS
Bye
Hello
DESTINATION
${PROJECT_DIRNAME_lib}
EXPORT
${PROJECT_NAME}Exports
)
install(
EXPORT
${PROJECT_NAME}Exports
DESTINATION
${PROJECT_DIRNAME_lib}
)
############################################################
##Config file configurations. PROJECT_DIRNAME_include will be made relocatable.
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${PROJECT_DIRNAME_lib}
PATH_VARS
PROJECT_DIRNAME_include
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
############################################################
##Installation target for the COnfig files configured in the previous step.
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION
${PROJECT_DIRNAME_lib}
)
############################################################