Skip to content

Commit bef5225

Browse files
Compile test project with source files instead of library reference (#55)
1 parent 5c499e3 commit bef5225

File tree

4 files changed

+73
-42
lines changed

4 files changed

+73
-42
lines changed

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ else()
1919
set(EXTRA_FLAGS "-DSIGNALRCLIENT_EXPORTS")
2020
endif()
2121

22-
if(USE_CPPRESTSDK)
23-
string(APPEND EXTRA_FLAGS " -DUSE_CPPRESTSDK")
24-
endif()
25-
2622
if(INJECT_HEADER_AFTER_STDAFX)
2723
string(APPEND EXTRA_FLAGS " -DINJECT_HEADER_AFTER_STDAFX=${INJECT_HEADER_AFTER_STDAFX}")
2824
endif()
@@ -45,10 +41,6 @@ endif()
4541

4642
include_directories (include)
4743

48-
# TODO: We shouldn't use this, it makes the dll/lib export all symbols
49-
# We need this for testing, but we might just add all the files to the test project manually
50-
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
51-
5244
if(USE_CPPRESTSDK)
5345
if(NOT WIN32)
5446
if(APPLE)

include/signalrclient/signalr_value.h

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#pragma once
66

7+
#include "_exports.h"
78
#include <string>
89
#include <vector>
910
#include <map>
@@ -33,152 +34,152 @@ namespace signalr
3334
/**
3435
* Create an object representing a value_type::null value.
3536
*/
36-
value();
37+
SIGNALRCLIENT_API value();
3738

3839
/**
3940
* Create an object representing a value_type::null value.
4041
*/
41-
value(std::nullptr_t);
42+
SIGNALRCLIENT_API value(std::nullptr_t);
4243

4344
/**
4445
* Create an object representing a default value for the given value_type.
4546
*/
46-
value(value_type t);
47+
SIGNALRCLIENT_API value(value_type t);
4748

4849
/**
4950
* Create an object representing a value_type::boolean with the given bool value.
5051
*/
51-
value(bool val);
52+
SIGNALRCLIENT_API value(bool val);
5253

5354
/**
5455
* Create an object representing a value_type::float64 with the given double value.
5556
*/
56-
value(double val);
57+
SIGNALRCLIENT_API value(double val);
5758

5859
/**
5960
* Create an object representing a value_type::string with the given string value.
6061
*/
61-
value(const std::string& val);
62+
SIGNALRCLIENT_API value(const std::string& val);
6263

6364
/**
6465
* Create an object representing a value_type::string with the given string value.
6566
*/
66-
value(std::string&& val);
67+
SIGNALRCLIENT_API value(std::string&& val);
6768

6869
/**
6970
* Create an object representing a value_type::string with the given string value.
7071
*/
71-
value(const char* val);
72+
SIGNALRCLIENT_API value(const char* val);
7273

7374
/**
7475
* Create an object representing a value_type::string with the given string value.
7576
*/
76-
value(const char* val, size_t length);
77+
SIGNALRCLIENT_API value(const char* val, size_t length);
7778

7879
/**
7980
* Create an object representing a value_type::array with the given vector of value's.
8081
*/
81-
value(const std::vector<value>& val);
82+
SIGNALRCLIENT_API value(const std::vector<value>& val);
8283

8384
/**
8485
* Create an object representing a value_type::array with the given vector of value's.
8586
*/
86-
value(std::vector<value>&& val);
87+
SIGNALRCLIENT_API value(std::vector<value>&& val);
8788

8889
/**
8990
* Create an object representing a value_type::map with the given map of string-value's.
9091
*/
91-
value(const std::map<std::string, value>& map);
92+
SIGNALRCLIENT_API value(const std::map<std::string, value>& map);
9293

9394
/**
9495
* Create an object representing a value_type::map with the given map of string-value's.
9596
*/
96-
value(std::map<std::string, value>&& map);
97+
SIGNALRCLIENT_API value(std::map<std::string, value>&& map);
9798

9899
/**
99100
* Copies an existing value.
100101
*/
101-
value(const value& rhs);
102+
SIGNALRCLIENT_API value(const value& rhs);
102103

103104
/**
104105
* Moves an existing value.
105106
*/
106-
value(value&& rhs) noexcept;
107+
SIGNALRCLIENT_API value(value&& rhs) noexcept;
107108

108109
/**
109110
* Cleans up the resources associated with the value.
110111
*/
111-
~value();
112+
SIGNALRCLIENT_API ~value();
112113

113114
/**
114115
* Copies an existing value.
115116
*/
116-
value& operator=(const value& rhs);
117+
SIGNALRCLIENT_API value& operator=(const value& rhs);
117118

118119
/**
119120
* Moves an existing value.
120121
*/
121-
value& operator=(value&& rhs) noexcept;
122+
SIGNALRCLIENT_API value& operator=(value&& rhs) noexcept;
122123

123124
/**
124125
* True if the object stored is a Key-Value pair.
125126
*/
126-
bool is_map() const;
127+
SIGNALRCLIENT_API bool is_map() const;
127128

128129
/**
129130
* True if the object stored is a double.
130131
*/
131-
bool is_double() const;
132+
SIGNALRCLIENT_API bool is_double() const;
132133

133134
/**
134135
* True if the object stored is a string.
135136
*/
136-
bool is_string() const;
137+
SIGNALRCLIENT_API bool is_string() const;
137138

138139
/**
139140
* True if the object stored is empty.
140141
*/
141-
bool is_null() const;
142+
SIGNALRCLIENT_API bool is_null() const;
142143

143144
/**
144145
* True if the object stored is an array of signalr::value's.
145146
*/
146-
bool is_array() const;
147+
SIGNALRCLIENT_API bool is_array() const;
147148

148149
/**
149150
* True if the object stored is a bool.
150151
*/
151-
bool is_bool() const;
152+
SIGNALRCLIENT_API bool is_bool() const;
152153

153154
/**
154155
* Returns the stored object as a double. This will throw if the underlying object is not a signalr::type::float64.
155156
*/
156-
double as_double() const;
157+
SIGNALRCLIENT_API double as_double() const;
157158

158159
/**
159160
* Returns the stored object as a bool. This will throw if the underlying object is not a signalr::type::boolean.
160161
*/
161-
bool as_bool() const;
162+
SIGNALRCLIENT_API bool as_bool() const;
162163

163164
/**
164165
* Returns the stored object as a string. This will throw if the underlying object is not a signalr::type::string.
165166
*/
166-
const std::string& as_string() const;
167+
SIGNALRCLIENT_API const std::string& as_string() const;
167168

168169
/**
169170
* Returns the stored object as an array of signalr::value's. This will throw if the underlying object is not a signalr::type::array.
170171
*/
171-
const std::vector<value>& as_array() const;
172+
SIGNALRCLIENT_API const std::vector<value>& as_array() const;
172173

173174
/**
174175
* Returns the stored object as a map of property name to signalr::value. This will throw if the underlying object is not a signalr::type::map.
175176
*/
176-
const std::map<std::string, value>& as_map() const;
177+
SIGNALRCLIENT_API const std::map<std::string, value>& as_map() const;
177178

178179
/**
179180
* Returns the signalr::type that represents the stored object.
180181
*/
181-
value_type type() const;
182+
SIGNALRCLIENT_API value_type type() const;
182183

183184
private:
184185
value_type mType;

src/signalrclient/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ endif()
7171
if(NOT USE_CPPRESTSDK)
7272
target_link_libraries(microsoft-signalr)
7373
else()
74+
set_target_properties(microsoft-signalr PROPERTIES COMPILE_FLAGS "-DUSE_CPPRESTSDK" )
75+
7476
if(APPLE)
7577
target_link_libraries(microsoft-signalr
7678
PUBLIC ${CPPREST_LIB}

test/signalrclienttests/CMakeLists.txt

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
set (SOURCES
42
callback_manager_tests.cpp
53
case_insensitive_comparison_utils_tests.cpp
@@ -22,9 +20,47 @@ set (SOURCES
2220
)
2321

2422
include_directories(
25-
../../src/signalrclient)
23+
../../src/signalrclient
24+
)
25+
26+
# include main library sources for "internals visible to"
27+
list (APPEND SOURCES
28+
../../src/signalrclient/callback_manager.cpp
29+
../../src/signalrclient/connection.cpp
30+
../../src/signalrclient/connection_impl.cpp
31+
../../src/signalrclient/default_http_client.cpp
32+
../../src/signalrclient/default_websocket_client.cpp
33+
../../src/signalrclient/handshake_protocol.cpp
34+
../../src/signalrclient/hub_connection.cpp
35+
../../src/signalrclient/hub_connection_builder.cpp
36+
../../src/signalrclient/hub_connection_impl.cpp
37+
../../src/signalrclient/json_helpers.cpp
38+
../../src/signalrclient/json_hub_protocol.cpp
39+
../../src/signalrclient/logger.cpp
40+
../../src/signalrclient/negotiate.cpp
41+
../../src/signalrclient/signalr_client_config.cpp
42+
../../src/signalrclient/signalr_value.cpp
43+
../../src/signalrclient/trace_log_writer.cpp
44+
../../src/signalrclient/transport.cpp
45+
../../src/signalrclient/transport_factory.cpp
46+
../../src/signalrclient/url_builder.cpp
47+
../../src/signalrclient/websocket_transport.cpp
48+
../../third_party_code/cpprestsdk/uri.cpp
49+
../../third_party_code/cpprestsdk/uri_builder.cpp
50+
)
51+
52+
include_directories(
53+
../../third_party_code/cpprestsdk
54+
)
2655

2756
add_executable (signalrclienttests ${SOURCES})
2857

29-
target_link_libraries(signalrclienttests gtest microsoft-signalr)
58+
if(INCLUDE_JSONCPP)
59+
target_sources(signalrclienttests PRIVATE ../../third_party_code/jsoncpp/jsoncpp.cpp)
60+
target_include_directories(signalrclienttests PRIVATE ../../third_party_code/jsoncpp)
61+
else()
62+
target_link_libraries(microsoft-signalr PUBLIC ${JSONCPP_LIB})
63+
endif()
64+
65+
target_link_libraries(signalrclienttests gtest)
3066
add_test(NAME signalrclienttests COMMAND signalrclienttests)

0 commit comments

Comments
 (0)