-
Notifications
You must be signed in to change notification settings - Fork 70
/
Herc65_ExtPackageWinCopy.cmake
186 lines (158 loc) · 6.87 KB
/
Herc65_ExtPackageWinCopy.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Herc65_ExtPackageInstall.cmake - Install CMake external package shared
# libraries needed to execute Hercules
# from the install directory
#[[ Copyright 2017 by Stephen Orso.
Distributed under the Boost Software License, Version 1.0.
See accompanying file BOOST_LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
]]
#[[
Function/Operation
- Create commands that run post-build to copy the shared library(s)
to the Hercules binary directory for use when Hercules is run from
the build directory. This is required ONLY for Windows; on UNIX-
like target systems, CMake assembles a build RPATH that includes the
directories for dependent targets. On install, the RPATH is updated
to point to the Hercules install directory.
- Shared libraries from the following packages are copied in all cases:
. BZip2
. PCRE
. Zlib
- If Hercules was built as a 32-bit application on a 64-bit system and
one or both REXX interpreters, Open Object Rexx and Regina Rexx, are
included in Hercules, then their respective shared libraries are also
copied to the release directory. The assumption is that the system
PATH statement points to the 64-bit REXX interpreters, with the
the result that the 32-bit Hercules will find and attempt to load
a 64-bit REXX .dll. This is a bad thing.
Input Parameters
- All parameters are passed as CMake -D options before the -P
Herc65_ExtPackageWinCopy.cmake option.
- IN1, IN2, and IN3 identify the full path names of the library files
that are to be copied. If the path name ends -NOTFOUND, or the path
does not exist, the file is not copied.
- OUT identifies the directory name of the Hercules target executable
to which the library files are to be copied. It is expected but not
required that -DOUT= be completed with a generator expression that
identifies the Hercules executable directory. This approach addresses
the issue of placing the shared library executable in the correct
directory for the current build, Release or Debug.
Output
- The external package shared libraries are copied to the directory
containing the Hercules executable. This is a de facto requirement
for execution on Windows. The generator expression
$<TARGET_FILE_DIR:hercules> nicely and transparently identifies this
directory.
Notes
- This script should not be invoked for non-Windows builds, and if it
is, configure is aborted with an error message.
- This author is not certain what needs to happen for mac OS Xcode
builds. Alteration of this script and the process surrounding it
are distinct possibilities.
]]
# Some bullet-proofing
if( NOT WIN32 )
message( FATAL_ERROR "Herc65_ExtPackageWinCopy.cmake should not be invoked for non-Windows builds" )
endif( )
# ----------------------------------------------------------------------
#
# Copy the BZip2 shared library from its directory to the Hercules build
# directory.
#
# ----------------------------------------------------------------------
if( HAVE_BZIP2_TARGET )
get_target_property( __libpath1 bz2 IMPORTED_LOCATION_RELEASE )
get_target_property( __libpath2 bz2 IMPORTED_LOCATION_DEBUG )
get_target_property( __libpath3 bz2 IMPORTED_LOCATION )
add_custom_command( TARGET hercules
PRE_LINK
VERBATIM
COMMAND ${CMAKE_COMMAND} ARGS
-DNAME=BZip2
-DIN1=${__libpath1}
-DIN2=${__libpath2}
-DIN3=${__libpath3}
-DOUT=$<TARGET_FILE_DIR:hercules>
-P ${PROJECT_SOURCE_DIR}/cmake/Herc03_CopySharedLib.cmake
)
endif( )
# ----------------------------------------------------------------------
#
# Copy the PCRE shared library from its directory to the Hercules build
# directory.
#
# ----------------------------------------------------------------------
# Note that PCRE includes two targets: PCRE and PCREPOSIX. Because the
# two libraries represent different interfaces to the same functionality,
# HAVE_PCRE_TARGET is treated as indicating both must
# be copied.
if( HAVE_PCRE_TARGET )
get_target_property( __libpath1 pcre IMPORTED_LOCATION_RELEASE )
get_target_property( __libpath2 pcre IMPORTED_LOCATION_DEBUG )
get_target_property( __libpath3 pcre IMPORTED_LOCATION )
add_custom_command( TARGET hercules
PRE_LINK
VERBATIM
COMMAND ${CMAKE_COMMAND} ARGS
-DIN1=${__libpath1}
-DIN2=${__libpath2}
-DIN3=${__libpath3}
-DOUT=$<TARGET_FILE_DIR:hercules>
-P ${PROJECT_SOURCE_DIR}/cmake/Herc03_CopySharedLib.cmake
)
get_target_property( __libpath1 pcreposix IMPORTED_LOCATION_RELEASE )
get_target_property( __libpath2 pcreposix IMPORTED_LOCATION_DEBUG )
get_target_property( __libpath3 pcreposix IMPORTED_LOCATION )
add_custom_command( TARGET hercules
PRE_LINK
VERBATIM
COMMAND ${CMAKE_COMMAND} ARGS
-DNAME=PCRE
-DIN1=${__libpath1}
-DIN2=${__libpath2}
-DIN3=${__libpath3}
-DOUT=$<TARGET_FILE_DIR:hercules>
-P ${PROJECT_SOURCE_DIR}/cmake/Herc03_CopySharedLib.cmake
)
endif( )
# ----------------------------------------------------------------------
#
# Copy the Zlib shared library from its directory to the Hercules build
# directory.
#
# ----------------------------------------------------------------------
if( HAVE_ZLIB_TARGET )
get_target_property( __libpath1 zlib IMPORTED_LOCATION_RELEASE )
get_target_property( __libpath2 zlib IMPORTED_LOCATION_DEBUG )
get_target_property( __libpath3 zlib IMPORTED_LOCATION )
add_custom_command( TARGET hercules
PRE_LINK
VERBATIM
COMMAND ${CMAKE_COMMAND} ARGS
-DNAME=Zlib
-DIN1=${__libpath1}
-DIN2=${__libpath2}
-DIN3=${__libpath3}
-DOUT=$<TARGET_FILE_DIR:hercules>
-P ${PROJECT_SOURCE_DIR}/cmake/Herc03_CopySharedLib.cmake
)
endif( )
# ----------------------------------------------------------------------
#
# If this is a 32-bit build on a 64-bit system and Regina Rexx support
# was included in Hercules, copy the regina.dll and rxutil.dll shared
# libraries from their directory to the Hercules build directory.
#
# ----------------------------------------------------------------------
if( ENABLE_REGINA_REXX )
add_custom_command( TARGET hercules
PRE_LINK
VERBATIM
COMMAND ${CMAKE_COMMAND} ARGS
-DNAME="Regina Rexx 32-bit"
-DIN1=${RREXX_DIR}/regina.dll
-DIN2=${RREXX_DIR}/regutil.dll
-DOUT=$<TARGET_FILE_DIR:hercules>
-P ${PROJECT_SOURCE_DIR}/cmake/Herc03_CopySharedLib.cmake
)
endif( )