# HG changeset patch # User koda # Date 1362584456 -3600 # Node ID a9957b7797f321da6af81285b46a8baabf9c053e # Parent fcb87b74ea7ec25c5aa703191cedaa2349d191c1 write FindGHC.cmake for haskell stuff diff -r fcb87b74ea7e -r a9957b7797f3 CMakeLists.txt --- a/CMakeLists.txt Wed Mar 06 09:42:20 2013 -0500 +++ b/CMakeLists.txt Wed Mar 06 16:40:56 2013 +0100 @@ -284,28 +284,6 @@ endif() - -#server discovery -if(NOT NOSERVER) - if(GHC) - set(ghc_executable ${GHC}) - else() - find_program(ghc_executable ghc) - endif() - - if(ghc_executable) - add_subdirectory(gameServer) - message(STATUS "Found GHC: ${ghc_executable}") - else() - message(${WARNING} "Could NOT find GHC, server will not be built") - set(HAVE_NETSERVER false) - endif() -else() - message(STATUS "Server will not be built per user request") - set(HAVE_NETSERVER false) -endif() - - #lua discovery find_package(Lua) if(LUA_FOUND) @@ -362,9 +340,14 @@ set(FFMPEG_FOUND false) endif() -# +#physfs helper library add_subdirectory(misc/libphyslayer) +#server +if(NOT NOSERVER) + add_subdirectory(gameServer) +endif() + #main engine add_subdirectory(hedgewars) diff -r fcb87b74ea7e -r a9957b7797f3 cmake_modules/FindGHC.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmake_modules/FindGHC.cmake Wed Mar 06 16:40:56 2013 +0100 @@ -0,0 +1,38 @@ +# - Try to find the Glasgow Haskell Compiler executable +# Once done this will define +# +# GHC_FOUND - system has GHC +# GHC_VERSION - GHC version +# GHC_EXECUTABLE - GHC executable +# +# Copyright (c) 2013, Vittorio Giovara +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +find_program(GHC_EXECUTABLE + NAMES ghc + PATHS /opt/local/bin /usr/local/bin /usr/bin + ) + +if (GHC_EXECUTABLE) + # check Freepascal version + execute_process(COMMAND ${GHC_EXECUTABLE} -V + OUTPUT_VARIABLE GHC_VERSION_OUTPUT + ERROR_VARIABLE GHC_VERSION_ERROR + RESULT_VARIABLE GHC_VERSION_RESULT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(${GHC_VERSION_RESULT} EQUAL 0) + string(REGEX MATCH "([0-9]+)" GHC_VERSION ${GHC_VERSION_OUTPUT}) + else() + message(SEND_ERROR "Command \"${GHC_EXECUTABLE} -V\" failed with output: ${GHC_VERSION_ERROR}") + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GHC DEFAULT_MSG GHC_EXECUTABLE GHC_VERSION) +mark_as_advanced(GHC_VERSION) + diff -r fcb87b74ea7e -r a9957b7797f3 gameServer/CMakeLists.txt --- a/gameServer/CMakeLists.txt Wed Mar 06 09:42:20 2013 -0500 +++ b/gameServer/CMakeLists.txt Wed Mar 06 16:40:56 2013 +0100 @@ -1,4 +1,8 @@ +find_package(GHC REQUIRED) +if(NOT ${GHC_FOUND}) + message(FATAL_ERROR "Missing Glasgow Haskell Compiler! Rerun cmake with -DNOSERVER=on to disable hosting LAN games") +endif() set(hwserver_sources OfficialServer/DBInteraction.hs @@ -34,7 +38,7 @@ ${haskell_flags}) add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}" - COMMAND "${ghc_executable}" + COMMAND "${GHC_EXECUTABLE}" ARGS ${ghc_flags} MAIN_DEPENDENCY ${hwserv_main} DEPENDS ${hwserver_sources}