-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
157 lines (128 loc) · 4.37 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#********************************************************************
# _ _ _
# _ __ | |_ _ | | __ _ | |__ ___
# | '__|| __|(_)| | / _` || '_ \ / __|
# | | | |_ _ | || (_| || |_) |\__ \
# |_| \__|(_)|_| \__,_||_.__/ |___/
#
# www.rt-labs.com
# Copyright 2019 rt-labs AB, Sweden.
#
# This software is dual-licensed under GPLv3 and a commercial
# license. See the file LICENSE.md distributed with this software for
# full license information.
#*******************************************************************/
cmake_minimum_required (VERSION 3.21)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools")
project (IOLINKMASTER VERSION 0.1.1)
# Set required standard level
set (CMAKE_C_STANDARD 11)
set (CMAKE_CXX_STANDARD 11)
# Always use standard .o suffix
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
# Default to installing in build directory
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${IOLINKMASTER_BINARY_DIR}/install
CACHE PATH "Default install path" FORCE)
endif()
# Platform configuration
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_SYSTEM_NAME}.cmake)
# Add Osal dependent on archtitecture
include(AddOsal)
include(CMakeDependentOption)
include(GetGitRevision)
# Options
option (BUILD_SHARED_LIBS "Build shared library" OFF)
option (LOG_ENABLE "Enable logging" OFF)
option (BUILD_TESTING "Build unit tests" OFF)
option (IOLINKMASTER_BUILD_DOCS "Build docs" OFF)
set(LOG_STATE_VALUES "ON;OFF")
set(LOG_LEVEL_VALUES "DEBUG;INFO;WARNING;ERROR")
Set(IOLINK_NUM_PORTS "8"
CACHE STRING "max number IO-Link ports")
Set(IOLINK_NUM_DIAG_ENTRIES "64"
CACHE STRING "max number IO-Link diagnosis entries")
Set(IOLINK_MAX_EVENTS "6"
CACHE STRING "max number IO-Link events")
set(LOG_LEVEL INFO CACHE STRING "default log level")
set_property(CACHE LOG_LEVEL PROPERTY STRINGS ${LOG_LEVEL_VALUES})
# Default to release build with debug info
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
message (STATUS "Default log level is: ${LOG_LEVEL}")
message (STATUS "Build type is: ${CMAKE_BUILD_TYPE}")
message (STATUS "Building for ${CMAKE_SYSTEM_NAME}")
# Generate version numbers
configure_file (
${IOLINKMASTER_SOURCE_DIR}/version.h.in
${IOLINKMASTER_BINARY_DIR}/include/version.h
)
# Generate config options
configure_file (
${IOLINKMASTER_SOURCE_DIR}/options.h.in
${IOLINKMASTER_BINARY_DIR}/include/options.h
)
# Source paths
add_subdirectory (src)
# Include paths
target_include_directories(iolmaster
PUBLIC
$<BUILD_INTERFACE:${IOLINKMASTER_BINARY_DIR}/include>
$<BUILD_INTERFACE:${IOLINKMASTER_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
src
)
if (BUILD_TESTING)
include(CTest)
add_subdirectory (test)
endif (BUILD_TESTING)
if (CMAKE_PROJECT_NAME STREQUAL IOLINKMASTER)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_subdirectory (samples/ifm_sample_app)
add_subdirectory (samples/irq_test)
elseif(CMAKE_SYSTEM_NAME STREQUAL "rt-kernel")
add_subdirectory (samples/ifm_sample_app)
endif ()
endif()
if (IOLINKMASTER_BUILD_DOCS)
add_subdirectory(docs)
add_custom_target(codespell
COMMAND codespell
${IOLINKMASTER_SOURCE_DIR}/docs/
${IOLINKMASTER_SOURCE_DIR}/include/
${IOLINKMASTER_SOURCE_DIR}/iol_osal/
${IOLINKMASTER_SOURCE_DIR}/samples/
${IOLINKMASTER_SOURCE_DIR}/src/
${IOLINKMASTER_SOURCE_DIR}/test/
--skip *_build*
COMMENT "Running spell check on source code"
)
endif()
install (
TARGETS
iolmaster
iolmaster_osal
EXPORT IolinkMasterConfig
)
install (
EXPORT IolinkMasterConfig
DESTINATION cmake
)
install (FILES
${IOLINKMASTER_SOURCE_DIR}/include/iolink.h
${IOLINKMASTER_SOURCE_DIR}/include/iolink_dl.h
${IOLINKMASTER_SOURCE_DIR}/include/iolink_main.h
${IOLINKMASTER_SOURCE_DIR}/include/iolink_types.h
${IOLINKMASTER_SOURCE_DIR}/include/iolink_max14819.h
${IOLINKMASTER_BINARY_DIR}/include/iolmaster_export.h
DESTINATION include)
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE "${IOLINKMASTER_SOURCE_DIR}/LICENSE.md")
set (CPACK_PACKAGE_CONTACT [email protected])
include (CPack)