server/src/CMakeLists.txt

284 lines
6.5 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 2.8)
2012-06-04 03:55:52 +02:00
project (server C)
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
2014-03-06 16:15:43 +01:00
include_directories (${CJSON_INCLUDE_DIR})
include_directories (${CLIBS_INCLUDE_DIR})
include_directories (${STORAGE_INCLUDE_DIR})
2012-06-04 03:55:52 +02:00
include_directories (${LUA_INCLUDE_DIR})
2015-07-12 03:08:29 +02:00
include_directories (${TOLUA_INCLUDE_DIR})
2012-06-04 03:55:52 +02:00
include_directories (${BSON_INCLUDE_DIR})
include_directories (${INIPARSER_INCLUDE_DIR})
2016-09-10 18:44:08 +02:00
IF(DEFINED ERESSEA_VERSION)
set_source_files_properties(kernel/version.c PROPERTIES
COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}")
2016-09-10 18:44:08 +02:00
ENDIF()
IF(DEFINED ERESSEA_BUILDNO)
set_source_files_properties(kernel/version.c PROPERTIES
COMPILE_DEFINITIONS ERESSEA_BUILDNO="${ERESSEA_BUILDNO}")
ENDIF()
2016-11-18 13:24:50 +01:00
IF (CMAKE_COMPILER_IS_GNUCC)
2017-03-01 18:16:07 +01:00
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
2016-11-18 13:24:50 +01:00
ENDIF()
IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
2017-02-18 21:26:38 +01:00
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")
ELSEIF(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP")
2014-08-29 07:47:47 +02:00
set(CMAKE_EXE_LINKER_FLAGS_DEBUG
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE
"${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib")
ELSE()
MESSAGE(STATUS "unknown compiler ${CMAKE_C_COMPILER_ID}")
ENDIF()
IF(CMAKE_COMPILER_IS_CLANG)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wtautological-compare -Weverything")
MESSAGE(STATUS "compiler is clang: ${CMAKE_C_COMPILER_ID}")
ELSEIF(CMAKE_COMPILER_IS_GCC)
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
IF (GCC_VERSION VERSION_GREATER 4.9)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion")
ENDIF()
ENDIF(CMAKE_COMPILER_IS_CLANG)
2014-08-29 07:47:47 +02:00
add_subdirectory(util)
add_subdirectory(kernel)
add_subdirectory(items)
add_subdirectory(attributes)
add_subdirectory(spells)
add_subdirectory(triggers)
add_subdirectory(modules)
add_subdirectory(races)
MACRO(ADD_LUA_MODULE MODULE_NAME FILES)
ADD_LIBRARY (${MODULE_NAME} SHARED ${FILES})
SET_TARGET_PROPERTIES(${MODULE_NAME}
PROPERTIES
PREFIX ""
)
ENDMACRO(ADD_LUA_MODULE)
MACRO(TOLUA_BINDING PKGFILE FILES)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${PKGFILE}.c
DEPENDS ${FILES} ${PKGFILE}
COMMAND ${TOLUA_EXECUTABLE}
ARGS -o ${CMAKE_CURRENT_SOURCE_DIR}/${PKGFILE}.c ${PKGFILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
ENDMACRO(TOLUA_BINDING)
IF(NOT MSVC)
TOLUA_BINDING(log.pkg util/log.h)
TOLUA_BINDING(locale.pkg bind_locale.h)
TOLUA_BINDING(config.pkg bind_config.h)
TOLUA_BINDING(process.pkg bind_process.h)
TOLUA_BINDING(game.pkg bind_eressea.h config.h)
TOLUA_BINDING(eressea.pkg bind_eressea.h)
TOLUA_BINDING(settings.pkg kenel/config.h)
ENDIF()
set (ERESSEA_SRC
vortex.c
calendar.c
move.c
piracy.c
spells.c
battle.c
alchemy.c
academy.c
upkeep.c
names.c
lighthouse.c
reports.c
teleport.c
guard.c
prefix.c
donations.c
eressea.c
direction.c
keyword.c
skill.c
json.c
2016-09-17 22:57:22 +02:00
creport.c
report.c
economy.c
give.c
items.c
laws.c
magic.c
market.c
morale.c
randenc.c
renumber.c
volcano.c
chaos.c
spy.c
study.c
summary.c
travelthru.c
monsters.c
wormhole.c
${SPELLS_SRC}
${RACES_SRC}
${ITEMS_SRC}
${MODULES_SRC}
${TRIGGERS_SRC}
${ATTRIBUTES_SRC}
${KERNEL_SRC}
${UTIL_SRC}
)
set(SERVER_SRC
main.c
building_action.c
console.c
helpers.c
bind_tolua.c
bind_building.c
bind_config.c
bind_locale.c
bind_eressea.c
bind_faction.c
bind_order.c
bindings.c
bind_message.c
bind_monsters.c
bind_process.c
bind_region.c
bind_ship.c
bind_storage.c
bind_unit.c
)
if (SQLITE3_FOUND)
set (SERVER_SRC ${SERVER_SRC}
sqlite.c
bind_sqlite.c
)
endif (SQLITE3_FOUND)
if (CURSES_FOUND)
set (SERVER_SRC ${SERVER_SRC}
gmtool.c
listbox.c
bind_gmtool.c
)
endif(CURSES_FOUND)
add_library(version STATIC ${VERSION_SRC})
add_library(game ${ERESSEA_SRC})
add_executable(eressea ${SERVER_SRC})
target_link_libraries(game version)
target_link_libraries(eressea
game
${TOLUA_LIBRARIES}
${LUA_LIBRARIES}
${STORAGE_LIBRARIES}
${CLIBS_LIBRARIES}
2014-03-06 16:15:43 +01:00
${CJSON_LIBRARIES}
${INIPARSER_LIBRARIES}
)
2017-02-26 15:03:47 +01:00
add_executable(convert convert.c)
target_link_libraries(convert
game
${LUA_MATH_LIBRARY}
${STORAGE_LIBRARIES}
${CLIBS_LIBRARIES}
${INIPARSER_LIBRARIES}
)
set(TESTS_SRC
test_eressea.c
tests.c
2017-05-07 13:35:59 +02:00
alchemy.test.c
battle.test.c
2017-05-07 13:35:59 +02:00
calendar.test.c
2016-09-17 22:57:22 +02:00
creport.test.c
direction.test.c
2017-05-07 13:35:59 +02:00
donations.test.c
economy.test.c
2017-05-07 13:35:59 +02:00
give.test.c
guard.test.c
json.test.c
keyword.test.c
laws.test.c
2016-09-17 12:34:02 +02:00
lighthouse.test.c
magic.test.c
market.test.c
2015-11-17 02:07:46 +01:00
monsters.test.c
move.test.c
2017-05-07 13:35:59 +02:00
names.test.c
2015-10-12 11:54:59 +02:00
piracy.test.c
prefix.test.c
2016-11-16 20:03:34 +01:00
renumber.test.c
2017-05-07 13:35:59 +02:00
reports.test.c
report.test.c
summary.test.c
skill.test.c
2015-05-06 17:36:20 +02:00
spells.test.c
2015-01-18 17:40:54 +01:00
spy.test.c
study.test.c
2017-05-07 13:35:59 +02:00
tests.test.c
travelthru.test.c
2015-05-06 17:36:20 +02:00
upkeep.test.c
2017-05-07 13:35:59 +02:00
volcano.test.c
vortex.test.c
wormhole.test.c
spells/flyingship.test.c
2015-07-07 20:23:24 +02:00
spells/magicresistance.test.c
triggers/shock.test.c
${ATTRIBUTES_TESTS}
${UTIL_TESTS}
${KERNEL_TESTS}
${ITEMS_TESTS}
)
add_executable(test_eressea ${TESTS_SRC})
target_link_libraries(test_eressea
game
cutest
${LUA_LIBRARIES}
${CLIBS_LIBRARIES}
${STORAGE_LIBRARIES}
2014-03-06 16:15:43 +01:00
${CJSON_LIBRARIES}
${INIPARSER_LIBRARIES}
)
add_test(server test_eressea)
2014-08-07 13:23:11 +02:00
#add_test(NAME E3
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/game-e3
# COMMAND $<TARGET_FILE:eressea> runtests.lua )
#add_test(NAME E2
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/game-e2
# COMMAND $<TARGET_FILE:eressea> runtests.lua )
install(TARGETS eressea DESTINATION "bin")
if (SQLITE3_FOUND)
target_link_libraries(eressea ${SQLITE3_LIBRARIES})
add_definitions(-DUSE_SQLITE)
endif(SQLITE3_FOUND)
if (CURSES_FOUND)
include_directories (${CURSES_INCLUDE_DIR})
target_link_libraries(eressea ${CURSES_LIBRARIES})
add_definitions(-DUSE_CURSES)
endif(CURSES_FOUND)
if (LIBXML2_FOUND)
include_directories (${LIBXML2_INCLUDE_DIR})
target_link_libraries(eressea ${LIBXML2_LIBRARIES})
2017-02-26 15:03:47 +01:00
target_link_libraries(convert ${LIBXML2_LIBRARIES})
target_link_libraries(test_eressea ${LIBXML2_LIBRARIES})
add_definitions(-DUSE_LIBXML2)
endif (LIBXML2_FOUND)