Skip to content

Commit 60fe5d1

Browse files
olszomalmtrojnar
authored andcommitted
use CMake instead of Makefile
1 parent b967175 commit 60fe5d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1032
-3022
lines changed

.gitignore

+18-26
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
1-
.deps
2-
Makefile
3-
Makefile.in
4-
aclocal.m4
5-
autom4te.cache/
6-
compile
1+
build/
2+
CMakeFiles/
3+
_CPack_Packages/
4+
Testing/
5+
6+
CMakeCache.txt
7+
cmake_install.cmake
78
config.h
8-
config.h.in
9-
config.h.in~
10-
config.log
11-
config.status
12-
configure
13-
depcomp
14-
install-sh
9+
CPackConfig.cmake
10+
CPackSourceConfig.cmake
11+
CTestTestfile.cmake
12+
install_manifest.txt
13+
Makefile
1514
missing
1615
osslsigncode
17-
osslsigncode.o
18-
msi.o
16+
osslsigncode.exe
1917
stamp-h1
20-
INSTALL
21-
COPYING
2218

2319
.#*#
2420
.*.bak
2521
.*.orig
2622
.*.rej
2723
.*~
2824
#*#
25+
*.asc
2926
*.bak
27+
*.bz2
3028
*.d
3129
*.def
3230
*.dll
33-
*.exe
31+
*.gz
32+
*.key
3433
*.la
3534
*.lib
3635
*.lo
3736
*.orig
37+
*.pc
3838
*.pdb
3939
*.rej
4040
*.u
4141
*.rc
42-
*.pc
4342
*~
44-
*.gz
45-
*.bz2
46-
*.asc
47-
48-
**/*.log
49-
!myapp.exe
50-
*.pem

CMakeLists.txt

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# required cmake version
2+
cmake_minimum_required(VERSION 3.6)
3+
4+
# set the project name and version
5+
project(osslsigncode VERSION 2.4)
6+
set(DEV "-dev")
7+
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}${DEV}")
8+
set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}")
9+
set(PACKAGE_BUGREPORT "Michal.Trojnara@stunnel.org")
10+
11+
# specify the C++ standard
12+
set(CMAKE_C_STANDARD 11)
13+
set(CMAKE_C_STANDARD_REQUIRED ON)
14+
15+
# make find modules in cmake dir available
16+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
17+
18+
# load CMake project modules
19+
include(SetOptions)
20+
include(FindOpenssl)
21+
include(FindCurl)
22+
include(FindMapping)
23+
24+
# use config.h
25+
target_compile_definitions(osslsigncode PRIVATE HAVE_CONFIG_H=1)
26+
configure_file(Config.h.in config.h)
27+
28+
# add include directories to osslsigncode
29+
target_include_directories(osslsigncode PUBLIC "${PROJECT_BINARY_DIR}")
30+
31+
if(MSVC)
32+
# set output directory
33+
set_target_properties(osslsigncode PROPERTIES
34+
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}
35+
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}
36+
)
37+
# copy necessary libraries
38+
file(COPY ${OPENSSL_LIBS} ${CURL_LIB} DESTINATION ${PROJECT_BINARY_DIR})
39+
else()
40+
# set LD_LIBRARY_PATH
41+
set_target_properties(osslsigncode PROPERTIES
42+
INSTALL_RPATH_USE_LINK_PATH TRUE
43+
)
44+
endif()
45+
46+
include(CMakeTest)
47+
include(CMakeInstall)
48+
if(NOT MSVC)
49+
include(CMakeDist)
50+
endif()

Config.h.in

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* the configured options and settings for osslsigncode */
2+
#define VERSION_MAJOR "@osslsigncode_VERSION_MAJOR@"
3+
#define VERSION_MINOR "@osslsigncode_VERSION_MINOR@"
4+
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
5+
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
6+
#cmakedefine ENABLE_CURL
7+
#cmakedefine HAVE_TERMIOS_H
8+
#cmakedefine HAVE_GETPASS
9+
#cmakedefine HAVE_SYS_MMAN_H
10+
#cmakedefine HAVE_MMAP
11+
#cmakedefine HAVE_MAPVIEWOFFILE
12+
#cmakedefine _WIN32

INSTALL.W32.md

