-
-
Notifications
You must be signed in to change notification settings - Fork 180
Use CPack with TARGET_RUNTIME_DLLS for Windows packaging #1897
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -84,7 +84,10 @@ else(GIT) | |||||||||||||
| endif(GIT) | ||||||||||||||
|
|
||||||||||||||
| find_package(PkgConfig) | ||||||||||||||
| if(MSVC OR NOT PKG_CONFIG_FOUND) | ||||||||||||||
| if(MSVC) | ||||||||||||||
| find_package(ZLIB REQUIRED CONFIG) | ||||||||||||||
| find_package(PNG REQUIRED CONFIG) | ||||||||||||||
|
Comment on lines
+88
to
+89
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||
| elseif(NOT PKG_CONFIG_FOUND) | ||||||||||||||
| # fallback to find_package | ||||||||||||||
| # cmake's FindPNG is very fragile; it breaks when multiple versions are installed | ||||||||||||||
| # this is most evident on macOS but can occur on Linux too | ||||||||||||||
|
|
@@ -132,3 +135,20 @@ foreach(SECTION "man1" "man5" "man7") | |||||||||||||
| set(DEST "${MANDIR}/${SECTION}") | ||||||||||||||
| install(FILES ${${SECTION}} DESTINATION ${DEST}) | ||||||||||||||
| endforeach() | ||||||||||||||
|
|
||||||||||||||
| if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.21") | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking it wouldn't be a bad idea to enable CPack across all platforms. (In particular, it may be useful to generate our releases' source tarballs, though any tweaking related to that can come in a separate PR.) |
||||||||||||||
| if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||||||||||||||
| set(CPACK_SYSTEM_NAME "win64") | ||||||||||||||
| else() | ||||||||||||||
| set(CPACK_SYSTEM_NAME "win32") | ||||||||||||||
| endif() | ||||||||||||||
|
Comment on lines
+140
to
+144
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pointer size check looks cursed as hell, hopefully there's a better way to do this... EDIT: Turns out that
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| set(CPACK_GENERATOR "ZIP") | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this gets overridden with the |
||||||||||||||
| set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAICT, this is best left undefined so that e.g. tarballs can be properly generated. (It would be necessary to pass it to generate the Windows zip files, but we can do that with
Suggested change
|
||||||||||||||
| set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}") | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This appears to be the default behaviour (though I'd need to check, but I don't have a Windows machine handy.)
Suggested change
|
||||||||||||||
| set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_SYSTEM_NAME}") | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};runtime;/") | ||||||||||||||
| set(CPACK_STRIP_FILES TRUE) | ||||||||||||||
| set(CPACK_VERBATIM_VARIABLES YES) | ||||||||||||||
|
Comment on lines
+151
to
+152
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two true values are inconsistent, but it looks like we've not been consistent in the rest of our files, so idk. |
||||||||||||||
| include(CPack) | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently we can also set some more variables?
Suggested change
Also, I'm noticing that this is not setting the (This has led me to a rabbit hole of realising how cursed our version setup is, and now I'm thinking of how the hell to fix that. Stay tuned lol) |
||||||||||||||
| endif() | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,7 +110,7 @@ foreach(PROG "asm" "fix" "gfx" "link") | |
| ${rgb${PROG}_src} | ||
| ${common_src} | ||
| ) | ||
| install(TARGETS rgb${PROG} RUNTIME DESTINATION bin) | ||
| install(TARGETS rgb${PROG} RUNTIME DESTINATION bin COMPONENT runtime) | ||
| # Required to run tests | ||
| set_target_properties(rgb${PROG} PROPERTIES | ||
| # hack for MSVC: no-op generator expression to stop generation of "per-configuration subdirectory" | ||
|
|
@@ -122,9 +122,11 @@ if(LIBPNG_FOUND) # pkg-config | |
| target_link_directories(rgbgfx PRIVATE ${LIBPNG_LIBRARY_DIRS}) | ||
| target_link_libraries(rgbgfx PRIVATE ${LIBPNG_LIBRARIES}) | ||
| else() | ||
| target_compile_definitions(rgbgfx PRIVATE ${PNG_DEFINITIONS}) | ||
| target_include_directories(rgbgfx PRIVATE ${PNG_INCLUDE_DIRS}) | ||
| target_link_libraries(rgbgfx PRIVATE ${PNG_LIBRARIES}) | ||
| target_link_libraries(rgbgfx PRIVATE PNG::PNG) | ||
| endif() | ||
|
|
||
| if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.21") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is a version check required? |
||
| install(FILES "$<TARGET_RUNTIME_DLLS:rgbgfx>" DESTINATION bin COMPONENT runtime) | ||
| endif() | ||
|
|
||
| include(CheckLibraryExists) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,7 @@ foreach(TARGET randtilegen rgbgfx_test) | |
| target_link_directories(${TARGET} PRIVATE ${LIBPNG_LIBRARY_DIRS}) | ||
| target_link_libraries(${TARGET} PRIVATE ${LIBPNG_LIBRARIES}) | ||
| else() | ||
| target_compile_definitions(${TARGET} PRIVATE ${PNG_DEFINITIONS}) | ||
| target_include_directories(${TARGET} PRIVATE ${PNG_INCLUDE_DIRS}) | ||
| target_link_libraries(${TARGET} PRIVATE ${PNG_LIBRARIES}) | ||
| target_link_libraries(${TARGET} PRIVATE PNG::PNG) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, very nice, thank you! We should do the same for the pkg-config path, tbh. |
||
| endif() | ||
| endforeach() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is looking for zlib separately required? I see
FindPNG.cmakecallsfind_package(ZLIB)on my system.