THRIFT-3442 Run CMake tests on Appveyor
Client: Test
Patch: Nobuaki Sukegawa

This closes #713
diff --git a/lib/hs/CMakeLists.txt b/lib/hs/CMakeLists.txt
index f28cb37..37ea288 100644
--- a/lib/hs/CMakeLists.txt
+++ b/lib/hs/CMakeLists.txt
@@ -48,11 +48,18 @@
     endif()
 endforeach()
 
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+  set(hs_optimize -O0)
+elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
+  set(hs_optimize -O1)
+endif()
+
 add_custom_command(
     OUTPUT ${haskell_artifacts}
     COMMAND ${CABAL} update
     # Build dependencies first without --builddir, otherwise it fails.
-    COMMAND ${CABAL} install --dependencies-only
+    COMMAND ${CABAL} install --only-dependencies
+    COMMAND ${CABAL} configure ${hs_optimize}
     COMMAND ${CABAL} install --builddir=${CMAKE_CURRENT_BINARY_DIR}/dist
     COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/thrift_cabal.stamp
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}