summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 295fa9cf9005e4cd331583b3bea09272b346e0ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# This project needs CMake version >= 2.6
cmake_minimum_required(VERSION 2.6)

# Set the project name. This will be used by CMake to name project related variables.
project(oxen)

# Unix Makefile generator: Default to build type 'Release'
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
	set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)

# Set C compiler flags
set(CMAKE_C_FLAGS "-Wall -pedantic -std=c99 -D_POSIX_SOURCE")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_C_FLAGS_DEBUG  "-O0 -g")

# If we specified a debug build, #define OXEN_DEBUG
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
	add_definitions(-DOXEN_DEBUG)
endif(${CMAKE_BUILD_TYPE} MATCHES Debug)

# If CMake is run with -DDGLSERVER=ON, #define OXEN_DGLSERVER
if(DGLSERVER)
	message("Building server to use for dgamelaunch watchmode")
	add_definitions(-DOXEN_DGLSERVER)
endif(DGLSERVER)

# Find dependencies
# Find ncurses (required)
set(CURSES_NEED_NCURSES true)
find_package(Curses REQUIRED)

# Find doxygen (optional)
find_package(Doxygen)
if(DOXYGEN_FOUND)
	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
	add_custom_target(doc
		${DOXYGEN_EXECUTABLE}
		${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
		COMMENT "Generating API documentation with Doxygen" VERBATIM
		)
endif(DOXYGEN_FOUND)

# Set the directory where source files are located.
set(OXEN_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)

# Include all source files recursively
file(GLOB_RECURSE OXEN_SOURCES ${OXEN_SOURCE_DIR}/*.c)

# Specify the name of our project executable and from which source files it will be built
add_executable(
	oxen
	${OXEN_SOURCES}
)

# Specify the libraries to be linked with our executable
target_link_libraries(
	oxen
	${CURSES_LIBRARIES}
)

install(TARGETS oxen RUNTIME DESTINATION bin)

# Package generator (see also http://www.cmake.org/Wiki/CMake:Packaging_With_CPack)
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
SET(CPACK_PACKAGE_VERSION_MINOR "1")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Multiplayer card game for up to 10 players")
SET(CPACK_DEBIAN_PACKAGE_SECTION "games")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libncurses5 (>= 5.6)")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "hornoxe")
INCLUDE(CPack)