Begin removing barriers to compiling Stout tests on Windows.

Currently the CMake files are designed primarily to build CMake on
various flavors of non-Windows OSs.

This commit will introduce a variety of small fixes to the CMake Stout
test configuration logic to help pave the way towards CMake-based
build system that builds on Windows two. This includes things like
adding the correct dependency targets to the stout build targets, as
well as disabling package finding logic that only works on *nix
flavors.

Review: https://reviews.apache.org/r/36967


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e891160f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e891160f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e891160f

Branch: refs/heads/master
Commit: e891160fe6b8eddebfce6ecd37231d70b48f5516
Parents: fce6356
Author: Alex Clemmer <[email protected]>
Authored: Sat Aug 1 15:11:38 2015 -0700
Committer: Benjamin Hindman <[email protected]>
Committed: Sat Aug 1 15:11:38 2015 -0700

----------------------------------------------------------------------
 .../stout/cmake/StoutTestsConfigure.cmake       | 77 +++++++++++++++++---
 1 file changed, 66 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e891160f/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake 
b/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake
index 6e7eb00..0dab6a4 100644
--- a/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake
+++ b/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake
@@ -14,22 +14,42 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-find_package(Apr REQUIRED)
-find_package(Svn REQUIRED)
+if (NOT WIN32)
+  # TODO(hausdorff): (cf. MESOS-3181) Add support for attempting to find these
+  # packages on Windows, and then if that fails, use CMake macros/functions to
+  # download, configure, and build them.
+  #
+  # WHY: Windows does not have a good package manager, so getting some of our
+  # dependencies can be really annoying in some circumstances. For this reason,
+  # we should support a CMake-based "distribution channel", even though this
+  # way is sure to be more hackish.
+  find_package(Apr REQUIRED)
+  find_package(Svn REQUIRED)
+endif (NOT WIN32)
 
 # COMPILER CONFIGURATION.
 #########################
-if (APPLE)
+if (WIN32)
+  # Used to #ifdef out (e.g.) some platform-specific parts of Stout. We choose
+  # to define a new flag rather than using an existing flag (e.g., `_WIN32`)
+  # because we want to give the build system fine-grained control over how what
+  # code is #ifdef'd out in the future, and using only flags defined by our
+  # build system to control this logic is the clearest and stablest way of
+  # doing this.
+  add_definitions(-D__WINDOWS__)
+elseif (APPLE)
   # GTEST on OSX needs its own tr1 tuple.
   # TODO(dhamon): Update to gmock 1.7 and pass GTEST_LANG_CXX11 when
   # in C++11 mode.
   add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
-endif (APPLE)
+endif (WIN32)
 
 # DEFINE PROCESS LIBRARY DEPENDENCIES. Tells the process library build targets
 # download/configure/build all third-party libraries before attempting to 
build.
 
################################################################################
 set(STOUT_TEST_DEPENDENCIES
+  ${BOOST_TARGET}
+  ${GLOG_TARGET}
   ${GMOCK_TARGET}
   ${GTEST_TARGET}
   ${PROTOBUF_TARGET}
@@ -69,29 +89,64 @@ endif (WIN32)
 ########################################################################
 set(STOUT_TEST_LIB_DIRS
   ${STOUT_TEST_LIB_DIRS}
-  ${GLOG_LIB}/lib
   ${APR_LIBS}
   ${SVN_LIBS}
   ${GMOCK_ROOT}-build/lib/.libs
   ${GMOCK_ROOT}-build/gtest/lib/.libs
-  ${PROTOBUF_LIB}/lib
   )
 
+if (WIN32)
+  # TODO(hausdorff): currently these dependencies have to be built out-of-band
+  # by opening Visual Studio, building the project, and then building Mesos. We
+  # should write batch scripts that will build these dependencies from the
+  # command line. (This is one reason why we're linking to the Debug/ folders,
+  # which is not a good idea for release builds anyway.)
+  set(STOUT_TEST_LIB_DIRS
+    ${STOUT_TEST_LIB_DIRS}
+    ${GLOG_ROOT}/Debug
+    ${GMOCK_ROOT}/msvc/2010/Debug
+    ${PROTOBUF_ROOT}/vsprojects/Debug
+    )
+else (WIN32)
+  set(STOUT_TEST_LIB_DIRS
+    ${STOUT_TEST_LIB_DIRS}
+    ${GLOG_LIB}/lib
+    ${PROTOBUF_LIB}/lib
+    )
+endif (WIN32)
+
 # DEFINE THIRD-PARTY LIBS. Used to generate flags that the linker uses to
 # include our third-party libs (e.g., -lglog on Linux).
 #########################################################################
 set(STOUT_TEST_LIBS
   ${STOUT_TEST_LIBS}
   ${CMAKE_THREAD_LIBS_INIT}
-  glog
-  dl
-  apr-1
-  protobuf
-  gtest
   gmock
   ${SVN_LIBS}
   )
 
+if (WIN32)
+  # Necessary because the lib names for glog and protobuf are generated
+  # incorrectly on Windows. That is, on *nix, the glog binary should be (e.g.)
+  # libglog.so, and on Windows it should be glog.lib. But on Windows, it's
+  # actually libglog.lib. Hence, we have to special case it here because CMake
+  # assumes the library names are generated correctly.
+  set(STOUT_TEST_LIBS
+    ${STOUT_TEST_LIBS}
+    libglog
+    libprotobuf
+    )
+else (WIN32)
+  set(STOUT_TEST_LIBS
+    ${STOUT_TEST_LIBS}
+    glog
+    gtest
+    protobuf
+    dl
+    apr-1
+    )
+endif (WIN32)
+
 # TODO(hausdorff): The `LINUX` flag comes from MesosConfigure; when we
 # port the bootstrap script to CMake, we should also copy this logic
 # into .cmake files in the Stout and Process libraries' folders

Reply via email to