File: CMakeLists.txt

package info (click to toggle)
megaglest 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,904 kB
  • ctags: 18,215
  • sloc: cpp: 144,232; ansic: 11,860; sh: 2,949; perl: 1,899; python: 1,751; objc: 142; asm: 42; makefile: 24
file content (178 lines) | stat: -rw-r--r-- 6,722 bytes parent folder | download
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#########################################################################################
# megaglest_tests

SET(EXTERNAL_LIBS "")
SET(TARGET_NAME "megaglest_tests")

IF(BUILD_MEGAGLEST_TESTS)
	MESSAGE(STATUS "Will try to build MegaGlest unit tests")

	INCLUDE (CheckIncludeFiles)

	FIND_PACKAGE(CppUnit REQUIRED)
	INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
	IF(UNIX)
		SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${CPPUNIT_LIBRARY})
	ENDIF()

	FIND_PACKAGE(${SDL_VERSION_NAME} REQUIRED)
	INCLUDE_DIRECTORIES(${${SDL_VERSION_NAME}_INCLUDE_DIR})
	IF(UNIX)
		SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${${SDL_VERSION_NAME}_LIBRARY})
	ENDIF()

	if(WANT_USE_FriBiDi)
		find_package( FriBiDi )
		if(FRIBIDI_FOUND)
			add_definitions(-DHAVE_FRIBIDI)

			include_directories( ${FRIBIDI_INCLUDE_DIR} )
			SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${FRIBIDI_LIBRARIES})
		else()
			message("Could not find FriBiDi. Disabling FriBiDi support.")
		endif()
	endif()

	#########################################################################################
	# megaglest test code

	SET(DIRS_WITH_SRC
                ./
                shared_lib/graphics
                shared_lib/streflop
                shared_lib/util
		shared_lib/xml)
	
	SET(MG_INCLUDES_ROOT "./")
	SET(MG_SOURCES_ROOT "./")
	SET(MG_INCLUDE_FILES "")
	SET(MG_SOURCE_FILES "")

	SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/")
	SET(GLEST_LIB_INCLUDE_DIRS
                ${GLEST_LIB_INCLUDE_ROOT}platform/common
                ${GLEST_LIB_INCLUDE_ROOT}platform/posix
                ${GLEST_LIB_INCLUDE_ROOT}util
                ${GLEST_LIB_INCLUDE_ROOT}graphics
                ${GLEST_LIB_INCLUDE_ROOT}graphics/gl
                ${GLEST_LIB_INCLUDE_ROOT}graphics/iqm
                ${GLEST_LIB_INCLUDE_ROOT}sound
                ${GLEST_LIB_INCLUDE_ROOT}sound/openal
                ${GLEST_LIB_INCLUDE_ROOT}xml
                ${GLEST_LIB_INCLUDE_ROOT}xml/rapidxml
                ${GLEST_LIB_INCLUDE_ROOT}glew
                ${GLEST_LIB_INCLUDE_ROOT}lua
                ${GLEST_LIB_INCLUDE_ROOT}map

                ${PROJECT_SOURCE_DIR}/source/glest_game/graphics
                ${PROJECT_SOURCE_DIR}/source/glest_game/world
                ${PROJECT_SOURCE_DIR}/source/glest_game/sound
                ${PROJECT_SOURCE_DIR}/source/glest_game/type_instances
                ${PROJECT_SOURCE_DIR}/source/glest_game/types
                )

	IF(WANT_USE_STREFLOP)
		SET(GLEST_LIB_INCLUDE_DIRS
			${GLEST_LIB_INCLUDE_DIRS}
			${GLEST_LIB_INCLUDE_ROOT}streflop
			${GLEST_LIB_INCLUDE_ROOT}streflop/libm_flt32_source)
	ENDIF()

	INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )

	IF(WIN32)
		INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/win32_deps/include)
		INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/posix)
		INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/win32)
		INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/${SDL_VERSION_SNAME} )
	ELSE()
		INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/${SDL_VERSION_SNAME} )
		SET(GLEST_LIB_INCLUDE_DIRS ${GLEST_LIB_INCLUDE_DIRS} ${GLEST_LIB_INCLUDE_ROOT}platform/${SDL_VERSION_SNAME})
		SET(GLEST_LIB_INCLUDE_DIRS ${GLEST_LIB_INCLUDE_DIRS} ${GLEST_LIB_INCLUDE_ROOT}platform/unix)
	ENDIF()

	FOREACH(DIR IN LISTS DIRS_WITH_SRC)
		set(INCLUDE_DIR_TO_GLOB ${MG_INCLUDES_ROOT}${DIR})
		INCLUDE_DIRECTORIES( ${INCLUDE_DIR_TO_GLOB} )
		IF(APPLE)
			#MESSAGE(STATUS "INCLUDE_DIR_TO_GLOB: ${INCLUDE_DIR_TO_GLOB}")
			FILE(GLOB INC_FILES_FROM_THIS_DIR ${INCLUDE_DIR_TO_GLOB}/*.h)
			#MESSAGE(STATUS "INCLUDE FILES GLOBBED: ${INC_FILES_FROM_THIS_DIR}")
			SET(MG_INCLUDE_FILES ${MG_INCLUDE_FILES} ${INC_FILES_FROM_THIS_DIR})
		ENDIF(APPLE)

		set(SRC_DIR_TO_GLOB ${MG_SOURCES_ROOT}${DIR})
		#MESSAGE(STATUS "SRC_DIR_TO_GLOB: ${SRC_DIR_TO_GLOB}")
		FILE(GLOB SRC_FILES_FROM_THIS_DIR ${SRC_DIR_TO_GLOB}/*.cpp)
		#MESSAGE(STATUS "SRC_FILES_FROM_THIS_DIR: ${SRC_FILES_FROM_THIS_DIR}")
		SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${SRC_FILES_FROM_THIS_DIR})
	
		set(SRC_DIR_TO_GLOB ${MG_SOURCES_ROOT}${DIR})
		#MESSAGE(STATUS "SRC_DIR_TO_GLOB: ${SRC_DIR_TO_GLOB}")
		FILE(GLOB SRC_FILES_FROM_THIS_DIR ${SRC_DIR_TO_GLOB}/*.c)
		#MESSAGE(STATUS "SRC_FILES_FROM_THIS_DIR: ${SRC_FILES_FROM_THIS_DIR}")
		SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${SRC_FILES_FROM_THIS_DIR})

		IF(APPLE)
			FILE(GLOB SRC_FILES_FROM_THIS_DIR ${SRC_DIR_TO_GLOB}/*.mm)
			#MESSAGE(STATUS "SRC_FILES_FROM_THIS_DIR: ${SRC_FILES_FROM_THIS_DIR}")
			SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${SRC_FILES_FROM_THIS_DIR})
			FILE(GLOB SRC_FILES_FROM_THIS_DIR ${SRC_DIR_TO_GLOB}/*.m)
			#MESSAGE(STATUS "SRC_FILES_FROM_THIS_DIR: ${SRC_FILES_FROM_THIS_DIR}")
			SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${SRC_FILES_FROM_THIS_DIR})	
		ENDIF(APPLE)
	ENDFOREACH(DIR)

	#MESSAGE(STATUS "Source files: ${MG_INCLUDE_FILES}")
	#MESSAGE(STATUS "Source files: ${MG_SOURCE_FILES}")
	#MESSAGE(STATUS "Include dirs: ${INCLUDE_DIRECTORIES}")

	IF(APPLE)
		SET(PLATFORM_SPECIFIC_DEFINES "-DHAVE_SYS_IOCTL_H")
	ELSEIF(WIN32)
		SET(PLATFORM_SPECIFIC_DEFINES "-DX11_AVAILABLE")
	ELSE()
		SET(PLATFORM_SPECIFIC_DEFINES "-DX11_AVAILABLE -DHAVE_SYS_IOCTL_H")
	ENDIF()

	SET_SOURCE_FILES_PROPERTIES(${MG_SOURCE_FILES} PROPERTIES COMPILE_FLAGS 
		"${PLATFORM_SPECIFIC_DEFINES} ${STREFLOP_PROPERTIES} ${CXXFLAGS}")
	
	SET_SOURCE_FILES_PROPERTIES(${MG_INCLUDE_FILES} PROPERTIES HEADER_FILE_ONLY 1)

	IF(WANT_DEV_OUTPATH)
		SET(EXECUTABLE_OUTPUT_PATH "${MEGAGLEST_FRIENDLY_OUTPUT_PATH}")
	ENDIF()

	MESSAGE(STATUS "EXTERNAL_LIBS = [${EXTERNAL_LIBS}]")

        MESSAGE(STATUS "***Note: The final output path for the MegaGlest engine will be [${EXECUTABLE_OUTPUT_PATH}]")

	SET_SOURCE_FILES_PROPERTIES(${MG_INCLUDE_FILES} PROPERTIES HEADER_FILE_ONLY 1)

	ADD_EXECUTABLE(${TARGET_NAME} ${MG_SOURCE_FILES} ${MG_INCLUDE_FILES})

	IF(NOT WIN32)
		IF(WANT_USE_STREFLOP)
			TARGET_LINK_LIBRARIES(${TARGET_NAME} ${MG_STREFLOP})
		ENDIF()
		TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest)
	ENDIF()

        TARGET_LINK_LIBRARIES(${TARGET_NAME} ${EXTERNAL_LIBS})
	IF(NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
		# Run the unit tests after build
		IF(EXISTS ${XVFB_EXEC})
			MESSAGE("***-- Found xvfb-run: ${XVFB_EXEC} will run tests with it.")

			add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
				COMMAND ${XVFB_EXEC} --auto-servernum --server-num=770 ${EXECUTABLE_OUTPUT_PATH}${TARGET_NAME}
				COMMENT "***-- Found MegaGlest test runner: ${TARGET_NAME} about to run unit tests via xvfb...")
		ELSE()
			add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
				COMMAND ${EXECUTABLE_OUTPUT_PATH}${TARGET_NAME}
				COMMENT "***-- Found MegaGlest test runner: ${TARGET_NAME} about to run unit tests...")
		ENDIF()
	ENDIF()

ENDIF()