THRIFT-2850 get windows cmake working again and building the unit tests for lib/cpp, and pass make check through cmake - also resolve some compiler warnings
diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt
index b444c35..46a48f7 100755
--- a/lib/cpp/CMakeLists.txt
+++ b/lib/cpp/CMakeLists.txt
@@ -23,8 +23,8 @@
else()
find_package(Boost 1.53.0 REQUIRED)
endif()
-include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
+include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
include_directories(src)
# SYSLIBS contains libraries that need to be linked to all lib targets
@@ -65,7 +65,7 @@
)
# This files don't work on Windows CE as there is no pipe support
-# TODO: This files won't work with UNICODE support on windows. If fixed this can be re-added.
+# TODO: These files won't work with UNICODE support on windows. If fixed this can be re-added.
if (NOT WINCE)
list(APPEND thriftcpp_SOURCES
src/thrift/transport/TPipe.cpp
@@ -158,7 +158,8 @@
include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
- TARGET_LINK_LIBRARIES_THRIFT(thriftnb thrift ${SYSLIBS} ${LIBEVENT_LIBRARIES})
+ TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${LIBEVENT_LIBRARIES})
+ TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftnb thrift)
endif()
if(WITH_ZLIB)
@@ -166,14 +167,16 @@
include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
- TARGET_LINK_LIBRARIES_THRIFT(thriftz thrift ${SYSLIBS} ${ZLIB_LIBRARIES})
+ TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
+ TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftz thrift)
endif()
if(WITH_QT4)
set(CMAKE_AUTOMOC ON)
find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork)
ADD_LIBRARY_THRIFT(thriftqt ${thriftcppqt_SOURCES})
- TARGET_LINK_LIBRARIES_THRIFT(thriftqt thrift ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork)
+ TARGET_LINK_LIBRARIES_THRIFT(thriftqt ${SYSLIBS} Qt4::QtCore Qt4::QtNetwork)
+ TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY(thriftqt thrift)
endif()
if(WITH_QT5)
diff --git a/lib/cpp/src/thrift/concurrency/Mutex.h b/lib/cpp/src/thrift/concurrency/Mutex.h
index e3142fa..6f892dc 100644
--- a/lib/cpp/src/thrift/concurrency/Mutex.h
+++ b/lib/cpp/src/thrift/concurrency/Mutex.h
@@ -22,6 +22,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
+#include <stdint.h>
namespace apache {
namespace thrift {
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
index e33dd48..622dfa4 100644
--- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
@@ -319,7 +319,7 @@
return;
}
ssl_ = ctx_->createSSL();
- SSL_set_fd(ssl_, socket_);
+ SSL_set_fd(ssl_, static_cast<int>(socket_));
int rc;
if (server()) {
rc = SSL_accept(ssl_);
@@ -576,7 +576,7 @@
TSSLSocketFactory* factory = (TSSLSocketFactory*)data;
string userPassword;
factory->getPassword(userPassword, size);
- int length = userPassword.size();
+ int length = static_cast<int>(userPassword.size());
if (length > size) {
length = size;
}
diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp
index cf6b79a..9d96d08 100644
--- a/lib/cpp/test/Benchmark.cpp
+++ b/lib/cpp/test/Benchmark.cpp
@@ -21,7 +21,8 @@
#include <config.h>
#endif
#include <iostream>
-#include <cmath>
+#define _USE_MATH_DEFINES
+#include <math.h>
#include "thrift/transport/TBufferTransports.h"
#include "thrift/protocol/TBinaryProtocol.h"
#include "gen-cpp/DebugProtoTest_types.h"
diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt
index 83ebe9e..8b27db8 100644
--- a/lib/cpp/test/CMakeLists.txt
+++ b/lib/cpp/test/CMakeLists.txt
@@ -17,7 +17,6 @@
# under the License.
#
-
# Find required packages
set(Boost_USE_STATIC_LIBS ON) # Force the use of static boost test framework
find_package(Boost 1.53.0 REQUIRED COMPONENTS chrono system thread unit_test_framework)
@@ -45,7 +44,6 @@
)
add_library(testgencpp STATIC ${testgencpp_SOURCES})
-target_link_libraries(testgencpp thrift)
set(testgencpp_cob_SOURCES
gen-cpp/ChildService.cpp
@@ -58,11 +56,11 @@
gen-cpp/proc_types.h
)
add_library(testgencpp_cob STATIC ${testgencpp_cob_SOURCES})
-target_link_libraries(testgencpp_cob thrift)
add_executable(Benchmark Benchmark.cpp)
target_link_libraries(Benchmark testgencpp)
+LINK_AGAINST_THRIFT_LIBRARY(Benchmark thrift)
add_test(NAME Benchmark COMMAND Benchmark)
set(UnitTest_SOURCES
@@ -81,15 +79,16 @@
endif()
add_executable(UnitTests ${UnitTest_SOURCES})
-target_link_libraries(UnitTests testgencpp thrift ${Boost_LIBRARIES})
+target_link_libraries(UnitTests testgencpp ${Boost_LIBRARIES})
+LINK_AGAINST_THRIFT_LIBRARY(UnitTests thrift)
add_test(NAME UnitTests COMMAND UnitTests)
add_executable(TSocketInterruptTest TSocketInterruptTest.cpp)
target_link_libraries(TSocketInterruptTest
testgencpp
${Boost_LIBRARIES}
- #-lrt
)
+LINK_AGAINST_THRIFT_LIBRARY(TSocketInterruptTest thrift)
if (NOT MSVC)
target_link_libraries(TSocketInterruptTest -lrt)
endif ()
@@ -100,6 +99,7 @@
testgencpp_cob
${Boost_LIBRARIES}
)
+LINK_AGAINST_THRIFT_LIBRARY(TServerIntegrationTest thrift)
if (NOT MSVC)
target_link_libraries(TServerIntegrationTest -lrt)
endif ()
@@ -109,19 +109,21 @@
add_executable(TransportTest TransportTest.cpp)
target_link_libraries(TransportTest
testgencpp
- thriftz
${Boost_LIBRARIES}
${ZLIB_LIBRARIES}
)
+LINK_AGAINST_THRIFT_LIBRARY(TransportTest thrift)
+LINK_AGAINST_THRIFT_LIBRARY(TransportTest thriftz)
add_test(NAME TransportTest COMMAND TransportTest)
add_executable(ZlibTest ZlibTest.cpp)
target_link_libraries(ZlibTest
testgencpp
- thriftz
${Boost_LIBRARIES}
${ZLIB_LIBRARIES}
)
+LINK_AGAINST_THRIFT_LIBRARY(ZlibTest thrift)
+LINK_AGAINST_THRIFT_LIBRARY(ZlibTest thriftz)
add_test(NAME ZlibTest COMMAND ZlibTest)
endif(WITH_ZLIB)
@@ -131,25 +133,25 @@
testgencpp
${Boost_LIBRARIES}
)
+LINK_AGAINST_THRIFT_LIBRARY(EnumTest thrift)
add_test(NAME EnumTest COMMAND EnumTest)
+if(HAVE_GETOPT_H)
add_executable(TFileTransportTest TFileTransportTest.cpp)
target_link_libraries(TFileTransportTest
testgencpp
${Boost_LIBRARIES}
)
+LINK_AGAINST_THRIFT_LIBRARY(TFileTransportTest thrift)
add_test(NAME TFileTransportTest COMMAND TFileTransportTest)
+endif()
add_executable(TFDTransportTest TFDTransportTest.cpp)
-target_link_libraries(TFDTransportTest
- thrift
-)
+LINK_AGAINST_THRIFT_LIBRARY(TFDTransportTest thrift)
add_test(NAME TFDTransportTest COMMAND TFDTransportTest)
add_executable(TPipedTransportTest TPipedTransportTest.cpp)
-target_link_libraries(TPipedTransportTest
- thrift
-)
+LINK_AGAINST_THRIFT_LIBRARY(TPipedTransportTest thrift)
add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest)
set(AllProtocolsTest_SOURCES
@@ -159,39 +161,36 @@
)
add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES})
-target_link_libraries(AllProtocolsTest
- testgencpp
-)
+target_link_libraries(AllProtocolsTest testgencpp)
+LINK_AGAINST_THRIFT_LIBRARY(AllProtocolsTest thrift)
add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest)
+# The debug run-time in Windows asserts on isprint() with negative inputs
+if (NOT MSVC OR (MSVC AND CMAKE_BUILD_TYPE EQUAL "DEBUG"))
add_executable(DebugProtoTest DebugProtoTest.cpp)
-target_link_libraries(DebugProtoTest
- testgencpp
-)
+target_link_libraries(DebugProtoTest testgencpp)
+LINK_AGAINST_THRIFT_LIBRARY(DebugProtoTest thrift)
add_test(NAME DebugProtoTest COMMAND DebugProtoTest)
+endif()
add_executable(JSONProtoTest JSONProtoTest.cpp)
-target_link_libraries(JSONProtoTest
- testgencpp
-)
+target_link_libraries(JSONProtoTest testgencpp)
+LINK_AGAINST_THRIFT_LIBRARY(JSONProtoTest thrift)
add_test(NAME JSONProtoTest COMMAND JSONProtoTest)
add_executable(OptionalRequiredTest OptionalRequiredTest.cpp)
-target_link_libraries(OptionalRequiredTest
- testgencpp
-)
+target_link_libraries(OptionalRequiredTest testgencpp)
+LINK_AGAINST_THRIFT_LIBRARY(OptionalRequiredTest thrift)
add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest)
add_executable(RecursiveTest RecursiveTest.cpp)
-target_link_libraries(RecursiveTest
- testgencpp
-)
+target_link_libraries(RecursiveTest testgencpp)
+LINK_AGAINST_THRIFT_LIBRARY(RecursiveTest thrift)
add_test(NAME RecursiveTest COMMAND RecursiveTest)
add_executable(SpecializationTest SpecializationTest.cpp)
-target_link_libraries(SpecializationTest
- testgencpp
-)
+target_link_libraries(SpecializationTest testgencpp)
+LINK_AGAINST_THRIFT_LIBRARY(SpecializationTest thrift)
add_test(NAME SpecializationTest COMMAND SpecializationTest)
set(concurrency_test_SOURCES
@@ -201,9 +200,7 @@
concurrency/TimerManagerTests.h
)
add_executable(concurrency_test ${concurrency_test_SOURCES})
-target_link_libraries(concurrency_test
- thrift
-)
+LINK_AGAINST_THRIFT_LIBRARY(concurrency_test thrift)
add_test(NAME concurrency_test COMMAND concurrency_test)
set(link_test_SOURCES
@@ -214,7 +211,8 @@
)
add_executable(link_test ${link_test_SOURCES})
-target_link_libraries(concurrency_test testgencpp_cob thrift)
+target_link_libraries(link_test testgencpp_cob)
+LINK_AGAINST_THRIFT_LIBRARY(link_test thrift)
add_test(NAME link_test COMMAND link_test)
if(WITH_LIBEVENT)
@@ -229,10 +227,10 @@
add_executable(processor_test ${processor_test_SOURCES})
target_link_libraries(processor_test
testgencpp_cob
- thrift
- thriftnb
${Boost_LIBRARIES}
)
+LINK_AGAINST_THRIFT_LIBRARY(processor_test thrift)
+LINK_AGAINST_THRIFT_LIBRARY(processor_test thriftnb)
add_test(NAME processor_test COMMAND processor_test)
set(TNonblockingServerTest_SOURCES TNonblockingServerTest.cpp)
@@ -240,21 +238,21 @@
include_directories(${LIBEVENT_INCLUDE_DIRS})
target_link_libraries(TNonblockingServerTest
testgencpp_cob
- thrift
- thriftnb
${LIBEVENT_LIBRARIES}
${Boost_LIBRARIES}
)
+LINK_AGAINST_THRIFT_LIBRARY(TNonblockingServerTest thrift)
+LINK_AGAINST_THRIFT_LIBRARY(TNonblockingServerTest thriftnb)
add_test(NAME TNonblockingServerTest COMMAND TNonblockingServerTest)
endif()
if(OPENSSL_FOUND AND WITH_OPENSSL)
add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp)
target_link_libraries(OpenSSLManualInitTest
- thrift
${OPENSSL_LIBRARIES}
${Boost_LIBRARIES}
)
+LINK_AGAINST_THRIFT_LIBRARY(OpenSSLManualInitTest thrift)
add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)
endif()
@@ -265,7 +263,8 @@
qt/TQTcpServerTest.cpp
)
add_executable(TQTcpServerTest ${TQTcpServerTest_SOURCES})
-target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt thrift Qt4::QtTest)
+target_link_libraries(TQTcpServerTest testgencpp_cob thriftqt Qt4::QtTest)
+LINK_AGAINST_THRIFT_LIBRARY(TQTcpServerTest thrift)
add_test(NAME TQTcpServerTest COMMAND TQTcpServerTest)
endif()
diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp
index b04ed43..6afd7ce 100644
--- a/lib/cpp/test/OpenSSLManualInitTest.cpp
+++ b/lib/cpp/test/OpenSSLManualInitTest.cpp
@@ -20,11 +20,12 @@
// MANUAL_OPENSSL_INIT to 0 to cause automatic OpenSSL init/cleanup,
// which will cause the test to fail
#define MANUAL_OPENSSL_INIT 1
+#ifdef _WIN32
+#include <WinSock2.h>
+#endif
#include <boost/test/unit_test.hpp>
-
#include <openssl/evp.h>
-
#include <thrift/transport/TSSLSocket.h>
using namespace std;
diff --git a/lib/cpp/test/TFDTransportTest.cpp b/lib/cpp/test/TFDTransportTest.cpp
index 9d2bd90..47780ff 100644
--- a/lib/cpp/test/TFDTransportTest.cpp
+++ b/lib/cpp/test/TFDTransportTest.cpp
@@ -30,6 +30,9 @@
int main() {
{ TFDTransport t(256, TFDTransport::NO_CLOSE_ON_DESTROY); }
+ // Disabled on MSVC because the RTL asserts on an invalid file descriptor
+ // in both debug and release mode; at least in MSVCR100 (Visual Studio 2010)
+#if !defined(WIN32)
try {
{
TFDTransport t(256, TFDTransport::CLOSE_ON_DESTROY);
@@ -51,6 +54,7 @@
std::abort();
} catch (DummyException&) {
}
+#endif
return 0;
}
diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp
index 465e12d..cf628ed 100644
--- a/lib/cpp/test/ZlibTest.cpp
+++ b/lib/cpp/test/ZlibTest.cpp
@@ -24,7 +24,9 @@
#endif
#include <stdint.h>
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
+#endif
#include <cstddef>
#include <fstream>
#include <iostream>
@@ -400,7 +402,9 @@
THRIFT_UNUSED_VARIABLE(argc);
THRIFT_UNUSED_VARIABLE(argv);
uint32_t seed = static_cast<uint32_t>(time(NULL));
+#ifdef HAVE_INTTYPES_H
printf("seed: %" PRIu32 "\n", seed);
+#endif
rng.seed(seed);
boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite();