Discussion:
[CMake] using cmake to install dlls into windows/system32
James Zipperer
2009-12-16 23:42:46 UTC
Permalink
Does anyone have an example of how to install dlls into %WINDIR%/system32 using cmake/ cpack/nsis? Thanks!

-James


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.
David Cole
2009-12-17 00:14:53 UTC
Permalink
You should avoid this if at all possible.

Install dlls next to your program, not in the system32 directory.

Do you have a reason you need to install a dll there?


On Wed, Dec 16, 2009 at 6:42 PM, James Zipperer <
Post by James Zipperer
Does anyone have an example of how to install dlls into %WINDIR%/system32
using cmake/ cpack/nsis? Thanks!
-James
------------------------------
This message contains information which is confidential and privileged.
Unless you are the addressee (or authorized to receive for the addressee),
you may not use, copy or disclose to anyone the message or any information
contained in the message. If you have received the message in error, please
advise the sender by reply e-mail and delete the message.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
James Zipperer
2009-12-17 00:18:13 UTC
Permalink
Yes, unfortunately they need to be there.

-James


From: David Cole [mailto:***@kitware.com]
Sent: Wednesday, December 16, 2009 4:15 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

You should avoid this if at all possible.
Install dlls next to your program, not in the system32 directory.

Do you have a reason you need to install a dll there?


On Wed, Dec 16, 2009 at 6:42 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Does anyone have an example of how to install dlls into %WINDIR%/system32 using cmake/ cpack/nsis? Thanks!

-James


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.
David Cole
2009-12-17 00:34:08 UTC
Permalink
What's the reason they need to be there?


On Wed, Dec 16, 2009 at 7:18 PM, James Zipperer <
Post by James Zipperer
Yes, unfortunately they need to be there.
-James
*Sent:* Wednesday, December 16, 2009 4:15 PM
*To:* James Zipperer
*Cc:* CMake mailing list
*Subject:* Re: [CMake] using cmake to install dlls into windows/system32
You should avoid this if at all possible.
Install dlls next to your program, not in the system32 directory.
Do you have a reason you need to install a dll there?
On Wed, Dec 16, 2009 at 6:42 PM, James Zipperer <
Does anyone have an example of how to install dlls into %WINDIR%/system32
using cmake/ cpack/nsis? Thanks!
-James
------------------------------
This message contains information which is confidential and privileged.
Unless you are the addressee (or authorized to receive for the addressee),
you may not use, copy or disclose to anyone the message or any information
contained in the message. If you have received the message in error, please
advise the sender by reply e-mail and delete the message.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
------------------------------
This message contains information which is confidential and privileged.
Unless you are the addressee (or authorized to receive for the addressee),
you may not use, copy or disclose to anyone the message or any information
contained in the message. If you have received the message in error, please
advise the sender by reply e-mail and delete the message.
James Zipperer
2009-12-17 00:44:03 UTC
Permalink
They're device driver dlls for use system-wide.

-James


From: David Cole [mailto:***@kitware.com]
Sent: Wednesday, December 16, 2009 4:34 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

What's the reason they need to be there?

On Wed, Dec 16, 2009 at 7:18 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Yes, unfortunately they need to be there.

-James


From: David Cole [mailto:***@kitware.com<mailto:***@kitware.com>]
Sent: Wednesday, December 16, 2009 4:15 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

You should avoid this if at all possible.
Install dlls next to your program, not in the system32 directory.

Do you have a reason you need to install a dll there?


On Wed, Dec 16, 2009 at 6:42 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Does anyone have an example of how to install dlls into %WINDIR%/system32 using cmake/ cpack/nsis? Thanks!

-James


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.
James Zipperer
2009-12-17 22:44:07 UTC
Permalink
This seems to work, although I don't think it's the ideal solution:

CMakeLists.txt
install (FILES drivers/driver.dll
DESTINATION sysdir/)

set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
CopyFiles \\\"$INSTDIR\\\\sysdir\\\\driver.dll\\\" \\\"$SYSDIR\\\"
")

This gets the dll into the windows system directory, but there are still some issues I'm sorting through:
Versioning of the dll: what if the file was already there and there is already a newer version?
How to uninstall only if nothing else is using the dll.

It appears that nsis has some helper functions: UpgradeDLL, AddSharedDLL, but I'm not sure yet how to include/call them through CMakeLists.txt. Does anyone have any insight? Thanks!

-James


From: cmake-***@cmake.org [mailto:cmake-***@cmake.org] On Behalf Of James Zipperer
Sent: Wednesday, December 16, 2009 4:44 PM
To: David Cole; CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

They're device driver dlls for use system-wide.

-James


From: David Cole [mailto:***@kitware.com]
Sent: Wednesday, December 16, 2009 4:34 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

What's the reason they need to be there?

On Wed, Dec 16, 2009 at 7:18 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Yes, unfortunately they need to be there.

-James


