diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-06-19 10:10:15 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-06-19 10:10:15 +0200 |
commit | 61d02a395b0ca594640f0fb917d7162a5aba2c37 (patch) | |
tree | 7dd6f7f540dda3d89d37bc7e19f3f4d27dd53c85 /src/CMakeLists.txt | |
parent | 5da59b807d9840fb23feb42df729bf5e88ee9678 (diff) | |
parent | ac0b338b3e026d0d05a447894de9a6a994da82dc (diff) | |
download | mana-61d02a395b0ca594640f0fb917d7162a5aba2c37.tar.gz mana-61d02a395b0ca594640f0fb917d7162a5aba2c37.tar.bz2 mana-61d02a395b0ca594640f0fb917d7162a5aba2c37.tar.xz mana-61d02a395b0ca594640f0fb917d7162a5aba2c37.zip |
Merge branch 'master' into online-player-listonline-player-list
Conflicts:
src/net/tmwa/chathandler.cpp
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r-- | src/CMakeLists.txt | 250 |
1 files changed, 128 insertions, 122 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72b44ac6..f993f4ed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,93 +1,87 @@ include(FindPkgConfig) -pkg_check_modules(SDL2 REQUIRED sdl2>=2.0.5 SDL2_image SDL2_mixer SDL2_net SDL2_ttf) -FIND_PACKAGE(PhysFS REQUIRED) -FIND_PACKAGE(CURL REQUIRED) -FIND_PACKAGE(LibXml2 REQUIRED) -FIND_PACKAGE(PNG REQUIRED) -FIND_PACKAGE(Gettext REQUIRED) +pkg_check_modules(SDL2 REQUIRED + sdl2>=2.0.5 + SDL2_image + SDL2_mixer + SDL2_net + SDL2_ttf) +find_package(PhysFS REQUIRED) +find_package(CURL REQUIRED) +find_package(LibXml2 REQUIRED) +find_package(PNG REQUIRED) +find_package(Gettext REQUIRED) +find_package(Intl REQUIRED) -IF (CMAKE_COMPILER_IS_GNUCXX) - # Help getting compilation warnings - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") - IF (WIN32) - # This includes enough debug information to get something useful - # from Dr. Mingw while keeping binary size down. Almost useless - # with gdb, though. - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb0 -gstabs2") - ENDIF() -ENDIF() - -SET(FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\"") - -IF (WIN32) - SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"") - SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${CMAKE_INSTALL_LOCALEDIR}/\\\"") -ELSE() - SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${CMAKE_INSTALL_FULL_DATAROOTDIR}/mana/\\\"") - SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${CMAKE_INSTALL_FULL_LOCALEDIR}/\\\"") -ENDIF() +if(CMAKE_COMPILER_IS_GNUCXX) + # Help getting compilation warnings + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + if(WIN32) + # This includes enough debug information to get something useful from Dr. + # Mingw while keeping binary size down. Almost useless with gdb, though. + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb0 -gstabs2") + endif() +endif() -IF (ENABLE_MANASERV) - INCLUDE_DIRECTORIES("../libs/enet/include") - LINK_DIRECTORIES("../libs/enet") - SET(INTERNAL_LIBRARIES enet) +add_compile_definitions(PACKAGE_VERSION="${PROJECT_VERSION}" + $<$<CONFIG:Debug>:DEBUG>) - SET(FLAGS "${FLAGS} -DMANASERV_SUPPORT=1") - MESSAGE(STATUS "Manaserv support enabled") -ENDIF() +if(WIN32) + add_compile_definitions(PKG_DATADIR="${CMAKE_INSTALL_DATADIR}/" + LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}/") +elseif(NOT APPLE) + add_compile_definitions(PKG_DATADIR="${CMAKE_INSTALL_FULL_DATADIR}/" + LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}/") +endif() -IF (APPLE OR NOT USE_SYSTEM_GUICHAN) - MESSAGE(STATUS "Using Guichan submodule") - SET(GUICHAN_INCLUDE_DIR "../libs/guichan/include") - SET(GUICHAN_LIBRARIES guichan) - LINK_DIRECTORIES("../libs/guichan") -ELSE() - MESSAGE(STATUS "Using system Guichan") - FIND_PACKAGE(Guichan REQUIRED) -ENDIF() +if(ENABLE_MANASERV) + if(NOT USE_SYSTEM_ENET) + message(STATUS "Using ENet submodule") + set(ENET_INCLUDE_DIR "../libs/enet/include") + set(ENET_LIBRARIES enet) + link_directories("../libs/enet") + else() + message(STATUS "Using system ENet") + find_package(ENet REQUIRED) + endif() -IF (ENABLE_NLS) - SET(FLAGS "${FLAGS} -DENABLE_NLS=1") - MESSAGE(STATUS "i18n support enabled") -ENDIF() + add_compile_definitions(MANASERV_SUPPORT=1) + message(STATUS "Manaserv support enabled") +endif() -IF (CMAKE_BUILD_TYPE) - STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) - IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug OR - CMAKE_BUILD_TYPE_TOLOWER MATCHES relwithdebinfo) - SET(FLAGS "${FLAGS} -DDEBUG") - MESSAGE(STATUS "Set Debug build type") - ENDIF() -ENDIF() +if(APPLE OR NOT USE_SYSTEM_GUICHAN) + message(STATUS "Using Guichan submodule") + set(GUICHAN_INCLUDE_DIR "../libs/guichan/include") + set(GUICHAN_LIBRARIES guichan) + link_directories("../libs/guichan") +else() + message(STATUS "Using system Guichan") + find_package(Guichan REQUIRED) +endif() -IF (WIN32) - SET(EXTRA_LIBRARIES ws2_32 winmm) - FIND_PACKAGE(LibIntl REQUIRED) -ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR BEOS) - FIND_PACKAGE(LibIntl REQUIRED) -ELSEIF (CMAKE_SYSTEM_NAME STREQUAL SunOS) - # explicit linking to libintl is required on Solaris - SET(EXTRA_LIBRARIES intl) -ENDIF() +if(ENABLE_NLS) + add_compile_definitions(ENABLE_NLS=1) + message(STATUS "i18n support enabled") +endif() -IF (WITH_OPENGL) - FIND_PACKAGE(OpenGL REQUIRED) - INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) - SET(FLAGS "${FLAGS} -DUSE_OPENGL") - MESSAGE(STATUS "OpenGL support enabled") -ENDIF (WITH_OPENGL) +if(WITH_OPENGL) + find_package(OpenGL REQUIRED) + include_directories(${OPENGL_INCLUDE_DIR}) + add_compile_definitions(USE_OPENGL) + message(STATUS "OpenGL support enabled") +endif(WITH_OPENGL) -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR} - ${SDL2_INCLUDE_DIRS} - ${PNG_INCLUDE_DIR} - ${PHYSFS_INCLUDE_DIR} - ${CURL_INCLUDE_DIR} - ${LIBXML2_INCLUDE_DIR} - ${GUICHAN_INCLUDE_DIR} - ) +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${SDL2_INCLUDE_DIRS} + ${PNG_INCLUDE_DIR} + ${PHYSFS_INCLUDE_DIR} + ${CURL_INCLUDE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${ENET_INCLUDE_DIR} + ${GUICHAN_INCLUDE_DIR} + ${Intl_INCLUDE_DIRS}) -SET(SRCS +set(SRCS gui/widgets/avatarlistbox.cpp gui/widgets/avatarlistbox.h gui/widgets/browserbox.cpp @@ -384,6 +378,8 @@ SET(SRCS utils/physfsrwops.h utils/sha256.cpp utils/sha256.h + utils/specialfolder.cpp + utils/specialfolder.h utils/stringutils.cpp utils/stringutils.h utils/mutex.h @@ -508,10 +504,9 @@ SET(SRCS vector.cpp vector.h video.cpp - video.h - ) + video.h) -SET(SRCS_TMWA +set(SRCS_TMWA net/tmwa/gui/guildtab.cpp net/tmwa/gui/guildtab.h net/tmwa/gui/partytab.cpp @@ -557,10 +552,9 @@ SET(SRCS_TMWA net/tmwa/specialhandler.h net/tmwa/token.h net/tmwa/tradehandler.cpp - net/tmwa/tradehandler.h - ) + net/tmwa/tradehandler.h) -SET(SRCS_MANA +set(SRCS_MANA net/manaserv/adminhandler.cpp net/manaserv/adminhandler.h net/manaserv/beinghandler.cpp @@ -608,49 +602,61 @@ SET(SRCS_MANA net/manaserv/specialhandler.cpp net/manaserv/specialhandler.h net/manaserv/tradehandler.cpp - net/manaserv/tradehandler.h - ) + net/manaserv/tradehandler.h) + +if(WIN32) + configure_file(mana.rc.in mana.rc) + set(SRCS ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/mana.rc) +endif(WIN32) + +set(APP_ICON_NAME "mana.icns") +set(APP_ICON_FILE "${CMAKE_SOURCE_DIR}/data/icons/${APP_ICON_NAME}") +set_source_files_properties(${APP_ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION + "Resources") -IF (WIN32) - CONFIGURE_FILE(mana.rc.in mana.rc) - SET(SRCS - ${SRCS} - utils/specialfolder.cpp - utils/specialfolder.h - ${CMAKE_CURRENT_BINARY_DIR}/mana.rc - ) -ENDIF (WIN32) +if(ENABLE_MANASERV) + add_executable(mana WIN32 ${SRCS} ${SRCS_MANA} ${SRCS_TMWA} ${APP_ICON_FILE}) +else(ENABLE_MANASERV) + add_executable(mana WIN32 ${SRCS} ${SRCS_TMWA} ${APP_ICON_FILE}) +endif(ENABLE_MANASERV) -SET (PROGRAMS mana) +target_link_libraries( + mana + PRIVATE ${ENET_LIBRARIES} + ${SDL2_LINK_LIBRARIES} + ${PNG_LIBRARIES} + ${PHYSFS_LIBRARY} + ${CURL_LIBRARIES} + ${LIBXML2_LIBRARIES} + ${GUICHAN_LIBRARIES} + ${OPENGL_LIBRARIES} + ${Intl_LIBRARIES}) -IF (ENABLE_MANASERV) - ADD_EXECUTABLE(mana WIN32 ${SRCS} ${SRCS_MANA} ${SRCS_TMWA}) -ELSE(ENABLE_MANASERV) - ADD_EXECUTABLE(mana WIN32 ${SRCS} ${SRCS_TMWA}) -ENDIF(ENABLE_MANASERV) +set_target_properties( + mana + PROPERTIES MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME} + MACOSX_BUNDLE_GUI_IDENTIFIER org.manasource.Mana + MACOSX_BUNDLE_ICON_FILE ${APP_ICON_NAME} + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_COPYRIGHT "(C) 2004-2024 ${CPACK_PACKAGE_VENDOR}" + MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING + ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) -TARGET_LINK_LIBRARIES(mana PRIVATE - ${INTERNAL_LIBRARIES} - ${SDL2_LINK_LIBRARIES} - ${PNG_LIBRARIES} - ${PHYSFS_LIBRARY} - ${CURL_LIBRARIES} - ${LIBXML2_LIBRARIES} - ${GUICHAN_LIBRARIES} - ${OPENGL_LIBRARIES} - ${LIBINTL_LIBRARIES} - ${EXTRA_LIBRARIES}) +install( + TARGETS mana + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(APPLE) target_link_libraries(mana PRIVATE "-framework Foundation") -endif() - -INSTALL(TARGETS mana RUNTIME DESTINATION ${PKG_BINDIR}) + set_target_properties(mana PROPERTIES OUTPUT_NAME Mana) -IF (CMAKE_SYSTEM_NAME STREQUAL SunOS) - # we expect the SMCgtxt package to be present on Solaris; - # the Solaris gettext is not API-compatible to GNU gettext - SET_TARGET_PROPERTIES(mana PROPERTIES LINK_FLAGS "-L/usr/local/lib") -ENDIF() + set(CPACK_GENERATOR "DRAGNDROP") -SET_TARGET_PROPERTIES(mana PROPERTIES COMPILE_FLAGS "${FLAGS}") + install( + CODE "include(BundleUtilities) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Mana.app\" \"\" \"/usr/local/lib\")" + ) +endif() |