Skip to content

Commit 0f8f904

Browse files
authored
Set -DENABLE_MODERN flag to ON by default and remove it (#66)
1 parent 9e32f80 commit 0f8f904

File tree

8 files changed

+53
-98
lines changed

8 files changed

+53
-98
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
run: |
7272
mkdir build
7373
cd build
74-
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON
74+
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON
7575
make
7676
7777
- name: Perform CodeQL Analysis

CMakeLists.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ endif (WIN32)
6161

6262
set(ENABLE_QPID_PROTON ON CACHE BOOL "Enable qpid proton clients")
6363
set(ENABLE_QPID_MESSAGING ON CACHE BOOL "Enable qpid messaging clients")
64-
set(ENABLE_MODERN ON CACHE BOOL "Enable usage of refactored code")
6564
set(BUILD_WITH_UNIT_TESTS OFF CACHE BOOL "Build unit tests for the CPP client code")
6665

6766
if (NOT WIN32)
@@ -169,14 +168,6 @@ if (BUILD_WITH_UNIT_TESTS)
169168
set (CTEST_BINARY_DIRECTORY ${CMAKE_BINARY_DIR}/target/tests/bin)
170169
endif (BUILD_WITH_UNIT_TESTS)
171170

172-
if (ENABLE_MODERN)
173-
add_definitions(-DENABLE_MODERN)
174-
else (ENABLE_MODERN)
175-
if (ENABLE_QPID_PROTON)
176-
message(FATAL_ERROR "Modern code is a requirement for proton code")
177-
endif(ENABLE_QPID_PROTON)
178-
endif(ENABLE_MODERN)
179-
180171
add_subdirectory(src/contrib)
181172
add_subdirectory(src/common)
182173

@@ -194,7 +185,7 @@ set(CPPCHECK_EXECUTABLE "/usr/bin/cppcheck" CACHE STRING "Path to cppcheck")
194185
set(CPPCHECK_FLAGS "--report-progress" "-v" "--enable=all" "--xml"
195186
CACHE STRING "Options for cppcheck")
196187

197-
set(CPPCHECK_DEFS "-DENABLE_MODERN" "-DENABLE_PROTON" "-DENABLE_QPID_MESSAGING"
188+
set(CPPCHECK_DEFS "-DENABLE_PROTON" "-DENABLE_QPID_MESSAGING"
198189
"-DQPIDSYSEPOCH" CACHE STRING "Defines for cppcheck")
199190

200191
add_custom_target(check

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ sudo make install ;
3939
These variables apply to all code base and may affect what code is built with
4040
along with the project. For example, they may enable refactored code.
4141

42-
* ENABLE_MODERN: Enable new and/or refactored code. It is a requirement for -DENABLE_QPID_PROTON.
43-
Default: off
44-
4542

4643
#### Boost libraries
4744

@@ -96,7 +93,7 @@ for some older RHEL/qpid versions. Default: false.
9693
These variables affect only the QPID Proton clients.
9794

9895
* ENABLE_QPID_PROTON: Enable qpid proton messaging/reactor clients (eg.: aac3
99-
and aac4). This variable requires ENABLE_MODERN.
96+
and aac4).
10097
* PROTON_DIR: QPID Proton base directory.
10198

10299

@@ -109,14 +106,14 @@ RHEL >= 6, with QPID Proton clients, using a non-standard QPID Proton directory
109106

110107
```
111108
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
112-
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` .
109+
-DCMAKE_CXX_COMPILER=`which c++` .
113110
```
114111

115112
RHEL 5.11 without QPID Proton and disabled unit tests
116113

117114
```
118115
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
119-
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` \
116+
-DCMAKE_CXX_COMPILER=`which c++` \
120117
-DCMAKE_VERBOSE_MAKEFILE=OFF -DBUILD_WITH_UNIT_TESTS=OFF \
121118
-DQPID_WITH_GET_CONTENT_OBJECT=ON \
122119
-DBoost_INCLUDE_DIRS=/usr/include/boost141/ \
@@ -127,7 +124,7 @@ RHEL 5.11 with QPID Proton and disabled unit tests
127124

128125
```
129126
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
130-
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` `
127+
-DCMAKE_CXX_COMPILER=`which c++` `
131128
-DCMAKE_VERBOSE_MAKEFILE=OFF -DBUILD_WITH_UNIT_TESTS=OFF `
132129
-DQPID_WITH_GET_CONTENT_OBJECT=ON `
133130
-DBoost_INCLUDE_DIRS=/usr/include/boost141/ `

dist/dtests-rhel-cpp.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ C++ clients, tools and runtime libraries
3535
%build
3636

3737
%ifarch x86_64
38-
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
38+
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
3939
%else
40-
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=OFF -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
40+
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=OFF -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
4141
%endif
4242
make
4343

src/api/qpid/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ target_link_libraries(
6565
dtests-qpid-messaging-common
6666

6767
${Qpid_LIBRARIES}
68+
${ProtonCpp_LIBRARIES}
6869
dtests-cpp-legacy
6970
boost_regex # would be `Boost::regex` in new CMake
7071
${qpid_client_link_libraries}
@@ -126,11 +127,9 @@ foreach(client ${qpid_messaging_clients})
126127
endforeach(client)
127128

128129

129-
if (ENABLE_MODERN)
130-
if (BUILD_WITH_UNIT_TESTS)
131-
add_subdirectory(common/formatter/test)
132-
endif (BUILD_WITH_UNIT_TESTS)
133-
endif (ENABLE_MODERN)
130+
if (BUILD_WITH_UNIT_TESTS)
131+
add_subdirectory(common/formatter/test)
132+
endif (BUILD_WITH_UNIT_TESTS)
134133

135134

136135
install(TARGETS

src/api/qpid/common/formatter/FormatUtil.cpp

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,20 @@ namespace messaging {
77
using std::cout;
88

99
void printMessageUpstream(const Message &message, bool verbose) {
10-
#ifdef ENABLE_MODERN
11-
QpidDecoder decoder = QpidDecoder(message);
12-
13-
std::ostringstream stream;
14-
UpstreamWriter writer = UpstreamWriter(&stream);
15-
16-
UpstreamFormatter formatter = UpstreamFormatter();
17-
formatter.printMessage(&decoder, &writer);
18-
19-
writer.endLine();
20-
std::cout << writer.toString();
21-
22-
#else
23-
Formatter formatter;
24-
25-
Message tmp = const_cast<Message &>(message);
26-
27-
formatter.printMessage(tmp, verbose);
28-
#endif // ENABLE_MODERN
10+
QpidDecoder decoder = QpidDecoder(message);
11+
12+
std::ostringstream stream;
13+
UpstreamWriter writer = UpstreamWriter(&stream);
14+
15+
UpstreamFormatter formatter = UpstreamFormatter();
16+
formatter.printMessage(&decoder, &writer);
17+
18+
writer.endLine();
19+
std::cout << writer.toString();
2920
}
3021

3122

3223
void printMessageDict(const Message &message) {
33-
#ifdef ENABLE_MODERN
3424
QpidDecoder decoder = QpidDecoder(message);
3525

3626
std::ostringstream stream;
@@ -41,13 +31,6 @@ void printMessageDict(const Message &message) {
4131

4232
writer.endLine();
4333
std::cout << writer.toString();
44-
#else
45-
Formatter formatter;
46-
47-
Message tmp = const_cast<Message &>(message);
48-
49-
formatter.printMessageAsDict(tmp);
50-
#endif // ENABLE_MODERN
5134
}
5235

5336
std::string formatBool(const bool b) {
@@ -354,7 +337,6 @@ void printMessageInterop(const Message &message) {
354337
}
355338

356339
void printStatistics(const Message &message, const Variant::Map &stats) {
357-
#ifdef ENABLE_MODERN
358340
/*
359341
* NOTE: this is *not* the best way to solve this problem and I will
360342
* implement a more elegant design in the future
@@ -366,13 +348,6 @@ void printStatistics(const Message &message, const Variant::Map &stats) {
366348

367349
DictFormatter formatter = DictFormatter();
368350
formatter.printStatistics(&decoder, &writer, stats);
369-
#else
370-
Formatter formatter;
371-
372-
Variant::Map tmp = const_cast<Variant::Map &>(stats);
373-
374-
formatter.printStatistics(tmp);
375-
#endif // ENABLE_MODERN
376351
}
377352

378353
}}}

src/api/qpid/common/formatter/FormatUtil.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,13 @@
2121
#include <iostream>
2222
#include <iomanip>
2323

24-
#ifdef ENABLE_MODERN
2524
#include "formatter/DictFormatter.h"
2625
#include "formatter/DictWriter.h"
2726

2827
#include "formatter/UpstreamFormatter.h"
2928
#include "formatter/UpstreamWriter.h"
3029

3130
#include "QpidDecoder.h"
32-
#else
33-
#include "Formatter.h"
34-
#endif // ENABLE_MODERN
3531

3632
using qpid::messaging::Message;
3733
using qpid::types::Variant;

src/common/CMakeLists.txt

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,40 @@ include_directories(
1313
common/options/modern
1414
)
1515

16-
if (ENABLE_MODERN)
17-
set(COMMON_MODERN_SRC
18-
output/Printer.cpp
19-
exceptions/BaseException.cpp
20-
exceptions/IOException.cpp
21-
exceptions/TimerExpiredException.cpp
22-
options/BaseOptionsParser.cpp
23-
options/OptionsHelper.cpp
24-
formatter/Writer.cpp
25-
formatter/DictWriter.cpp
26-
formatter/UpstreamWriter.cpp
27-
formatter/AbstractDecoder.cpp
28-
formatter/AbstractFormatter.cpp
29-
formatter/DictFormatter.cpp
30-
formatter/UpstreamFormatter.cpp
31-
logger/Logger.cpp
32-
logger/LoggerWrapper.cpp
33-
34-
Timer.cpp
35-
UriParser.cpp
36-
Client.cpp
37-
ContentType.cpp
38-
MessageHeader.cpp
39-
)
16+
set(COMMON_MODERN_SRC
17+
output/Printer.cpp
18+
exceptions/BaseException.cpp
19+
exceptions/IOException.cpp
20+
exceptions/TimerExpiredException.cpp
21+
options/BaseOptionsParser.cpp
22+
options/OptionsHelper.cpp
23+
formatter/Writer.cpp
24+
formatter/DictWriter.cpp
25+
formatter/UpstreamWriter.cpp
26+
formatter/AbstractDecoder.cpp
27+
formatter/AbstractFormatter.cpp
28+
formatter/DictFormatter.cpp
29+
formatter/UpstreamFormatter.cpp
30+
logger/Logger.cpp
31+
logger/LoggerWrapper.cpp
32+
33+
Timer.cpp
34+
UriParser.cpp
35+
Client.cpp
36+
ContentType.cpp
37+
MessageHeader.cpp
38+
)
4039

41-
if (BUILD_WITH_UNIT_TESTS)
42-
set(TEST_SUPPORT_SRC
43-
TestUtils.cpp
44-
)
40+
if (BUILD_WITH_UNIT_TESTS)
41+
set(TEST_SUPPORT_SRC
42+
TestUtils.cpp
43+
)
4544

4645
add_subdirectory(test)
47-
add_subdirectory(output/test)
48-
add_subdirectory(logger/test)
49-
add_subdirectory(options/test)
50-
endif (BUILD_WITH_UNIT_TESTS)
51-
52-
endif (ENABLE_MODERN)
46+
add_subdirectory(output/test)
47+
add_subdirectory(logger/test)
48+
add_subdirectory(options/test)
49+
endif (BUILD_WITH_UNIT_TESTS)
5350

5451
add_library(dtests-cpp-common
5552
${COMMON_MODERN_SRC}

0 commit comments

Comments
 (0)