From: David Cole [mailto:***@kitware.com<mailto:***@kitware.com>]
Sent: Wednesday, December 16, 2009 4:15 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

You should avoid this if at all possible.
Install dlls next to your program, not in the system32 directory.

Do you have a reason you need to install a dll there?


On Wed, Dec 16, 2009 at 6:42 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Does anyone have an example of how to install dlls into %WINDIR%/system32 using cmake/ cpack/nsis? Thanks!

-James


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.
James Zipperer
2009-12-18 00:00:21 UTC
Permalink
Is there a way to add an NSIS macro or override the NSIS template or something to allow inclusion of the UpgradeDLL macro? With that functionality I think I could achieve my goal. Thanks!

-James


From: cmake-***@cmake.org [mailto:cmake-***@cmake.org] On Behalf Of James Zipperer
Sent: Thursday, December 17, 2009 2:44 PM
To: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

This seems to work, although I don't think it's the ideal solution:

CMakeLists.txt
install (FILES drivers/driver.dll
DESTINATION sysdir/)

set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
CopyFiles \\\"$INSTDIR\\\\sysdir\\\\driver.dll\\\" \\\"$SYSDIR\\\"
")

This gets the dll into the windows system directory, but there are still some issues I'm sorting through:
Versioning of the dll: what if the file was already there and there is already a newer version?
How to uninstall only if nothing else is using the dll.

It appears that nsis has some helper functions: UpgradeDLL, AddSharedDLL, but I'm not sure yet how to include/call them through CMakeLists.txt. Does anyone have any insight? Thanks!

-James


From: cmake-***@cmake.org [mailto:cmake-***@cmake.org] On Behalf Of James Zipperer
Sent: Wednesday, December 16, 2009 4:44 PM
To: David Cole; CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

They're device driver dlls for use system-wide.

-James


From: David Cole [mailto:***@kitware.com]
Sent: Wednesday, December 16, 2009 4:34 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

What's the reason they need to be there?

On Wed, Dec 16, 2009 at 7:18 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Yes, unfortunately they need to be there.

-James


From: David Cole [mailto:***@kitware.com<mailto:***@kitware.com>]
Sent: Wednesday, December 16, 2009 4:15 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

You should avoid this if at all possible.
Install dlls next to your program, not in the system32 directory.

Do you have a reason you need to install a dll there?


On Wed, Dec 16, 2009 at 6:42 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Does anyone have an example of how to install dlls into %WINDIR%/system32 using cmake/ cpack/nsis? Thanks!

-James


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.
James Zipperer
2009-12-18 02:46:41 UTC
Permalink
After a lot of trial and error and some rtfm work, I figured out a way to do it. The UpgradeDLL macro I mentioned below appears to be out of date and the preferred method is now InstallLib. It appears to handle DLL versioning and usage counting. Note: I could be wrong, I've been at this problem for about a day now.

Here's the hack solution I came up with:

1. Modify NSIS.template.in to include Library.nsh:

!include Library.nsh
2. Do the following in CMakeLists.txt:
install (FILES driver.dll
DESTINATION sysdir/)
#lots of string escaping, bleccch. NSIS uses the same ${xxx} variable syntax as cmake
#note: this is a hack since INST_DIR is a !define inside NSIS.template.in that gets set to CPACK_TEMPORARY_DIRECTORY
set (tmp_nsis_inst_dir "\\\${INST_DIR}")
set (tmp_nsis_localdll "\\\${localdll}")
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
!define localdll \\\"${tmp_nsis_inst_dir}\\\\sysdir\\\\driver.dll\\\"
!insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED \\\"${tmp_nsis_localdll}\\\" \\\"$SYSDIR\\\\driver.dll\\\" \\\"$SYSDIR\\\"
!undef localdll
")

If anyone could offer up a better solution, I'd greatly appreciate it. Hope this helps someone else out there in the wonderful world of cmake.

-James


From: cmake-***@cmake.org [mailto:cmake-***@cmake.org] On Behalf Of James Zipperer
Sent: Thursday, December 17, 2009 4:00 PM
To: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

Is there a way to add an NSIS macro or override the NSIS template or something to allow inclusion of the UpgradeDLL macro? With that functionality I think I could achieve my goal. Thanks!

-James


From: cmake-***@cmake.org [mailto:cmake-***@cmake.org] On Behalf Of James Zipperer
Sent: Thursday, December 17, 2009 2:44 PM
To: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

This seems to work, although I don't think it's the ideal solution:

CMakeLists.txt
install (FILES drivers/driver.dll
DESTINATION sysdir/)

set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
CopyFiles \\\"$INSTDIR\\\\sysdir\\\\driver.dll\\\" \\\"$SYSDIR\\\"
")

This gets the dll into the windows system directory, but there are still some issues I'm sorting through:
Versioning of the dll: what if the file was already there and there is already a newer version?
How to uninstall only if nothing else is using the dll.

It appears that nsis has some helper functions: UpgradeDLL, AddSharedDLL, but I'm not sure yet how to include/call them through CMakeLists.txt. Does anyone have any insight? Thanks!

