From f113f9573d0899596cd4d7b51facf55575acdd20 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 5 Oct 2012 12:38:17 +0000 Subject: [PATCH] - CPack support. Works on my side, needs tweaks for Win --- AI/BattleAI/CMakeLists.txt | 3 + AI/EmptyAI/CMakeLists.txt | 2 + AI/StupidAI/CMakeLists.txt | 3 + AI/VCAI/CMakeLists.txt | 4 +- CMakeLists.txt | 104 +++++++++++++++++++++----- Global.h | 10 +-- Scripting/ERM/CMakeLists.txt | 2 + client/CMakeLists.txt | 3 + client/{ => icons}/vcmiclient.desktop | 2 +- debian/control | 2 +- debian/rules | 5 +- lib/CMakeLists.txt | 2 + server/CMakeLists.txt | 3 + 13 files changed, 114 insertions(+), 31 deletions(-) rename client/{ => icons}/vcmiclient.desktop (93%) diff --git a/AI/BattleAI/CMakeLists.txt b/AI/BattleAI/CMakeLists.txt index 415a423f2..eaf7983e6 100644 --- a/AI/BattleAI/CMakeLists.txt +++ b/AI/BattleAI/CMakeLists.txt @@ -10,3 +10,6 @@ set(battleAI_SRCS add_library(BattleAI SHARED ${battleAI_SRCS}) target_link_libraries(BattleAI vcmi) + +install(TARGETS BattleAI DESTINATION ${AI_LIB_DIR}) + diff --git a/AI/EmptyAI/CMakeLists.txt b/AI/EmptyAI/CMakeLists.txt index 3703fa596..4630de447 100644 --- a/AI/EmptyAI/CMakeLists.txt +++ b/AI/EmptyAI/CMakeLists.txt @@ -10,3 +10,5 @@ set(emptyAI_SRCS add_library(EmptyAI SHARED ${emptyAI_SRCS}) target_link_libraries(EmptyAI vcmi) + +install(TARGETS EmptyAI DESTINATION ${AI_LIB_DIR}) diff --git a/AI/StupidAI/CMakeLists.txt b/AI/StupidAI/CMakeLists.txt index 320812718..d3e9c53e7 100644 --- a/AI/StupidAI/CMakeLists.txt +++ b/AI/StupidAI/CMakeLists.txt @@ -10,3 +10,6 @@ set(stupidAI_SRCS add_library(StupidAI SHARED ${stupidAI_SRCS}) target_link_libraries(StupidAI vcmi) + +install(TARGETS StupidAI DESTINATION ${AI_LIB_DIR}) + diff --git a/AI/VCAI/CMakeLists.txt b/AI/VCAI/CMakeLists.txt index 1641e8efd..ad5f9d0e3 100644 --- a/AI/VCAI/CMakeLists.txt +++ b/AI/VCAI/CMakeLists.txt @@ -10,4 +10,6 @@ set(VCAI_SRCS ) add_library(VCAI SHARED ${VCAI_SRCS}) -target_link_libraries(VCAI FuzzyLite_lib vcmi) \ No newline at end of file +target_link_libraries(VCAI FuzzyLite_lib vcmi) + +install(TARGETS VCAI DESTINATION ${AI_LIB_DIR}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67cf9bf8d..493438329 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,6 @@ project(vcmi) cmake_minimum_required(VERSION 2.6) -#needed? -INCLUDE(CheckLibraryExists) - # where to look for cmake modules set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) @@ -12,37 +9,57 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() +option(DISABLE_ERM "Disable compilation of ERM scripting module" OFF) + +############################################ +# Building section # +############################################ + find_package(Boost 1.46.0 COMPONENTS program_options filesystem system thread iostreams REQUIRED) find_package(SDL REQUIRED) find_package(SDL_image REQUIRED) find_package(SDL_mixer REQUIRED) find_package(SDL_ttf REQUIRED) find_package(ZLIB REQUIRED) -find_package(FFMPEG_swscale REQUIRED) -#check if some platform-specific libraries are needed for linking client and server -CHECK_LIBRARY_EXISTS(rt shm_open "" HAVE_RT_LIB) -if(HAVE_RT_LIB) - set(RT_LIB -lrt) +if(NOT WIN32) + find_package(FFMPEG_swscale REQUIRED) + + INCLUDE(CheckLibraryExists) + + #check if some platform-specific libraries are needed for linking client and server + CHECK_LIBRARY_EXISTS(rt shm_open "" HAVE_RT_LIB) + if(HAVE_RT_LIB) + set(RT_LIB -lrt) + endif() + + CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DL_LIB) + if(HAVE_DL_LIB) + set(DL_LIB -ldl) + endif() endif() -CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DL_LIB) -if(HAVE_DL_LIB) - set(DL_LIB -ldl) +if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support such parameters + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wno-overloaded-virtual") endif() -if(CMAKE_CXX_COMPILER MATCHES ".*clang") - set(CMAKE_COMPILER_IS_CLANGXX ON) +if(WIN32) # on Win everything goes into H3 root directory + set(BIN_DIR "" CACHE STRING "Where to install binaries") + set(LIB_DIR "" CACHE STRING "Where to install main library") + set(DATA_DIR "" CACHE STRING "Where to install data files") +else() + set(BIN_DIR "bin" CACHE STRING "Where to install binaries") + set(LIB_DIR "lib/vcmi" CACHE STRING "Where to install main library") + set(DATA_DIR "share/vcmi" CACHE STRING "Where to install data files") endif() -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wno-overloaded-virtual") -endif() +set (AI_LIB_DIR "${LIB_DIR}/AI") +set (SCRIPTING_LIB_DIR "${LIB_DIR}/Scripting") #define required constants -add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/vcmi") -add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/bin") -add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/lib/vcmi") +add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_DIR}") +add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/${BIN_DIR}") +add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/${LIB_DIR}") add_subdirectory(lib) add_subdirectory(client) @@ -52,3 +69,52 @@ if (NOT DISABLE_ERM) add_subdirectory(Scripting/ERM) endif() +####################################### +# Installation section # +####################################### + +# copy whole directory but .svn control files and user-specific settings.json +install(DIRECTORY config DESTINATION ${DATA_DIR} PATTERN ".svn" EXCLUDE PATTERN "settings.json" EXCLUDE) +# copy vcmi mod along with all its content +install(DIRECTORY Mods/vcmi DESTINATION ${DATA_DIR}/Mods PATTERN ".svn" EXCLUDE) +# copy only fs.json for WoG +install(FILES Mods/WoG/filesystem.json DESTINATION ${DATA_DIR}/Mods/WoG) + +if(WIN32) + #TODO: install any additional dll's. This version (may be broken) will copy all dll's including H3 ones + #FILE(GLOB dll_files "${CMAKE_BINARY_DIR}/*.dll") + #INSTALL(FILES ${dll_files} DESTINATION ${BIN_DIR}) +else() + #install icons and desktop file on Linux + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.64x64.png" DESTINATION share/icons/hicolor/64x64/apps RENAME vcmiclient.png) + + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.48x48.png" DESTINATION share/icons/hicolor/48x48/apps RENAME vcmiclient.png) + + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.32x32.png" DESTINATION share/icons/hicolor/32x32/apps RENAME vcmiclient.png) + + install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.desktop" DESTINATION share/applications) + +endif() + +####################################### +# Packaging section # +####################################### + +set(CPACK_PACKAGE_VERSION_MAJOR 0) +set(CPACK_PACKAGE_VERSION_MINOR 90) +set(CPACK_PACKAGE_VERSION_PATCH 0) + +# vcmi does not have "patch version" in version string +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") +#TODO: remove version from Global.h and use this one as define? + +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) + +if(WIN32) + set(CPACK_GENERATOR ZIP) # just use zip? CPack has some GUI install as well +else() + set(CPACK_GENERATOR TGZ) +endif() + +INCLUDE(CPack) + diff --git a/Global.h b/Global.h index 99178bc05..c403225cc 100644 --- a/Global.h +++ b/Global.h @@ -177,17 +177,17 @@ public: bmap() {} - +#if 0 // What is _Myt? gcc\clang does not have that bmap(const typename std::map::_Myt& _Right) - : std::map(_Right) + : std::map(_Right) {} - +#endif explicit bmap(const typename std::map::key_compare& _Pred) - : std::map(_Pred) + : std::map(_Pred) {} bmap(const typename std::map::key_compare& _Pred, const typename std::map::allocator_type& _Al) - : std::map(_Pred, _Al) + : std::map(_Pred, _Al) {} template diff --git a/Scripting/ERM/CMakeLists.txt b/Scripting/ERM/CMakeLists.txt index 8a157d314..294ffe704 100644 --- a/Scripting/ERM/CMakeLists.txt +++ b/Scripting/ERM/CMakeLists.txt @@ -11,3 +11,5 @@ set(lib_SRCS add_library(vcmiERM SHARED ${lib_SRCS}) target_link_libraries(vcmiERM ${Boost_LIBRARIES}) + +install(TARGETS vcmiERM DESTINATION ${SCRIPTING_LIB_DIR}) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 0c1886cea..7e67f59a7 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -49,3 +49,6 @@ ELSEIF(WIN32) ENDIF() target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${RT_LIB} ${DL_LIB}) + +install(TARGETS vcmiclient DESTINATION ${BIN_DIR}) + diff --git a/client/vcmiclient.desktop b/client/icons/vcmiclient.desktop similarity index 93% rename from client/vcmiclient.desktop rename to client/icons/vcmiclient.desktop index 64466b395..e47131bdd 100644 --- a/client/vcmiclient.desktop +++ b/client/icons/vcmiclient.desktop @@ -6,4 +6,4 @@ Comment=Open engine for Heroes of Might and Magic 3 Icon=vcmiclient Exec=vcmiclient Categories=Game;StrategyGame; -Version=0.89 +Version=0.90 diff --git a/debian/control b/debian/control index 850065700..ecbfc6b9a 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: vcmi Section: games Priority: optional Maintainer: frank zago -Build-Depends: debhelper (>= 8), cdbs (>= 0.4.48), autotools-dev, libsdl-image1.2-dev, libsdl-ttf2.0-dev, libsdl-mixer1.2-dev (>= 1.2.8), zlib1g-dev, libavformat-dev, libswscale-dev, libboost-dev (>=1.44), libboost-program-options-dev (>=1.44), libboost-filesystem-dev (>=1.44), libboost-system-dev (>=1.44), libboost-thread-dev (>=1.44) +Build-Depends: debhelper (>= 8), cdbs (>= 0.4.48), cmake, libsdl-image1.2-dev, libsdl-ttf2.0-dev, libsdl-mixer1.2-dev (>= 1.2.8), zlib1g-dev, libavformat-dev, libswscale-dev, libboost-dev (>=1.44), libboost-program-options-dev (>=1.44), libboost-filesystem-dev (>=1.44), libboost-system-dev (>=1.44), libboost-thread-dev (>=1.44) Standards-Version: 3.9.1 Homepage: http://vcmi.eu diff --git a/debian/rules b/debian/rules index d466bacd8..254a3004d 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,4 @@ #!/usr/bin/make -f -include /usr/share/cdbs/1/class/autotools.mk +include /usr/share/cdbs/1/class/cmake.mk include /usr/share/cdbs/1/rules/debhelper.mk - -override_dh_auto_configure: - dh_auto_configure -- --disable-debug --bindir=/usr/games diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 9ebc0334c..3c621f7fd 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -49,3 +49,5 @@ set(lib_SRCS add_library(vcmi SHARED ${lib_SRCS}) target_link_libraries(vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${ZLIB_LIBRARIES}) + +install(TARGETS vcmi DESTINATION ${LIB_DIR}) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 63385a2cd..f15a00185 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -17,3 +17,6 @@ ELSEIF(WIN32) ENDIF() target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES} ${RT_LIB} ${DL_LIB}) + +install(TARGETS vcmiserver DESTINATION ${BIN_DIR}) +