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

Fix broken cmake support for MinGW32 #230

Merged
merged 4 commits into from
Jun 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,20 +37,25 @@ 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")
set(OPENSSL_INCLUDE_DIRS "${ROOT_DIR}/3rdparty/openssl-win32")

# bundled expat
add_subdirectory(expat)

# bundled wxWidgets
add_subdirectory(wxWidgets)

# bundled crypto
add_subdirectory(crypto)

# WinSparkle
set(SOURCE_DIR ${ROOT_DIR}/src)

include_directories(${ROOT_DIR}/include)
include_directories(${EXPAT_INCLUDE_DIRS})
include_directories(${wxWidgets_INCLUDE_DIRS})
include_directories(${OPENSSL_INCLUDE_DIRS})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

Expand All @@ -57,7 +64,8 @@ add_definitions(
-DNTDDI_VERSION=0x06000000
-DBUILDING_WIN_SPARKLE
-DXML_STATIC
-DUNICODE -D_UNICODE)
-DUNICODE -D_UNICODE
-U__STRICT_ANSI__)

set(SOURCES
${SOURCE_DIR}/appcast.cpp
Expand All @@ -77,18 +85,27 @@ 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)
file(GLOB PO_FILES ${ROOT_DIR}/translations/*.po)
foreach(PO_FILE ${PO_FILES})
get_filename_component(LANG ${PO_FILE} NAME_WLE)
add_custom_command(OUTPUT ${LANG}.mo
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -c -o ${LANG}.mo ${PO_FILE}
DEPENDS ${PO_FILE}
)
list(APPEND MO_FILES ${LANG}.mo)
endforeach()

add_library(${PROJECT_NAME} SHARED ${SOURCES} $<TARGET_OBJECTS:wxWidgets> $<TARGET_OBJECTS:expat>)
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_OBJECTS:wxWidgets> $<TARGET_OBJECTS:expat> $<TARGET_OBJECTS:crypto>)

target_link_libraries(${PROJECT_NAME} wininet version rpcrt4 comctl32 crypt32)
target_link_libraries(${PROJECT_NAME} wininet version rpcrt4 comctl32 crypt32 wsock32 ws2_32 UxTheme Shlwapi)

set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}
Expand Down
7 changes: 7 additions & 0 deletions cmake/common.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
MinGW can't compile multiple .rc files. Only single.
*/

#include "../translations/translations.rc"
#include "../src/winsparkle.rc"

Loading