Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wzmaplib, improve CMake config #6

Merged
merged 2 commits into from Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 39 additions & 26 deletions CMakeLists.txt
Expand Up @@ -24,6 +24,13 @@ endif()

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

get_directory_property(hasParent PARENT_DIRECTORY)
if(PROJECT_IS_TOP_LEVEL OR NOT hasParent) # PROJECT_IS_TOP_LEVEL is only available in CMake 3.21+
set(is_top_level ON)
endif()
option(maptools_INSTALL "Install maptools" "${is_top_level}")
option(maptools_INCLUDE_PACKAGING "Include packaging rules for maptools" "${is_top_level}")

include(GNUInstallDirs)
include(HardenTargets)

Expand All @@ -40,7 +47,7 @@ if(NOT TARGET wzmaplib)
FetchContent_Declare(
warzone2100_repo
GIT_REPOSITORY https://github.com/Warzone2100/warzone2100.git
GIT_TAG 0c0e6c466861fb22eaf43bf92a8914d6ea146ced
GIT_TAG 6f01806777f64dd7e60417fb299cfea8ef8e9939
GIT_PROGRESS TRUE
USES_TERMINAL_DOWNLOAD TRUE
)
Expand Down Expand Up @@ -111,12 +118,14 @@ set(WZ_APP_INSTALL_DEST "${CMAKE_INSTALL_BINDIR}")

############################
# Install
install(TARGETS maptools DESTINATION "${WZ_APP_INSTALL_DEST}")
if(maptools_INSTALL)
install(TARGETS maptools DESTINATION "${WZ_APP_INSTALL_DEST}")
endif()

############################
# Installing Required Runtime Dependencies

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(maptools_INSTALL AND CMAKE_SYSTEM_NAME MATCHES "Windows")
set(_mainexename "maptools")
if(_mainexename)
if(NOT CMAKE_CROSSCOMPILING)
Expand Down Expand Up @@ -252,31 +261,35 @@ endif()
############################
# Packaging

set(CPACK_PACKAGE_NAME "maptools CLI")
set(CPACK_PACKAGE_VENDOR "Warzone 2100 Project")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_PACKAGE_HOMEPAGE_URL "https://wz2100.net")
if(maptools_INCLUDE_PACKAGING)

if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
# Default of "maptools"
set(CPACK_PACKAGE_FILE_NAME "maptools")
endif()
set(CPACK_PACKAGE_NAME "maptools CLI")
set(CPACK_PACKAGE_VENDOR "Warzone 2100 Project")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_PACKAGE_HOMEPAGE_URL "https://wz2100.net")

if(NOT DEFINED CPACK_SOURCE_PACKAGE_FILE_NAME)
# Default of "maptools"
set(CPACK_SOURCE_PACKAGE_FILE_NAME "maptools")
endif()
if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
# Default of "maptools"
set(CPACK_PACKAGE_FILE_NAME "maptools")
endif()

if(NOT DEFINED CPACK_SOURCE_PACKAGE_FILE_NAME)
# Default of "maptools"
set(CPACK_SOURCE_PACKAGE_FILE_NAME "maptools")
endif()

set(CPACK_GENERATOR "ZIP")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE)
set(CPACK_GENERATOR "ZIP")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE)

# Ignore version control
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git")
# Ignore various CI / Github-config related files
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.github/")
# Ignore development / runtime created files
list (APPEND CPACK_SOURCE_IGNORE_FILES "~$")
list (APPEND CPACK_SOURCE_IGNORE_FILES "\\\\.DS_Store$")
# Ignore version control
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git")
# Ignore various CI / Github-config related files
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.github/")
# Ignore development / runtime created files
list (APPEND CPACK_SOURCE_IGNORE_FILES "~$")
list (APPEND CPACK_SOURCE_IGNORE_FILES "\\\\.DS_Store$")

include(CPack)
include(CPack)

endif()
8 changes: 4 additions & 4 deletions src/maptools_version.cpp
Expand Up @@ -23,7 +23,7 @@
#include <wzmaplib/map_version.h>
#include <nlohmann/json.hpp>
#if !defined(WZ_MAPTOOLS_DISABLE_ARCHIVE_SUPPORT)
#include <zip.h>
#include <ZipIOProvider.h>
#endif
#include <png.h>

Expand All @@ -37,10 +37,10 @@ std::string generateMapToolsVersionInfo()
versionInfo << " wzmaplib/" << WzMap::wzmaplib_version_string();
versionInfo << " nlohmann-json/" << stringify_(NLOHMANN_JSON_VERSION_MAJOR) "." stringify_(NLOHMANN_JSON_VERSION_MINOR) "." stringify_(NLOHMANN_JSON_VERSION_PATCH);
#if !defined(WZ_MAPTOOLS_DISABLE_ARCHIVE_SUPPORT)
const char* verStr = zip_libzip_version();
if (verStr)
auto zipVerStr = WzMapZipIO::getZipLibraryVersionString();
if (!zipVerStr.empty())
{
versionInfo << " libzip/" << verStr;
versionInfo << " " << zipVerStr;
}
#endif
versionInfo << " libpng/" << PNG_LIBPNG_VER_STRING;
Expand Down