diff options
author | Louie S <louie@example.com> | 2024-04-29 16:45:49 -0400 |
---|---|---|
committer | U-LEIDOS-CORP\shprungl <shprungl@B5K2GR3.corp.leidos.com> | 2024-04-29 16:48:20 -0400 |
commit | 1df7f5ada22a372fa1efdd5c768c30d64dab7334 (patch) | |
tree | 110e202348d81865e62a29d58342db1f92233e91 | |
parent | 4621f2a8d7ff5772931fb67b21c9eb1a7fcd2636 (diff) |
Progress on NSIS installer
-rw-r--r-- | CMakeLists.txt | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index dca866d..74b5a41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.21) # Get the date for last git commit (or today if it can't) if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git") @@ -122,7 +122,10 @@ target_link_libraries(assignment-list ${qt_libraries}) # Installation include(GNUInstallDirs) -install(TARGETS assignment-list) +# Do not install normally if on Windows (we will install to / rather than /bin of install location) +if(NOT CMAKE_SYSTEM MATCHES "Windows*") + install(TARGETS assignment-list) +endif() # install desktop entry and icon if(CMAKE_SYSTEM MATCHES "Linux.*") @@ -144,9 +147,12 @@ set(CPACK_PACKAGE_CONTACT "Louie Shprung <lshprung@tutanota.com>") set(CPACK_SOURCE_IGNORE_FILES "/\.git.*;/\.cache;/build;/compile_commands\.json$;/config\.h$;/data/assignment-list\.desktop$") # CPack NSIS configuration +# TODO provide option to create desktop shortcut +# TODO installed software does not work if .../mingw64/bin/ is not on the PATH set(CPACK_NSIS_DEFINES "RequestExecutionLevel user") # Based on https://stackoverflow.com/q/69139412 if(CMAKE_SYSTEM MATCHES "Windows*") + set(CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_TITLE}) include(InstallRequiredSystemLibraries) find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}") add_custom_command(TARGET assignment-list POST_BUILD @@ -154,11 +160,43 @@ if(CMAKE_SYSTEM MATCHES "Windows*") COMMAND ${WINDEPLOYQT_EXECUTABLE} --dir ${CMAKE_BINARY_DIR}/qtDeploy $<TARGET_FILE:assignment-list> ) +# Install dlls install( DIRECTORY ${CMAKE_BINARY_DIR}/qtDeploy/ - DESTINATION ${CMAKE_INSTALL_BINDIR} - FILES_MATCHING_PATTERN "*.*" + DESTINATION / + FILES_MATCHING PATTERN "*.*" ) +# Based on https://discourse.cmake.org/t/runtime-dependencies-cannot-find-dll/3782 +# and https://discourse.cmake.org/t/get-runtime-dependencies-does-not-seem-to-work-with-mingw/2239 + install(CODE "set(CMAKE_MINGW_SYSTEM_LIBRARY_PATH \"${CMAKE_FIND_ROOT_PATH}/bin/\")") + install(TARGETS assignment-list + RUNTIME_DEPENDENCIES + PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" + POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" + DIRECTORIES ${CMAKE_SYSTEM_LIBRARY_PATH} ${CMAKE_MINGW_SYSTEM_LIBRARY_PATH} + DESTINATION / + ) + #install(CODE [[ + # file(GET_RUNTIME_DEPENDENCIES + # LIBRARIES "$<TARGET_FILE:assignment-list>" + # RESOLVED_DEPENDENCIES_VAR _r_deps + # UNRESOLVED_DEPENDENCIES_VAR _u_deps + # DIRECTORIES ${DEPENDENCY_PATHS} + # PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" + # POST_EXCLUDE_REGEXES" ".*system32/.*\\.dll" + # ) + # foreach(_file ${_r_deps}) + # file(INSTALL + # DESTINATION "${CMAKE_INSTALL_BINDIR}" + # TYPE SHARED_LIBRARY + # FILES "${_file}" + # ) + # endforeach() + # list(LENGTH _u_deps _u_length) + # if("${_u_length}" GREATER 0) + # message(WARNING "Unresolved dependencies detected!") + # endif() + #]]) endif() # CPack Deb configuration |