gameServer/CMakeLists.txt
author koda
Fri, 02 Oct 2009 18:44:37 +0000 (2009-10-02)
changeset 2401 2a694ea2a437
parent 2203 6bd39d75e0dd
child 2406 2e757b32991e
permissions -rw-r--r--
fixes & co.
find_program(ghc_executable ghc)

if(NOT ghc_executable)
	message(FATAL_ERROR "Cannot find GHC")
endif(NOT ghc_executable)

if(APPLE)
	find_package(GMP REQUIRED)
endif(APPLE)

set(hwserver_sources
	OfficialServer/DBInteraction.hs
	Actions.hs
	ClientIO.hs
	CoreTypes.hs
	HWProtoCore.hs
	HWProtoInRoomState.hs
	HWProtoLobbyState.hs
	HWProtoNEState.hs
	NetRoutines.hs
	Opts.hs
	ServerCore.hs
	Utils.hs
	hedgewars-server.hs
	)

set(hwserv_main ${hedgewars_SOURCE_DIR}/gameServer/hedgewars-server.hs)

set(ghc_flags
	--make ${hwserv_main}
	-i${hedgewars_SOURCE_DIR}/gameServer
	-o ${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}
	-odir ${CMAKE_CURRENT_BINARY_DIR}
	-hidir ${CMAKE_CURRENT_BINARY_DIR})

if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "Release")
set(ghc_flags
	-w
	-O2
	${ghc_flags}
)
else()
set(ghc_flags
	-Wall
	-debug
	-dcore-lint
	${ghc_flags}
)
endif()

add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}"
		COMMAND "${ghc_executable}"
		ARGS ${ghc_flags}
		MAIN_DEPENDENCY ${hwserv_main}
		DEPENDS ${hwserver_sources}
		)

add_custom_target(hedgewars-server ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}")

install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir})