winsparkle icon indicating copy to clipboard operation
winsparkle copied to clipboard

Fix CMake build

Open Youw opened this issue 7 years ago • 8 comments

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.

Youw avatar Jan 10 '18 12:01 Youw

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 "[email protected]")

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

vslavik avatar Jan 10 '18 16:01 vslavik

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

Youw avatar Jan 10 '18 16:01 Youw

I've tried - it is much more complicated.

Sorry :(

vslavik avatar Jan 10 '18 16:01 vslavik

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.

Youw avatar Jan 10 '18 16:01 Youw

I have own fix.

drizt avatar Jan 11 '18 14:01 drizt

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

drizt avatar Jan 11 '18 15:01 drizt

I have own fix.

@drizt Please submit a PR. Thanks!

vslavik avatar Jan 17 '18 14:01 vslavik

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)

R2RT avatar May 14 '19 07:05 R2RT