@@ -18,25 +18,42 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
18
18
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake/tools" )
19
19
project (PROFINET VERSION 0.1.0 )
20
20
21
- include (AddOsal )
22
- include (GenerateExportHeader )
23
- include (CMakeDependentOption )
24
-
21
+ # Default settings if this is the main project
25
22
if (CMAKE_PROJECT_NAME STREQUAL PROFINET )
26
23
include (CTest )
24
+
25
+ # Make option visible in ccmake, cmake-gui
26
+ option (BUILD_SHARED_LIBS "Build shared library" OFF )
27
+
28
+ # Default to release build with debug info
29
+ if (NOT CMAKE_BUILD_TYPE )
30
+ set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
31
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
32
+ FORCE )
33
+ endif (NOT CMAKE_BUILD_TYPE )
34
+
35
+ # Default to installing in build directory
36
+ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
37
+ set (CMAKE_INSTALL_PREFIX ${PROFINET_BINARY_DIR} /install
38
+ CACHE PATH "Default install path" FORCE )
39
+ endif ()
40
+
41
+ message (STATUS "Current build type is: ${CMAKE_BUILD_TYPE} " )
42
+ message (STATUS "Current install path is: ${CMAKE_INSTALL_PREFIX} " )
43
+ message (STATUS "Building for ${CMAKE_SYSTEM_NAME} " )
27
44
endif ()
28
45
29
- # Set required standard level
30
- set (CMAKE_C_STANDARD 99 )
31
- set (CMAKE_CXX_STANDARD 11 )
46
+ include (AddOsal )
47
+ include (GenerateExportHeader )
48
+ include (CMakeDependentOption )
49
+ include (GetGitRevision )
32
50
33
51
# Always use standard .o suffix
34
52
set (CMAKE_C_OUTPUT_EXTENSION_REPLACE 1 )
35
53
set (CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1 )
36
54
37
55
# Options. See options.h.in for more information.
38
56
39
- option (BUILD_SHARED_LIBS "Build shared library" OFF )
40
57
option (PNET_OPTION_FAST_STARTUP "" ON )
41
58
option (PNET_OPTION_PARAMETER_SERVER "" ON )
42
59
option (PNET_OPTION_IR "" ON )
@@ -137,30 +154,7 @@ set_property(CACHE PF_PNAL_LOG PROPERTY STRINGS ${LOG_STATE_VALUES})
137
154
set (PNET_LOG ON CACHE STRING "PNET log" )
138
155
set_property (CACHE PNET_LOG PROPERTY STRINGS ${LOG_STATE_VALUES} )
139
156
140
- # Default to release build with debug info
141
- if (NOT CMAKE_BUILD_TYPE )
142
- set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
143
- "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
144
- FORCE )
145
- endif (NOT CMAKE_BUILD_TYPE )
146
- message (STATUS "Current build type is: ${CMAKE_BUILD_TYPE} " )
147
-
148
- # Default to installing in build directory
149
- if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
150
- set (CMAKE_INSTALL_PREFIX ${PROFINET_BINARY_DIR} /install
151
- CACHE PATH "Default install path" FORCE )
152
- endif ()
153
- message (STATUS "Current install path is: ${CMAKE_INSTALL_PREFIX} " )
154
-
155
- # Get git revision if available
156
- find_package (Git QUIET )
157
- execute_process (COMMAND
158
- "${GIT_EXECUTABLE} " describe --tags --always --dirty
159
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR} "
160
- OUTPUT_VARIABLE PNET_VERSION_GIT
161
- ERROR_QUIET
162
- OUTPUT_STRIP_TRAILING_WHITESPACE
163
- )
157
+ # Generate version numbers
164
158
configure_file (
165
159
version .h.in
166
160
${PROFINET_BINARY_DIR} /src/version.h
@@ -182,14 +176,20 @@ if (CMAKE_PROJECT_NAME STREQUAL PROFINET AND BUILD_TESTING)
182
176
endif ()
183
177
184
178
# Platform configuration
185
- include (${CMAKE_SYSTEM_NAME} )
186
- message (STATUS "Building for ${CMAKE_SYSTEM_NAME} " )
179
+ include (${CMAKE_CURRENT_SOURCE_DIR} /cmake/${CMAKE_SYSTEM_NAME}.cmake )
187
180
188
181
generate_export_header (profinet
189
182
BASE_NAME pnet
190
183
EXPORT_FILE_NAME ${PROFINET_BINARY_DIR} /include/pnet_export.h
191
184
)
192
185
186
+ set_target_properties (profinet pn_dev
187
+ PROPERTIES
188
+ C_STANDARD 99
189
+ )
190
+
191
+ target_compile_features (profinet PUBLIC c_std_99 )
192
+
193
193
target_include_directories (profinet
194
194
PUBLIC
195
195
$< BUILD_INTERFACE:${PROFINET_SOURCE_DIR} /include>
0 commit comments