From 52d0b9f87b2882d80ae26a3dd7c1750b97b2b9ef Mon Sep 17 00:00:00 2001 From: Ivan Romanov Date: Thu, 11 Jan 2018 20:06:35 +0500 Subject: [PATCH] Update CMake scripts --- cmake/CMakeLists.txt | 70 +++++++++++++++++++++--- cmake/common.rc | 7 +++ cmake/expat/CMakeLists.txt | 11 +++- cmake/expat/expat_config.h.cmake | 91 ++++++++++++++++++++++++++++++++ 4 files changed, 169 insertions(+), 10 deletions(-) create mode 100644 cmake/common.rc create mode 100644 cmake/expat/expat_config.h.cmake diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 35703618..a5392db6 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -14,6 +14,8 @@ endif() cmake_policy(SET CMP0022 NEW) +find_package(Gettext REQUIRED) + get_filename_component(ROOT_DIR ${CMAKE_SOURCE_DIR}/.. REALPATH) # Parse version header to always have actual version of winsparkle @@ -35,7 +37,7 @@ set(INCLUDE_INSTALL_DIR "include") set(CONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}") set(CMAKE_DEBUG_POSTFIX "d") -set(EXPAT_INCLUDE_DIRS "${ROOT_DIR}/3rdparty/expat/lib") +set(EXPAT_INCLUDE_DIRS "${ROOT_DIR}/3rdparty/expat/expat/lib") # bundled expat add_subdirectory(expat) @@ -76,19 +78,71 @@ set(PUBLIC_HEADERS ${ROOT_DIR}/include/winsparkle.h ${ROOT_DIR}/include/winsparkle-version.h) -set(RESOURCES winsparkle translations) - -# resource compilation for MinGW -foreach(RESOURCE ${RESOURCES}) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE}.o - COMMAND ${CMAKE_RC_COMPILER} -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE}.rc - -o ${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE}.o) +set(LANGUAGES + ar + be + bg + bs + ca_ES + co + cs + da + de + el + es + eu + fr + fy_NL + ga + he + hr + hu + hy + id + it + ja + kk + ko + nb + nl + pl + pt_BR + pt_PT + ru + sk + sr + sv + tr + uk + zh_CN + zh_TW +) + +foreach(LANG ${LANGUAGES}) + add_custom_command(OUTPUT ${LANG}.mo + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -c -o ${LANG}.mo ${ROOT_DIR}/translations/${LANG}.po + DEPENDS ${ROOT_DIR}/translations/${LANG}.po + ) + + list(APPEND MO_FILES ${LANG}.mo) endforeach() +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/common_res.o + COMMAND ${CMAKE_RC_COMPILER} -O coff -I${ROOT_DIR}/include -i ${CMAKE_CURRENT_SOURCE_DIR}/common.rc + -o ${CMAKE_CURRENT_BINARY_DIR}/common_res.o + DEPENDS ${MO_FILES} +) + +list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/common_res.o) + add_library(${PROJECT_NAME} SHARED ${SOURCES} $ $) target_link_libraries(${PROJECT_NAME} wininet version rpcrt4 comctl32) +#set_target_properties(${PROJECT_NAME} PROPERTIES +# LINK_FLAGS "translations.res winsparkle.res" +#) + set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION} PUBLIC_HEADER "${PUBLIC_HEADERS}" diff --git a/cmake/common.rc b/cmake/common.rc new file mode 100644 index 00000000..934b5c86 --- /dev/null +++ b/cmake/common.rc @@ -0,0 +1,7 @@ +/* +MinGW can't compile multiple .rc files. Only single. +*/ + +#include "../translations/translations.rc" +#include "../src/winsparkle.rc" + diff --git a/cmake/expat/CMakeLists.txt b/cmake/expat/CMakeLists.txt index 644f2f22..7f29f624 100755 --- a/cmake/expat/CMakeLists.txt +++ b/cmake/expat/CMakeLists.txt @@ -1,11 +1,15 @@ project(expat) -set(SOURCE_DIR ${ROOT_DIR}/3rdparty/expat) +set(SOURCE_DIR ${ROOT_DIR}/3rdparty/expat/expat) + +file(COPY ${SOURCE_DIR}/expat_config.h.cmake + DESTINATION ${CMAKE_CURRENT_SOURCE_DIR} +) cmake_minimum_required(VERSION 2.6) set(PACKAGE_BUGREPORT "expat-bugs@libexpat.org") set(PACKAGE_NAME "expat") -set(PACKAGE_VERSION "2.1.0") +set(PACKAGE_VERSION "2.2.3") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}") @@ -31,8 +35,11 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${SOURCE_DIR}/lib) if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996) endif(MSVC) +add_definitions(-DWIN32) +add_definitions(-DXML_STATIC) set(expat_SRCS + ${SOURCE_DIR}/lib/loadlibrary.c ${SOURCE_DIR}/lib/xmlparse.c ${SOURCE_DIR}/lib/xmlrole.c ${SOURCE_DIR}/lib/xmltok.c diff --git a/cmake/expat/expat_config.h.cmake b/cmake/expat/expat_config.h.cmake new file mode 100644 index 00000000..25d79a6d --- /dev/null +++ b/cmake/expat/expat_config.h.cmake @@ -0,0 +1,91 @@ +/* expat_config.h.in. Generated from configure.in by autoheader. */ + +/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ +#cmakedefine BYTEORDER @BYTEORDER@ + +/* Define to 1 if you have the `bcopy' function. */ +#cmakedefine HAVE_BCOPY + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H + +/* Define to 1 if you have the `getpagesize' function. */ +#cmakedefine HAVE_GETPAGESIZE + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H + +/* Define to 1 if you have the `memmove' function. */ +#cmakedefine HAVE_MEMMOVE + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H + +/* Define to 1 if you have a working `mmap' system call. */ +#cmakedefine HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS + +/* whether byteorder is bigendian */ +#cmakedefine WORDS_BIGENDIAN + +/* Define to specify how much context to retain around the current parse + point. */ +#cmakedefine XML_CONTEXT_BYTES @XML_CONTEXT_BYTES@ + +/* Define to make parameter entity parsing functionality available. */ +#cmakedefine XML_DTD + +/* Define to make XML Namespaces functionality available. */ +#cmakedefine XML_NS + +/* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */ +#ifdef _MSC_VER +# define __func__ __FUNCTION__ +#endif + +/* Define to `long' if does not define. */ +#cmakedefine off_t @OFF_T@ + +/* Define to `unsigned' if does not define. */ +#cmakedefine size_t @SIZE_T@