+50
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,53 @@
9393
OpenSSL 1.1.1k 25 Mar 2021 (Library: OpenSSL 1.1.1k 25 Mar 2021)
9494
libcurl/7.78.0 OpenSSL/1.1.1k
9595
```
96+
97+
### Building OpenSSL, Curl and osslsigncode sources with Microsoft Visual Studio 64-bit:
98+
99+
1) Download and install Strawberry Perl from https://strawberryperl.com/
100+
101+
2) Run "Open Visual Studio 2022 Tools Command Prompt for targeting x64"
102+
103+
3) Build and install OpenSSL.
104+
```
105+
cd openssl-(version)
106+
perl Configure VC-WIN64A --prefix=C:\OpenSSL\vc-win64a --openssldir=C:\OpenSSL\SSL no-asm shared
107+
nmake && nmake install
108+
```
109+
110+
4) Build and install curl.
111+
```
112+
cd curl-(version)\winbuild
113+
nmake /f Makefile.vc mode=dll WITH_PREFIX=C:\curl SSL_PATH=C:\OpenSSL\vc-win64a \
114+
VC=22 MACHINE=x64 DEBUG=no WITH_SSL=dll ENABLE_NGHTTP2=no ENABLE_SSPI=no \
115+
ENABLE_IDN=no GEN_PDB=no ENABLE_WINSSL=no USE_ZLIB=no
116+
```
117+
118+
5) Build 64-bit Windows osslsigncode.
119+
Navigate to the build directory and run CMake to configure the osslsigncode project
120+
and generate a native build system:
121+
```
122+
mkdir build && cd build && cmake ..
123+
```
124+
with specific compile options:
125+
```
126+
-Denable-strict=ON
127+
-Denable-pedantic=ON
128+
-Dwith-curl=OFF
129+
-Dssl-path=C:\OpenSSL\
130+
-Dcurl-path=C:\curl\
131+
```
132+
Then call that build system to actually compile/link the osslsigncode project:
133+
```
134+
cmake --build .
135+
```
136+
137+
6) Make tests.
138+
```
139+
ctest -C Release
140+
```
141+
142+
5) Make install (with administrator privileges).
143+
```
144+
cmake --install . --prefix "C:\osslsigncode"
145+
```

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
OpenSSL based Authenticode signing for PE/MSI/Java CAB files.
22

33
Copyright (C) 2005-2014 Per Allansson <pallansson@gmail.com>
4-
Copyright (C) 2018-2019 Michał Trojnara <Michal.Trojnara@stunnel.org>
4+
Copyright (C) 2018-2022 Michał Trojnara <Michal.Trojnara@stunnel.org>
55

66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by

Makefile.am

-21
This file was deleted.

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- remove "-timestamp-expiration" option
1313
- disable verification of the Timestamp Server signature
1414
("-ignore-timestamp" option)
15+
- use CMake instead of Makefile
1516

1617
### 2.3 (2022.03.06)
1718

README.md

+26-22
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,47 @@ supports signature verification, removal and extraction.
2929

3030
This section covers building osslsigncode for [Unix-like](https://en.wikipedia.org/wiki/Unix-like) operating systems.
3131
See [INSTALL.W32.md](https://github.com/mtrojnar/osslsigncode/blob/master/INSTALL.W32.md) for Windows notes.
32+
We highly recommend downloading a [release tarball](https://github.com/mtrojnar/osslsigncode/releases) instead of cloning from a git repository.
3233

33-
### Generate the ./configure script
34-
35-
This step is only needed if osslsigncode was cloned from a git repository.
36-
We highly recommend downloading a [release tarball](https://github.com/mtrojnar/osslsigncode/releases) instead.
34+
### Configure, build, make tests and install osslsigncode
3735

3836
* Install prerequisites on a Debian-based distributions, such as Ubuntu:
3937
```
40-
sudo apt update && sudo apt install automake pkg-config
38+
sudo apt update && sudo apt install cmake libssl-dev libcurl4-openssl-dev
4139
```
42-
4340
* Install prerequisites on macOS with Homebrew:
4441
```
45-
brew install automake pkg-config
42+
brew install pkg-config openssl@1.1
43+
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
4644
```
47-
48-
* Generate the ./configure script:
45+
* Navigate to the build directory and run CMake to configure the osslsigncode project
46+
and generate a native build system:
4947
```
50-
./bootstrap
48+
mkdir build && cd build && cmake ..
5149
```
52-
53-
### Configure, build and install osslsigncode
54-
55-
* Install prerequisites on a Debian-based distributions, such as Ubuntu:
50+
with specific compile options:
5651
```
57-
sudo apt update && sudo apt install build-essential pkg-config libssl-dev libcurl4-openssl-dev
52+
-Denable-strict=ON
53+
-Denable-pedantic=ON
54+
-Dssl-path=/opt/openssl-3.0.2/
55+
-Dcurl-path=/opt/curl-7.82/
56+
-Dwith-curl=OFF
5857
```
59-
60-
* Install prerequisites on macOS with Homebrew:
58+
* Then call that build system to actually compile/link the osslsigncode project (alias `make`):
6159
```
62-
brew install pkg-config openssl@1.1
63-
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
60+
cmake --build .
6461
```
65-
66-
* Configure, build and install osslsigncode:
62+
* Make test:
63+
```
64+
ctest -C Release
65+
```
66+
* Make install:
67+
```
68+
sudo cmake --install . --prefix "/home/myuser/installdir"
69+
```
70+
* Make tarball (simulate autotools' `make dist`):
6771
```
68-
./configure && make && sudo make install
72+
cmake --build . --target package_source
6973
```
7074

7175
## USAGE

bootstrap

-2
This file was deleted.

cmake/CMakeDist.cmake

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# make dist
2+
# cmake --build . --target package_source
3+
4+
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
5+
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
6+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenSSL based Authenticode signing for PE, CAB, CAT and MSI files")
7+
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
8+
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
9+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.txt")
10+
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
11+
set(CPACK_SOURCE_GENERATOR "TGZ")
12+
set(CPACK_SOURCE_IGNORE_FILES "\.git/;\.gitignore")
13+
list(APPEND CPACK_SOURCE_IGNORE_FILES "Makefile")
14+
list(APPEND CPACK_SOURCE_IGNORE_FILES "CMakeCache.txt")
15+
list(APPEND CPACK_SOURCE_IGNORE_FILES "CMakeFiles")
16+
list(APPEND CPACK_SOURCE_IGNORE_FILES "CPackConfig.cmake")
17+
list(APPEND CPACK_SOURCE_IGNORE_FILES "CPackSourceConfig.cmake")
18+
list(APPEND CPACK_SOURCE_IGNORE_FILES "CTestTestfile.cmake")
19+
list(APPEND CPACK_SOURCE_IGNORE_FILES "cmake_install.cmake")
20+
list(APPEND CPACK_SOURCE_IGNORE_FILES "config.h")
21+
list(APPEND CPACK_SOURCE_IGNORE_FILES "/CMakeFiles/")
22+
list(APPEND CPACK_SOURCE_IGNORE_FILES "/Testing/")
23+
list(APPEND CPACK_SOURCE_IGNORE_FILES "/_CPack_Packages/")
24+
list(APPEND CPACK_SOURCE_IGNORE_FILES "/build/")
25+
26+
include(CPack)
27+
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)

cmake/CMakeInstall.cmake

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# make install
2+
# cmake --install . --prefix "/home/myuser/installdir"
3+
4+
# installation rules for a project
5+
set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
6+
install(TARGETS osslsigncode RUNTIME DESTINATION ${BINDIR})
7+
if(MSVC)
8+
install(FILES
9+
"${PROJECT_BINARY_DIR}/libcrypto-3-x64.dll"
10+
"${PROJECT_BINARY_DIR}/libssl-3-x64.dll"
11+
"${PROJECT_BINARY_DIR}/libcurl.dll"
12+
DESTINATION ${BINDIR}
13+
)
14+
endif()
15+
16+
# install bash completion script
17+
if(NOT MSVC)
18+
find_package(bash-completion QUIET)
19+
if(NOT BASH_COMPLETION_COMPLETIONSDIR)
20+
if(BASH_COMPLETION_COMPATDIR)
21+
set(BASH_COMPLETION_COMPLETIONSDIR ${BASH_COMPLETION_COMPATDIR})
22+
else()
23+
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share")
24+
set(BASH_COMPLETION_COMPLETIONSDIR "${SHAREDIR}/bash-completion/completions")
25+
endif()
26+
endif()
27+
message(STATUS "Using bash completions dir ${BASH_COMPLETION_COMPLETIONSDIR}")
28+
install(FILES "osslsigncode.bash" DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR})
29+
endif()

0 commit comments

Comments
 (0)