CMakeLists.txt

Thu, 23 Jul 2015 17:39:52 +0300

author
Teemu Piippo <tsapii@utu.fi>
date
Thu, 23 Jul 2015 17:39:52 +0300
changeset 93
1ea012a6e1ec
parent 92
39947c46ed17
child 97
2d43f05b284c
permissions
-rw-r--r--

Fix min/max name clashing

cmake_minimum_required (VERSION 2.4)
cmake_policy (SET CMP0003 NEW)
project (ZFC9000)
string (TOLOWER ${CMAKE_PROJECT_NAME} TARGET_NAME)

add_library (huffman STATIC
	huffman/bitreader.cpp
	huffman/bitwriter.cpp
	huffman/huffcodec.cpp
	huffman/huffman.cpp
)

set (SOURCE_FILES
	sources/coloredline.cpp
	sources/interface.cpp
	sources/main.cpp
	sources/md5.cpp
	sources/mystring.cpp
	sources/version.cpp
	sources/network/bytestream.cpp
	sources/network/ipaddress.cpp
	sources/network/rconsession.cpp
	sources/network/udpsocket.cpp
)

set (HEADER_FILES
	sources/basics.h
	sources/coloredline.h
	sources/geometry.h
	sources/interface.h
	sources/list.h
	sources/main.h
	sources/md5.h
	sources/mystring.h
	sources/network/bytestream.h
	sources/network/ipaddress.h
	sources/network/rconsession.h
	sources/network/udpsocket.h
	sources/range.h
	sources/version.h
)

if (NOT WIN32)
	find_package (Curses REQUIRED)
endif()

if (MINGW)
	set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
endif()

include_directories (${CMAKE_CURRENT_BINARY_DIR})
include_directories (huffman)
add_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries (${TARGET_NAME} huffman)

if (WIN32)
	add_definitions (-D_CRT_SECURE_NO_WARNINGS)
	target_link_libraries (${TARGET_NAME} wsock32 ws2_32)

	if (PDCURSES_PATH OR PDCURSES_WIN32A_PATH)
		if (NOT PDCURSES_PATH)
			set (PDCURSES_PATH "${PDCURSES_WIN32A_PATH}")
			add_definitions (-DHAVE_PDCURSES_WIN32A)
		endif()

		include_directories (${PDCURSES_PATH}/include)

		if (MINGW)
			target_link_libraries (${TARGET_NAME} ${PDCURSES_PATH}/lib/pdcurses.a)
		else()
			target_link_libraries (${TARGET_NAME} ${PDCURSES_PATH}/lib/pdcurses.lib)
		endif()
	else()
		message (SEND_ERROR "Must provide PDCURSES_PATH or PDCURSES_WIN32A_PATH on Windows")

		if (MINGW)
			message (SEND_ERROR "This path must contain pdcurses.a in lib/, and curses.h in include/.")
		else()
			message (SEND_ERROR "This path must contain pdcurses.lib in lib/, and curses.h in include/.")
		endif()
	endif()
else()
	include_directories (${CURSES_INCUDE_DIRS}) # sic
	target_link_libraries (${TARGET_NAME} ${CURSES_LIBRARIES})
	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -std=c++0x")
endif()

add_custom_target (make_hginfo_h
	COMMAND python
		"${CMAKE_SOURCE_DIR}/updaterevision/updaterevision.py"
		"${CMAKE_CURRENT_BINARY_DIR}/hginfo.h")
add_dependencies (${TARGET_NAME} make_hginfo_h)

mercurial