Skip to content

Commit e0431c7

Browse files
committed
Initial commit
0 parents  commit e0431c7

File tree

3 files changed

+247
-0
lines changed

3 files changed

+247
-0
lines changed

CMakeLists.txt

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
cmake_minimum_required(VERSION 2.8.10.2)
2+
3+
#
4+
# This project allows to configure, build, archive and upload an OpenSSL install tree.
5+
#
6+
7+
if(DEFINED UPLOAD_PACKAGE_SCRIPT)
8+
9+
set(MIDAS_URL "http://packages.kitware.com")
10+
set(FOLDER_ID 203)
11+
set(APPLICATION_ID 20)
12+
set(PACKAGE_TYPE "Tar.gz Archive")
13+
14+
set(midas_api_script ${ARCHIVE_DIR}/MidasAPI.cmake)
15+
if(NOT EXISTS ${midas_api_script})
16+
file(DOWNLOAD ${MIDAS_URL}/api/rest?method=midas.packages.script.download ${midas_api_script})
17+
endif()
18+
include(${midas_api_script})
19+
20+
message("----------------------")
21+
message("${PACKAGE_NAME}")
22+
message(" os: ${PACKAGE_OS}")
23+
message(" arch: ${PACKAGE_ARCH}")
24+
message(" version: ${PACKAGE_VERSION}")
25+
26+
midas_api_package_upload(
27+
API_URL ${MIDAS_URL}
28+
API_EMAIL ${MIDAS_USER}
29+
API_KEY ${MIDAS_API_KEY}
30+
FILE "${ARCHIVE_DIR}/${PACKAGE_NAME}"
31+
NAME ${PACKAGE_NAME}
32+
FOLDER_ID ${FOLDER_ID}
33+
APPLICATION_ID ${APPLICATION_ID}
34+
OS ${PACKAGE_OS}
35+
ARCH ${PACKAGE_ARCH}
36+
PACKAGE_TYPE ${PACKAGE_TYPE}
37+
SUBMISSION_TYPE Experimental
38+
RELEASE "${PACKAGE_VERSION}"
39+
RESULT_VARNAME upload_status
40+
)
41+
message("Upload status: ${upload_status}")
42+
return()
43+
endif()
44+
45+
project(OpenSSL)
46+
include(ExternalProject)
47+
48+
set(version "1.0.1h")
49+
string(REPLACE "." "_" version_underscore ${version})
50+
set(source_archive_name "OpenSSL_${version_underscore}")
51+
math(EXPR bitness "${CMAKE_SIZEOF_VOID_P} * 8")
52+
set(binary_archive_name "${source_archive_name}-install-msvc${MSVC_VERSION}-${bitness}")
53+
set(binary_archive_name_with_config "${binary_archive_name}-${CMAKE_BUILD_TYPE}")
54+
55+
option(UPLOAD_PACKAGES "Upload package(s)" ON)
56+
option(SUPERBUILD "Build ${proj} Debug and Release tree" ON)
57+
58+
if(UPLOAD_PACKAGES)
59+
set(MIDAS_USER "" CACHE STRING "Midas User")
60+
set(MIDAS_API_KEY "" CACHE STRING "Midas API Key")
61+
set(package_upload_options
62+
-DMIDAS_USER:STRING=${MIDAS_USER}
63+
-DMIDAS_API_KEY:STRING=${MIDAS_API_KEY}
64+
)
65+
endif()
66+
67+
find_program(PERL_COMMAND "Path to perl executable")
68+
if(NOT PERL_COMMAND)
69+
message(FATAL_ERROR "PERL_COMMAND is not set !")
70+
endif()
71+
get_filename_component(PERL_BIN_DIR ${PERL_COMMAND} PATH)
72+
73+
set(proj ${PROJECT_NAME})
74+
75+
if(NOT SUPERBUILD)
76+
77+
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
78+
set(config "VC-WIN32")
79+
set(do_script "do_ms.bat")
80+
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
81+
set(config "VC-WIN64A")
82+
set(do_script "do_win64a.bat")
83+
endif()
84+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
85+
set(config "debug-${config}")
86+
endif()
87+
88+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${proj}-configure.bat"
89+
"set PATH=%PATH%;${PERL_BIN_DIR}
90+
perl Configure ${config} no-asm --prefix=${CMAKE_BINARY_DIR}/${binary_archive_name_with_config}
91+
call ms\\${do_script}")
92+
93+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${proj}-build.bat"
94+
"set PATH=%PATH%;${PERL_BIN_DIR}
95+
nmake -f ms\\ntdll.mak")
96+
97+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${proj}-install.bat"
98+
"set PATH=%PATH%;${PERL_BIN_DIR}
99+
nmake -f ms\\ntdll.mak install")
100+
101+
ExternalProject_Add(${proj}
102+
# Use github archive instead of the one hosted on openssl.org because of CMake bug #13251
103+
URL "https://github.com/openssl/openssl/archive/${source_archive_name}.tar.gz"
104+
URL_MD5 "9e380f6f9cc497bd2f47c944019239ac"
105+
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}
106+
SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
107+
BUILD_IN_SOURCE 1
108+
CONFIGURE_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${proj}-configure.bat"
109+
BUILD_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${proj}-build.bat"
110+
INSTALL_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${proj}-install.bat"
111+
)
112+
113+
ExternalProject_Add_Step(${proj} create-archive
114+
COMMAND ${CMAKE_COMMAND} -E
115+
tar czvf ${binary_archive_name_with_config}.tar.gz ${binary_archive_name_with_config}
116+
DEPENDEES install
117+
)
118+
ExternalProject_Add_StepTargets(${proj} create-archive)
119+
120+
if(UPLOAD_PACKAGES)
121+
ExternalProject_Add_Step(${proj} upload-archive
122+
COMMAND ${CMAKE_COMMAND}
123+
${package_upload_options}
124+
-DARCHIVE_DIR:PATH=${CMAKE_BINARY_DIR}
125+
-DPACKAGE_ARCH:STRING=MSVC${MSVC_VERSION}_${bitness}-bit
126+
-DPACKAGE_NAME:STRING=${binary_archive_name_with_config}.tar.gz
127+
-DPACKAGE_OS:STRING=Windows-${CMAKE_BUILD_TYPE}
128+
-DPACKAGE_VERSION:STRING=${version}
129+
-DUPLOAD_PACKAGE_SCRIPT:BOOL=ON -P ${CMAKE_CURRENT_LIST_FILE}
130+
DEPENDEES create-archive
131+
)
132+
ExternalProject_Add_StepTargets(${proj} upload-archive)
133+
endif()
134+
135+
if(DEFINED MULTICONFIG_DIR)
136+
ExternalProject_Add_Step(${proj} copy-into-multiconfig-dir
137+
COMMAND ${CMAKE_COMMAND} -E copy_directory
138+
${CMAKE_BINARY_DIR}/${binary_archive_name_with_config}
139+
${MULTICONFIG_DIR}/${CMAKE_BUILD_TYPE}
140+
DEPENDEES install
141+
)
142+
ExternalProject_Add_StepTargets(${proj} copy-into-multiconfig-dir)
143+
endif()
144+
145+
else()
146+
147+
set(multiconfig_dir ${CMAKE_BINARY_DIR}/${binary_archive_name})
148+
file(MAKE_DIRECTORY ${multiconfig_dir})
149+
150+
set(ep_cmake_cache_args
151+
-DPERL_COMMAND:FILEPATH=${PERL_COMMAND}
152+
-DSUPERBUILD:BOOL=OFF
153+
-DUPLOAD_PACKAGES:BOOL=${UPLOAD_PACKAGES}
154+
${package_upload_options}
155+
-DMULTICONFIG_DIR:PATH=${multiconfig_dir}
156+
)
157+
158+
ExternalProject_Add(${proj}-Release
159+
DOWNLOAD_COMMAND ""
160+
SOURCE_DIR "${CMAKE_SOURCE_DIR}"
161+
BINARY_DIR "${CMAKE_BINARY_DIR}/${proj}-Release"
162+
CMAKE_CACHE_ARGS ${ep_cmake_cache_args} -DCMAKE_BUILD_TYPE:STRING=Release
163+
INSTALL_COMMAND ""
164+
)
165+
166+
ExternalProject_Add(${proj}-Debug
167+
DOWNLOAD_COMMAND ""
168+
SOURCE_DIR "${CMAKE_SOURCE_DIR}"
169+
BINARY_DIR "${CMAKE_BINARY_DIR}/${proj}-Debug"
170+
CMAKE_CACHE_ARGS ${ep_cmake_cache_args} -DCMAKE_BUILD_TYPE:STRING=Debug
171+
INSTALL_COMMAND ""
172+
)
173+
174+
ExternalProject_Add(${proj}-MultiConfig
175+
DOWNLOAD_COMMAND ""
176+
CONFIGURE_COMMAND ""
177+
BUILD_COMMAND
178+
${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}
179+
${CMAKE_COMMAND} -E tar czvf ${binary_archive_name}.tar.gz ${binary_archive_name}
180+
INSTALL_COMMAND ""
181+
DEPENDS
182+
${proj}-Debug
183+
${proj}-Release
184+
STEP_TARGETS build
185+
)
186+
187+
if(UPLOAD_PACKAGES)
188+
ExternalProject_Add_Step(${proj}-MultiConfig upload-archive
189+
COMMAND ${CMAKE_COMMAND}
190+
${package_upload_options}
191+
-DARCHIVE_DIR:PATH=${CMAKE_BINARY_DIR}
192+
-DPACKAGE_ARCH:STRING=MSVC${MSVC_VERSION}_${bitness}-bit
193+
-DPACKAGE_NAME:STRING=${binary_archive_name}.tar.gz
194+
-DPACKAGE_OS:STRING=Windows
195+
-DPACKAGE_VERSION:STRING=${version}
196+
-DUPLOAD_PACKAGE_SCRIPT:BOOL=ON -P ${CMAKE_CURRENT_LIST_FILE}
197+
DEPENDEES build
198+
)
199+
ExternalProject_Add_StepTargets(${proj}-MultiConfig upload-archive)
200+
endif()
201+
202+
endif()

LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2018, Kitware Inc.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of the <organization> nor the
12+
names of its contributors may be used to endorse or promote products
13+
derived from this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
This project allows to configure, build, archive and upload an OpenSSL install tree.
3+
4+
# instructions
5+
6+
Steps using cmake-gui:
7+
8+
1. Download CMakeLists.txt into a folder such as `C:\path\OpenSSL-packages`
9+
2. Create a build folder such as `C:\path\OpenSSL-packages-build`
10+
3. Run CMake, set source code and binary paths to the folders listed above, and press Configure
11+
4. Choose a generator
12+
5. Set configuration variables such as username, API key, and path to Perl executable, then press Generate to create the build files
13+
6. Open the solution file in `C:\path\OpenSSL-packages-build` and build the solution
14+
15+
# license
16+
17+
This project is covered by the OSI-approved BSD 3-clause License.
18+
19+
OpenSSL is distributed under the [OpenSSL License][openssl-license]. For more information about OpenSSL, visit https://www.openssl.org/
20+
21+
[openssl-license]: https://www.openssl.org/source/license.html

0 commit comments

Comments
 (0)