I’m trying to create an nsis installer via the GH Actions runners.
I’ve defined some code in the INSTALL section, to copy and bundle all the libs (I’m using a shell script , rather than the built-in functionality).
The problem is, I just can’t get the install script to know where the source tree is located at.
Of course, my first instinct was to just use CMAKE_SOURCE_DIR
, when that didn’t work, I tried other versions (such as PROJECT_SOUR_DIR
and <TARGET>_SOURCE_DIR
), none of which work.
Then I realized CPACK should be able to get variables that start with CPACK
, so I made a CPACK_TOP_SOURCE_DIR
which is set the CMAKE_SOURCE_DIR
; again, didn’t work. I reasoned maybe it’s because it was being re-set on every run (including CPack) and thus was being set to empty during install. So, I came up with the following:
if (CMAKE_SOURCE_DIR AND (NOT (CMAKE_SOURCE_DIR STREQUAL CPACK_TOP_SOURCE_DIR)))
set (CPACK_TOP_SOURCE_DIR "${CMAKE_SOURCE_DIR}" CACHE INTERNAL "Source directory to be used by CPack." FORCE)
endif()
Looking into CPackConfig.txt shows that it apparently works:
runneradmin@fv-az250-215 MINGW64 /d/a/performous/performous/performous/build
# cat CPackConfig.cmake | grep TOP_SOURCE
set(CPACK_TOP_SOURCE_DIR "D:/a/performous/performous/performous")
But again, this doesn’t work during the install phase.
install(CODE [[
message ("SOURCE DIR IS: ${CPACK_TOP_SOURCE_DIR}")
]])
prints
CPack: Install projects
CPack: - Run preinstall target for: Performous
CPack: - Install project: Performous []
SOURCE DIR IS:
What am I doing wrong, and how can I fix it? At this point, the only idea I’m getting is to maybe use a file instead of a variable, and then read the contents of the file, but that’s an even nastier hack that what I’m already using…