THRIFT-3398 Add CMake build for Haskell library and tests
Client: Build, Haskell
Patch: Nobuaki Sukegawa
This closes #660
diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
index 62e240f..0aad240 100644
--- a/build/cmake/DefineOptions.cmake
+++ b/build/cmake/DefineOptions.cmake
@@ -86,6 +86,13 @@
CMAKE_DEPENDENT_OPTION(BUILD_PYTHON "Build Python library" ON
"BUILD_LIBRARIES;WITH_PYTHON;PYTHONLIBS_FOUND" OFF)
+# Haskell
+option(WITH_HASKELL "Build Haskell Thrift library" ON)
+find_package(GHC QUIET)
+find_package(Cabal QUIET)
+CMAKE_DEPENDENT_OPTION(BUILD_HASKELL "Build GHC library" ON
+ "BUILD_LIBRARIES;WITH_HASKELL;GHC_FOUND;CABAL_FOUND" OFF)
+
# Common library options
option(WITH_SHARED_LIB "Build shared libraries" ON)
option(WITH_STATIC_LIB "Build static libraries" ON)
@@ -129,6 +136,10 @@
message(STATUS " Build Python library: ${BUILD_PYTHON}")
MESSAGE_DEP(WITH_PYTHON "Disabled by via WITH_PYTHON=OFF")
MESSAGE_DEP(PYTHONLIBS_FOUND "Python libraries missing")
+message(STATUS " Build Haskell library: ${BUILD_HASKELL}")
+MESSAGE_DEP(WITH_HASKELL "Disabled by via WITH_HASKELL=OFF")
+MESSAGE_DEP(GHC_FOUND "GHC missing")
+MESSAGE_DEP(CABAL_FOUND "Cabal missing")
message(STATUS " Library features:")
message(STATUS " Build shared libraries: ${WITH_SHARED_LIB}")
message(STATUS " Build static libraries: ${WITH_STATIC_LIB}")
diff --git a/build/cmake/FindCabal.cmake b/build/cmake/FindCabal.cmake
new file mode 100644
index 0000000..fed337b
--- /dev/null
+++ b/build/cmake/FindCabal.cmake
@@ -0,0 +1,30 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# Cabal_FOUND - system has Cabal
+# Cabal - the Cabal executable
+#
+# It will search the environment variable CABAL_HOME if it is set
+
+include(FindPackageHandleStandardArgs)
+
+find_program(CABAL NAMES cabal PATHS $ENV{HOME}/.cabal/bin $ENV{CABAL_HOME}/bin)
+find_package_handle_standard_args(CABAL DEFAULT_MSG CABAL)
+mark_as_advanced(CABAL)
diff --git a/build/cmake/FindGHC.cmake b/build/cmake/FindGHC.cmake
new file mode 100644
index 0000000..4873847
--- /dev/null
+++ b/build/cmake/FindGHC.cmake
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# GHC_FOUND - system has GHC
+# GHC - the GHC executable
+# RUN_HASKELL_FOUND - system has runhaskell
+# RUN_HASKELL - the runhaskell executable
+#
+# It will search the environment variable GHC_HOME if it is set
+
+include(FindPackageHandleStandardArgs)
+
+find_program(GHC NAMES ghc PATHS $ENV{GHC_HOME}/bin)
+find_package_handle_standard_args(GHC DEFAULT_MSG GHC)
+mark_as_advanced(GHC)
+
+find_program(RUN_HASKELL NAMES runhaskell PATHS $ENV{GHC_HOME}/bin)
+find_package_handle_standard_args(RUN_HASKELL DEFAULT_MSG RUN_HASKELL)
+mark_as_advanced(RUN_HASKELL)