File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66cmake_minimum_required (VERSION 3.4.1...3.17.2 )
77set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR } /CMake;${CMAKE_MODULE_PATH } " )
88
9+ # Set the default before project() initializes this cache entry.
10+ if (NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS AND
11+ NOT DEFINED ENV{CMAKE_EXPORT_COMPILE_COMMANDS })
12+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
13+ endif ()
14+
915project (ixwebsocket LANGUAGES C CXX VERSION 12.1.0)
1016
11- set (CMAKE_CXX_STANDARD 11)
12- set (CXX_STANDARD_REQUIRED ON )
13- set (CMAKE_CXX_EXTENSIONS OFF )
14- set (CMAKE_EXPORT_COMPILE_COMMANDS yes )
17+ if (NOT DEFINED CMAKE_CXX_STANDARD )
18+ set (CMAKE_CXX_STANDARD 11)
19+ endif ()
20+ if (CMAKE_CXX_STANDARD STREQUAL "98" OR CMAKE_CXX_STANDARD LESS 11)
21+ message (FATAL_ERROR "IXWebSocket requires C++11 or later" )
22+ endif ()
23+ if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED )
24+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
25+ endif ()
26+ if (NOT DEFINED CMAKE_CXX_EXTENSIONS )
27+ set (CMAKE_CXX_EXTENSIONS OFF )
28+ endif ()
1529
1630option (BUILD_DEMO OFF )
1731
Original file line number Diff line number Diff line change @@ -59,6 +59,13 @@ Autobahn protocol compliance checks run in Docker with
5959the CI check; it also runs on ` master ` and manually. See the
6060[ Autobahn instructions] ( autobahn.md ) for reports and local debugging.
6161
62+ The library defaults to C++11 and requires C++11 or later. To build with a newer
63+ standard, pass ` -DCMAKE_CXX_STANDARD=17 ` (or another supported standard). The CLI
64+ and tests inherit this choice; the test framework requires at least C++14.
65+ Caller-provided ` CMAKE_CXX_STANDARD_REQUIRED ` , ` CMAKE_CXX_EXTENSIONS ` , and
66+ ` CMAKE_EXPORT_COMPILE_COMMANDS ` settings are respected, including values inherited
67+ from a parent project using ` add_subdirectory ` .
68+
6269Options for building:
6370
6471* ` -DBUILD_SHARED_LIBS=ON ` will build the unittest as a shared libary instead of a static library, which is the default
Original file line number Diff line number Diff line change 55cmake_minimum_required (VERSION 3.14 )
66project (ixwebsocket_unittest)
77
8- set (CMAKE_CXX_STANDARD 11)
9-
108option (USE_TLS "Add TLS support" ON )
119
1210# Shared sources
@@ -119,6 +117,13 @@ foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES})
119117
120118endforeach ()
121119
120+ add_test (NAME IXWebSocketBuildSettings
121+ COMMAND ${CMAKE_COMMAND }
122+ -S ${CMAKE_CURRENT_SOURCE_DIR } /cmake/build-settings
123+ -B ${CMAKE_CURRENT_BINARY_DIR } /cmake-build-settings
124+ -G "${CMAKE_GENERATOR } " )
125+ set_tests_properties (IXWebSocketBuildSettings PROPERTIES TIMEOUT 30)
126+
122127set_tests_properties (IXWebSocketReconnectTest IXWebSocketDispatchTest IXWebSocketSendFailureTest PROPERTIES TIMEOUT 30)
123128
124129if (USE_NETWORK_FRAMEWORK OR (UNIX AND USE_TLS AND (USE_OPEN_SSL OR USE_LIBRE_SSL OR USE_MBED_TLS)))
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.14 )
2+
3+ # Normal parent variables must take precedence over defaults in the dependency.
4+ set (CMAKE_CXX_STANDARD 17)
5+ set (CMAKE_CXX_STANDARD_REQUIRED OFF )
6+ set (CMAKE_CXX_EXTENSIONS ON )
7+ set (CMAKE_EXPORT_COMPILE_COMMANDS OFF )
8+ project (ixwebsocket_build_settings LANGUAGES C CXX )
9+
10+ set (USE_TLS OFF CACHE BOOL "" )
11+ set (USE_ZLIB OFF CACHE BOOL "" )
12+ set (USE_WS ON CACHE BOOL "" )
13+ set (USE_TEST ON CACHE BOOL "" )
14+ add_subdirectory (../../.. ixwebsocket )
15+
16+ foreach (target ixwebsocket ws IXHttpTest)
17+ get_target_property (standard ${target} CXX_STANDARD)
18+ get_target_property (required ${target} CXX_STANDARD_REQUIRED)
19+ get_target_property (extensions ${target} CXX_EXTENSIONS)
20+ if (NOT standard STREQUAL "17" OR required OR NOT extensions)
21+ message (FATAL_ERROR "${target} changed the parent settings: ${standard} ;${required} ;${extensions} " )
22+ endif ()
23+ endforeach ()
24+
25+ get_target_property (library_source ixwebsocket SOURCE_DIR)
26+ get_directory_property (export_commands DIRECTORY ${library_source}
27+ DEFINITION CMAKE_EXPORT_COMPILE_COMMANDS )
28+ if (export_commands)
29+ message (FATAL_ERROR "IXWebSocket enabled compile commands despite the parent setting" )
30+ endif ()
Original file line number Diff line number Diff line change 66cmake_minimum_required (VERSION 3.14 )
77project (ws)
88
9- set (CMAKE_CXX_STANDARD 11)
10-
119option (USE_TLS "Add TLS support" ON )
1210
1311include_directories (ws . )
You can’t perform that action at this time.
0 commit comments