-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
64 lines (51 loc) · 1.71 KB
/
CMakeLists.txt
File metadata and controls
64 lines (51 loc) · 1.71 KB
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
# You should always specify a range with the newest
# and oldest tested versions of CMake.
cmake_minimum_required(VERSION 3.14...3.19)
# This is your project statement. You should always list languages;
project(
SunSpecModBus
VERSION 1.0
LANGUAGES CXX)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Find external packages for project
include(FetchContent)
FetchContent_Declare(
sunspec
GIT_REPOSITORY https://github.com/sunspec/models.git
GIT_TAG master
)
FetchContent_MakeAvailable(sunspec)
# This is a hack to have the program have access to the xml files.
# This should be packaged up with the static library, but I just
# couldn't figure out how to do that.
file(COPY ${sunspec_SOURCE_DIR}/smdx DESTINATION ${CMAKE_SOURCE_DIR})
file(COPY ${sunspec_SOURCE_DIRS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
# Find preinstall packages
find_package (Boost REQUIRED)
find_package (PkgConfig REQUIRED)
pkg_check_modules(modbus REQUIRED)
add_subdirectory(src)
# include CMakePackageConfigHelpers macro
include(CMakePackageConfigHelpers)
# set version
set(version 3.4.1)
# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/SunSpecModBus.cmake"
VERSION "${version}"
COMPATIBILITY AnyNewerVersion
)
# create config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/SunSpecModBus.cmake"
INSTALL_DESTINATION lib/cmake
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# install config files
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/SunSpecModBus.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/SunSpecModBus.cmake"
DESTINATION lib/cmake
)