-James


From: cmake-***@cmake.org [mailto:cmake-***@cmake.org] On Behalf Of James Zipperer
Sent: Wednesday, December 16, 2009 4:44 PM
To: David Cole; CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

They're device driver dlls for use system-wide.

-James


From: David Cole [mailto:***@kitware.com]
Sent: Wednesday, December 16, 2009 4:34 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

What's the reason they need to be there?

On Wed, Dec 16, 2009 at 7:18 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Yes, unfortunately they need to be there.

-James


From: David Cole [mailto:***@kitware.com<mailto:***@kitware.com>]
Sent: Wednesday, December 16, 2009 4:15 PM
To: James Zipperer
Cc: CMake mailing list
Subject: Re: [CMake] using cmake to install dlls into windows/system32

You should avoid this if at all possible.
Install dlls next to your program, not in the system32 directory.

Do you have a reason you need to install a dll there?


On Wed, Dec 16, 2009 at 6:42 PM, James Zipperer <***@modsystems.com<mailto:***@modsystems.com>> wrote:
Does anyone have an example of how to install dlls into %WINDIR%/system32 using cmake/ cpack/nsis? Thanks!

-James


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.


________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.

________________________________
This message contains information which is confidential and privileged. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail and delete the message.
Eric Noulard
2009-12-18 08:09:45 UTC
Permalink
After  a lot of trial and error and some rtfm work, I figured out a way to
do it.  The UpgradeDLL macro I mentioned below appears to be out of date and
the preferred method is now InstallLib.  It appears to handle DLL versioning
and usage counting.  Note: I could be wrong, I’ve been at this problem for
about a day now.
I would say that if you have a specific behavior which is not configurable
with the CMake provided NSIS.template.in
you'll better craft your own NSIS.template.in
which may contain as much specificities as you need.

I mean not only adding "include Library.nsh" but whatever
other NSIS installer code you need.

Then after that if the "install driver DLL" thing is of general
interest may be you can report a bug and propose a generic
modification of the mainstream NSIS.template.in provided with cmake.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
David Cole
2009-12-18 16:07:04 UTC
Permalink
Post by James Zipperer
Post by James Zipperer
After a lot of trial and error and some rtfm work, I figured out a way
to
Post by James Zipperer
do it. The UpgradeDLL macro I mentioned below appears to be out of date
and
Post by James Zipperer
the preferred method is now InstallLib. It appears to handle DLL
versioning
Post by James Zipperer
and usage counting. Note: I could be wrong, I’ve been at this problem
for
Post by James Zipperer
about a day now.
I would say that if you have a specific behavior which is not configurable
with the CMake provided NSIS.template.in
you'll better craft your own NSIS.template.in
which may contain as much specificities as you need.
I mean not only adding "include Library.nsh" but whatever
other NSIS installer code you need.
Then after that if the "install driver DLL" thing is of general
interest may be you can report a bug and propose a generic
modification of the mainstream NSIS.template.in provided with cmake.
See my note attached to this bug for a way to use your own override of the
NSIS.template.in file. (So you can do it on a per-project basis rather than
modifying the main one in the CMake installation...)

http://public.kitware.com/Bug/view.php?id=9148

Note copy/pasted here to save you the hunting time:

Make your own copy of the NSIS.template.in file
Put it in a directory named "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
Make edits to your own NSIS.template.in file as needed
Put this in your CMakeLists.txt file:
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
${CMAKE_MODULE_PATH})

Voila.

CPack will now use your NSIS.template.in file instead of the built-in one.


HTH,
David
Eric Noulard
2009-12-18 17:10:45 UTC
Permalink
Post by David Cole
See my note attached to this bug for a way to use your own override of the
NSIS.template.in file. (So you can do it on a per-project basis rather than
modifying the main one in the CMake installation...)
http://public.kitware.com/Bug/view.php?id=9148
David,

If this kind of request is pop-in up again may be it would be worth
to make the feature a builtin of the CPack NSIS generator.

Eg. putting in the CMakeLists.txt something like:

SET(CPACK_NSIS_USER_TEMPLATE /whatever/path/to/NSIS.template.user)

would you find it worth a valuable feature request?
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
David Cole
2009-12-18 17:26:17 UTC
Permalink
Post by Eric Noulard
Post by David Cole
See my note attached to this bug for a way to use your own override of
the
Post by David Cole
NSIS.template.in file. (So you can do it on a per-project basis rather
than
Post by David Cole
modifying the main one in the CMake installation...)
http://public.kitware.com/Bug/view.php?id=9148
David,
If this kind of request is pop-in up again may be it would be worth
to make the feature a builtin of the CPack NSIS generator.
SET(CPACK_NSIS_USER_TEMPLATE /whatever/path/to/NSIS.template.user)
would you find it worth a valuable feature request?
But there's already a way to do it. Why add a variable if you can achieve
the goal as is...?

Loading...