--- a/QTfrontend/CMakeLists.txt Sun Oct 28 15:18:26 2012 +0100
+++ b/QTfrontend/CMakeLists.txt Fri Dec 06 22:20:53 2019 +0100
@@ -1,38 +1,83 @@
-# Configure for Qt4
-set(QT_MIN_VERSION "4.5.0")
+if(APPLE AND EXISTS /usr/local/opt/qt5)
+ # Special treatment for OS X users who
+ # install Qt5 via Homebrew.
+ # Homebrew installs Qt5 (up to at least 5.9.1) in
+ # /usr/local/qt5, ensure it can be found by CMake since
+ # it is not in the default /usr/local prefix.
+ list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5")
+endif()
+
+find_package(Qt5 COMPONENTS Core Widgets Gui Network)
+
+include_directories(${Qt5Core_PRIVATE_INCLUDE_DIRS})
+
include(CheckLibraryExists)
-set(QT_USE_QTCORE TRUE)
-set(QT_USE_QTGUI TRUE)
-set(QT_USE_QTNETWORK TRUE)
-set(QT_USE_QTSVG FALSE)
-set(QT_USE_QTXML FALSE)
-set(QT_USE_QTOPENGL FALSE)
-set(QT_USE_QTMAIN TRUE)
+find_package(SDL2 REQUIRED)
+find_package(SDL2_mixer 2 REQUIRED) #audio in SDLInteraction
+include_directories(${SDL2_INCLUDE_DIR})
+include_directories(${SDL2_MIXER_INCLUDE_DIRS})
-find_package(Qt4 REQUIRED)
-if (NOT CROSSAPPLE)
- include(${QT_USE_FILE})
+if(LIBAV_FOUND)
+ add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS)
+ include_directories(${LIBAV_INCLUDE_DIR})
+ list(APPEND HW_LINK_LIBS ${LIBAV_LIBRARIES})
endif()
-# Check if we need zlib
-check_library_exists("${QT_QTCORE_LIBRARY}" inflateInit2_ ${QT_LIBRARY_DIR} QT_PROVIDES_ZLIB_FUNCTIONS)
+# server messages localization
+file(GLOB ServerSources ${CMAKE_SOURCE_DIR}/gameServer/*.hs)
+foreach(hsfile ${ServerSources})
+ file(READ ${hsfile} hs)
+ string(REGEX MATCHALL "loc *\"[^\n\"]+\"" locs ${hs})
+ foreach(str ${locs})
+ string(REGEX REPLACE "loc *\"([^\n\"]+)\"" "QT_TRANSLATE_NOOP(\"server\", \"\\1\")" s ${str})
+ list(APPEND serverlocs ${s})
+ endforeach(str)
+endforeach(hsfile)
-if(NOT QT_PROVIDES_ZLIB_FUNCTIONS)
- find_package(ZLIB REQUIRED)
-
- set(HW_LINK_LIBS ${ZLIB_LIBRARIES} ${HW_LINK_LIBS})
-endif()
+list(REMOVE_DUPLICATES serverlocs)
+list(GET serverlocs 0 firstline)
+list(REMOVE_AT serverlocs 0)
+set(locsout "const char * serverMessages[] = {\n")
+foreach(l ${serverlocs})
+ list(APPEND locsout ${l} ",\n")
+endforeach(l)
+list(APPEND locsout ${firstline} "\n}\\;\n")
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/servermessages.h ${locsout})
-# Configure for SDL
-find_package(SDL REQUIRED)
-find_package(SDL_mixer REQUIRED)
-if(NOT NOVIDEOREC)
- find_package(FFMPEG)
-endif()
+# Credits localization
+file(GLOB CreditsCSV ${CMAKE_SOURCE_DIR}/QTfrontend/res/credits.csv)
+foreach(csvfile ${CreditsCSV})
+ # Load credits.csv
+ file(READ ${csvfile} csv)
+
+ # Match first line of CSV file
+ string(REGEX MATCH "(E|S|U),\"[^\n\"]+\"" loc_top ${csv})
+ string(REGEX REPLACE "(E|S|U),\"([^\n\"]+)\"" "\nQT_TRANSLATE_NOOP(\"credits\", \"\\2\")" s ${loc_top})
+ list(APPEND csvlocs ${s})
-include_directories(.)
+ # Match remaining lines of CSV file
+ string(REGEX MATCHALL "\n(E|S|U),\"[^\n\"]+\"" locs ${csv})
+ foreach(str ${locs})
+ string(REGEX REPLACE "(E|S|U),\"([^\n\"]+)\"" "QT_TRANSLATE_NOOP(\"credits\", \"\\2\")" s ${str})
+ list(APPEND csvlocs ${s})
+ endforeach(str)
+endforeach(csvfile)
+
+list(REMOVE_DUPLICATES csvlocs)
+list(GET csvlocs 0 firstline)
+list(REMOVE_AT csvlocs 0)
+set(locsout "const char * creditsMessages[] = {")
+foreach(l ${csvlocs})
+ list(APPEND locsout ${l} ",")
+endforeach(l)
+list(APPEND locsout ${firstline} "\n}\\;\n")
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/creditsmessages.h ${locsout})
+
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/net)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui)
@@ -40,33 +85,21 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/page)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/widget)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util)
-include_directories(${SDL_INCLUDE_DIR})
-include_directories(${SDLMIXER_INCLUDE_DIR})
-include_directories(${FFMPEG_INCLUDE_DIR})
-include_directories(${CMAKE_SOURCE_DIR}/misc/quazip)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util/platform)
+include_directories(BEFORE ${PHYSFS_INCLUDE_DIR})
+include_directories(BEFORE ${PHYSLAYER_INCLUDE_DIR})
+include_directories(${LUA_INCLUDE_DIR}) #brought by physlayer hwpacksmounter.h
+
if(UNIX)
# HACK: in freebsd cannot find iconv.h included via SDL.h
include_directories("/usr/local/include")
endif(UNIX)
-
-if(WIN32 AND NOT UNIX)
- set(HEDGEWARS_BINDIR ".")
- set(HEDGEWARS_DATADIR "../share/")
- add_definitions(-DUSE_XFIRE)
-else()
- set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX})
- if(DEFINED DATA_INSTALL_DIR)
- set(HEDGEWARS_DATADIR ${DATA_INSTALL_DIR})
- else()
- set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/share/)
- endif()
- #only the cocoa version of qt supports building 64 bit apps
- if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA))
- message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X")
- endif()
+#only the cocoa version of qt supports building 64 bit apps
+if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA))
+ message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X")
endif()
-
+#endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
@@ -75,11 +108,7 @@
file(GLOB_RECURSE UIcpp ui/*.cpp)
file(GLOB UtilCpp util/*.cpp)
-if(${FFMPEG_FOUND})
- add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS)
-endif()
-
-set(hwfr_src
+list(APPEND hwfr_src
${ModelCpp}
${NetCpp}
${UIcpp}
@@ -94,24 +123,21 @@
main.cpp
team.cpp
campaign.cpp
+ mission.cpp
ui_hwform.cpp
${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/sdlkeys.cpp
)
-#xfire integration
-if(WIN32)
- set(hwfr_src ${hwfr_src} xfire.cpp ../misc/xfire/xfiregameclient.cpp)
-endif(WIN32)
-
if(MINGW)
# resource compilation for mingw
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o
- COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR}
- -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc
- -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
- set(hwfr_src ${hwfr_src} ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
+ COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR}
+ -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc
+ -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
+ list(APPEND hwfr_src ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
else(MINGW)
- set(hwfr_src ${hwfr_src} hedgewars.rc)
+ list(APPEND hwfr_src hedgewars.rc)
endif(MINGW)
file(GLOB ModelHdr model/*.h)
@@ -131,7 +157,7 @@
hwform.h
team.h
util/DataManager.h
- util/libav_iteraction.h
+ util/LibavInteraction.h
)
set(hwfr_hdrs
@@ -143,54 +169,77 @@
hwconsts.h
sdlkeys.h
campaign.h
+ mission.h
+ ${CMAKE_CURRENT_BINARY_DIR}/servermessages.h
+ ${CMAKE_CURRENT_BINARY_DIR}/creditsmessages.h
)
set(hwfr_rez hedgewars.qrc)
-qt4_add_resources(hwfr_rez_src ${hwfr_rez})
-
-qt4_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs})
-
+if(BUILD_ENGINE_LIBRARY)
+ add_definitions(-DHWLIBRARY=1)
+ set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ list(APPEND HW_LINK_LIBS ${hwlibname})
-if(APPLE OR CROSSAPPLE)
- set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m)
- set(HW_LINK_LIBS IOKit ${HW_LINK_LIBS})
-
- if(NOT NOAUTOUPDATE)
- find_package(Sparkle)
- if(SPARKLE_FOUND)
- add_definitions(-DSPARKLE_ENABLED)
- set(hwfr_src ${hwfr_src} AutoUpdater.cpp SparkleAutoUpdater.mm)
- set(HW_LINK_LIBS ${SPARKLE_LIBRARY} ${HW_LINK_LIBS})
- endif()
+ if(LIBAV_FOUND)
+# add_subdirectory(avwrapper)
+ list(APPEND HW_LINK_LIBS avwrapper)
endif()
endif()
+qt5_add_resources(hwfr_rez_src ${hwfr_rez})
-add_executable(hedgewars WIN32
+qt5_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs})
+
+
+if(APPLE)
+ find_library(iokit_framework NAMES IOKit)
+ list(APPEND HW_LINK_LIBS ${iokit_framework})
+ list(APPEND hwfr_src util/platform/CocoaInitializer.mm
+ util/platform/InstallController.cpp
+ util/platform/M3Panel.mm
+ util/platform/M3InstallController.m
+ util/platform/NSWorkspace_RBAdditions.m
+ )
+ include(${CMAKE_MODULE_PATH}/utils.cmake)
+ find_package_or_disable_msg(Sparkle NOAUTOUPDATE "Autoupdater will not be built.")
+ if(SPARKLE_FOUND)
+ add_definitions(-DSPARKLE_ENABLED)
+ list(APPEND hwfr_src util/platform/AutoUpdater.cpp
+ util/platform/SparkleAutoUpdater.mm)
+ list(APPEND HW_LINK_LIBS ${SPARKLE_LIBRARY})
+ endif()
+endif()
+
+#when debugging, always prompt a console to see fronted messages
+#TODO: check it doesn't interfere on UNIX
+if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
+ set(console_access "WIN32")
+endif(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
+
+add_executable(hedgewars ${console_access}
${hwfr_src}
${hwfr_moc_srcs}
${hwfr_hdrs}
${hwfr_rez_src}
)
+list(APPEND HW_LINK_LIBS
+ physfs physlayer
+ Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Network
+ )
-set(HW_LINK_LIBS
- quazip
- ${QT_LIBRARIES}
- ${SDL_LIBRARY}
- ${SDLMIXER_LIBRARY}
- ${FFMPEG_LIBRARIES}
- ${HW_LINK_LIBS}
+list(APPEND HW_LINK_LIBS
+ ${SDL2_LIBRARY}
+ ${SDL2_MIXER_LIBRARIES}
)
if(WIN32 AND NOT UNIX)
- if(NOT SDL_LIBRARY)
- set(HW_LINK_LIBS ${HW_LINK_LIBS} SDL)
+ if(NOT SDL2_LIBRARY)
+ list(APPEND HW_LINK_LIBS SDL2)
endif()
- set(HW_LINK_LIBS
- ${HW_LINK_LIBS}
+ list(APPEND HW_LINK_LIBS
ole32
oleaut32
winspool
@@ -198,13 +247,19 @@
)
endif()
-
-if (CROSSAPPLE)
- add_dependencies(hedgewars quazip)
-else()
- target_link_libraries(hedgewars ${HW_LINK_LIBS})
+if(CMAKE_CXX_COMPILER MATCHES "clang*")
+ list(APPEND HW_LINK_LIBS stdc++ m)
+ if(NOT APPLE)
+ list(APPEND HW_LINK_LIBS atomic)
+ endif()
endif()
+if(WIN32 AND VCPKG_TOOLCHAIN)
+ list(APPEND HW_LINK_LIBS Qt5::WinMain)
+endif()
-install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir})
+target_link_libraries(hedgewars ${HW_LINK_LIBS})
+
+install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_binary_install_dir})
+