fix mingw support

This commit is contained in:
Michał Trojnara 2022-08-03 22:22:46 +02:00
parent 7510e3c553
commit 86e4eb9252
5 changed files with 26 additions and 29 deletions

View File

@ -49,9 +49,9 @@ target_compile_definitions(osslsigncode PRIVATE HAVE_CONFIG_H=1)
# set sources
target_sources(osslsigncode PRIVATE osslsigncode.c msi.c)
if(WIN32)
if(NOT UNIX)
target_sources(osslsigncode PRIVATE applink.c)
endif(WIN32)
endif(NOT UNIX)
# set include directories
target_include_directories(osslsigncode PRIVATE "${PROJECT_BINARY_DIR}")
@ -81,7 +81,9 @@ include(CMakeTest)
# installation rules for a project
install(TARGETS osslsigncode RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
if(WIN32)
if(UNIX)
include(CMakeDist)
else(UNIX)
install(
DIRECTORY ${PROJECT_BINARY_DIR}/ DESTINATION ${CMAKE_INSTALL_PREFIX}
FILES_MATCHING
@ -90,6 +92,4 @@ if(WIN32)
PATTERN "CMakeFiles" EXCLUDE
PATTERN "Testing" EXCLUDE
)
else(WIN32)
include(CMakeDist)
endif(WIN32)
endif(UNIX)

View File

@ -30,7 +30,7 @@ set(sign_opt "-time" "1556708400"
"-n" "osslsigncode" "-ac" "${CERTS}/crosscert.pem"
)
if(NOT CMAKE_HOST_WIN32)
if(CMAKE_HOST_UNIX)
execute_process(
COMMAND "${CONF}/makecerts.sh"
WORKING_DIRECTORY ${CONF}

View File

@ -1,22 +1,17 @@
include(CheckIncludeFile)
include(CheckFunctionExists)
if(NOT MSVC)
if(UNIX)
check_function_exists(getpass HAVE_GETPASS)
check_include_file(termios.h HAVE_TERMIOS_H)
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
if(HAVE_SYS_MMAN_H)
check_function_exists(mmap HAVE_MMAP)
if(NOT HAVE_MMAP)
message(FATAL_ERROR "Error: Need mmap to build.")
endif()
endif()
endif()
# include wincrypt.h in Windows.h
if(MSVC AND NOT CYGWIN)
endif(HAVE_SYS_MMAN_H)
else(UNIX)
check_include_file(windows.h HAVE_MAPVIEWOFFILE)
if(NOT (HAVE_MMAP OR HAVE_MAPVIEWOFFILE))
message(FATAL_ERROR "Error: Need file mapping function to build.")
endif()
endif()
endif(UNIX)
if(NOT (HAVE_MMAP OR HAVE_MAPVIEWOFFILE))
message(FATAL_ERROR "Error: Need file mapping function to build.")
endif(NOT (HAVE_MMAP OR HAVE_MAPVIEWOFFILE))

View File

@ -85,7 +85,7 @@ function(add_compile_flags target)
target_compile_options(${target} PRIVATE $<$<CONFIG:DEBUG>:/D_FORTIFY_SOURCE=2>)
# Unrecognized compiler options are errors
target_compile_options(${target} PRIVATE $<$<CONFIG:DEBUG>:/options:strict>)
else()
else(MSVC)
check_c_compiler_flag("-fstack-protector-all" HAVE_STACK_PROTECTOR_ALL)
if(HAVE_STACK_PROTECTOR_ALL)
target_link_options(${target} PRIVATE -fstack-protector-all)
@ -98,14 +98,16 @@ function(add_compile_flags target)
endif()
endif()
# Support address space layout randomization (ASLR)
target_compile_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-fPIE>)
target_link_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-fPIE -pie>)
target_link_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-Wl,-z,relro>)
target_link_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-Wl,-z,now>)
target_link_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-Wl,-z,noexecstack>)
if(NOT (MINGW OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"))
target_compile_options(${target} PRIVATE -fPIE)
target_link_options(${target} PRIVATE -fPIE -pie)
target_link_options(${target} PRIVATE -Wl,-z,relro)
target_link_options(${target} PRIVATE -Wl,-z,now)
target_link_options(${target} PRIVATE -Wl,-z,noexecstack)
endif(NOT (MINGW OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"))
target_link_options(${target} PRIVATE -fstack-check)
add_compile_flag_to_targets(${target})
endif()
endif(MSVC)
endfunction()
add_compile_flags(osslsigncode)

View File

@ -61,9 +61,9 @@
#define OPENSSL_API_COMPAT 0x10100000L
#define OPENSSL_NO_DEPRECATED
#if defined(_MSC_VER) || defined(MINGW32)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define HAVE_WINDOWS_H
#endif /* _MSC_VER || MINGW32 */
#endif /* _MSC_VER || __MINGW32__ */
#ifdef HAVE_CONFIG_H
#include "config.h"