vslavik / winsparkle

App update framework for Windows, inspired by Sparkle for macOS
http://winsparkle.org
Other
1.31k stars 267 forks source link

Fix CMake build #159

Open Youw opened 6 years ago

Youw commented 6 years ago

After one of the expat updates, CMake build is no longer working.

I did a quick look at it - the issue is that expat being moved to expat/expat.

Not going to prepare a PR right now - just to keep track of things.

vslavik commented 6 years ago

cb5ac6e71fbc80bcca502cc2fb9e9ec1ba1f11ee is the responsible commit.

I think this simple change should fix it:

--- a/cmake/expat/CMakeLists.txt
+++ b/cmake/expat/CMakeLists.txt
@@ -1,6 +1,6 @@
 project(expat)

-set(SOURCE_DIR ${ROOT_DIR}/3rdparty/expat)
+set(SOURCE_DIR ${ROOT_DIR}/3rdparty/expat/expat)

 cmake_minimum_required(VERSION 2.6)
 set(PACKAGE_BUGREPORT "expat-bugs@libexpat.org")

@drizt (as the one user of the cmake build known to me), any chance you could verify it?

Youw commented 6 years ago

I've tried - it is much more complicated. Let me share my results.

vslavik commented 6 years ago

I've tried - it is much more complicated.

Sorry :(

Youw commented 6 years ago

As a matter of sport interest, I have a fix here: https://github.com/Youw/winsparkle/commit/ded0c90c4e0dbd4a29ee0fbd646d72593b384f11 But I wouldn't take it as a solution - install target collects some garbage (like expat headers ans static lib).

Maybe someone, who more interested in CMake build, might improve it.

On the other hand, not entirely correct but working - is better solution, than broken.

drizt commented 6 years ago

I have own fix.

drizt commented 6 years ago

Look here https://github.com/drizt/winsparkle/tree/fix-cmake

vslavik commented 6 years ago

I have own fix.

@drizt Please submit a PR. Thanks!

R2RT commented 5 years ago

I've tried to follow up work on this, but eventually, I gave up... I ended up with using ExternalProject in CMake, it is hardcoded for x64 Release for VS 2017, as it is enough for me. Hard part was learning about nuget downloaded package. Maybe someone will find it useful

include(ExternalProject)
ExternalProject_Add(winsparkle
    GIT_REPOSITORY    https://github.com/vslavik/winsparkle.git
    GIT_TAG           0388af88deb6bf399d5ccebbfe8a63579ec4d2b2
    GIT_SHALLOW On
    CONFIGURE_COMMAND ""
    BUILD_IN_SOURCE On
    BUILD_COMMAND msbuild.exe WinSparkle-2017.sln /p:configuration=Release,Platform=x64,BuildProjectReferences=true /t:WinSparkle
    INSTALL_COMMAND ""
    BYPRODUCTS <SOURCE_DIR>/x64/Release/WinSparkle.dll <SOURCE_DIR>/x64/Release/WinSparkle.lib
    EXCLUDE_FROM_ALL On
    BUILD_ALWAYS Off
)

ExternalProject_Add_Step(winsparkle nuget
    COMMAND nuget restore WinSparkle-2017.sln
    WORKING_DIRECTORY <SOURCE_DIR>
    COMMENT "Downloading required nuget packages"
    DEPENDEES configure
    DEPENDERS build
)

ExternalProject_Get_property(winsparkle SOURCE_DIR)
file(MAKE_DIRECTORY ${SOURCE_DIR}/include)

add_library(Winsparkle::Winsparkle IMPORTED SHARED)
set_target_properties(Winsparkle::Winsparkle PROPERTIES
    IMPORTED_LOCATION "${SOURCE_DIR}/x64/Release/WinSparkle.dll"
    IMPORTED_IMPLIB "${SOURCE_DIR}/x64/Release/WinSparkle.lib"
    INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/include"
)

add_library(foo foo.cpp)
target_link_libraries(foo PRIVATE Winsparkle::Winsparkle)