janbar / openssl-cmake Goto Github PK
View Code? Open in Web Editor NEWBuild OpenSSL with CMake on MacOS, Win32, Win64 and cross compile for Android, IOS
License: Other
Build OpenSSL with CMake on MacOS, Win32, Win64 and cross compile for Android, IOS
License: Other
OpenSSL 1.1.1w 11 Sep 2023 Copyright (c) 1998-2023 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson All rights reserved. DESCRIPTION ----------- The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, fully featured, and Open Source toolkit implementing the Transport Layer Security (TLS) protocols (including SSLv3) as well as a full-strength general purpose cryptographic library. OpenSSL is descended from the SSLeay library developed by Eric A. Young and Tim J. Hudson. The OpenSSL toolkit is licensed under a dual-license (the OpenSSL license plus the SSLeay license), which means that you are free to get and use it for commercial and non-commercial purposes as long as you fulfill the conditions of both licenses. OVERVIEW -------- The OpenSSL toolkit includes: libssl (with platform specific naming): Provides the client and server-side implementations for SSLv3 and TLS. libcrypto (with platform specific naming): Provides general cryptographic and X.509 support needed by SSL/TLS but not logically part of it. openssl: A command line tool that can be used for: Creation of key parameters Creation of X.509 certificates, CSRs and CRLs Calculation of message digests Encryption and decryption SSL/TLS client and server tests Handling of S/MIME signed or encrypted mail And more... INSTALLATION ------------ See the appropriate file: INSTALL Linux, Unix, Windows, OpenVMS, ... NOTES.* INSTALL addendums for different platforms SUPPORT ------- See the OpenSSL website www.openssl.org for details on how to obtain commercial technical support. Free community support is available through the openssl-users email list (see https://www.openssl.org/community/mailinglists.html for further details). If you have any problems with OpenSSL then please take the following steps first: - Download the latest version from the repository to see if the problem has already been addressed - Configure with no-asm - Remove compiler optimization flags If you wish to report a bug then please include the following information and create an issue on GitHub: - OpenSSL version: output of 'openssl version -a' - Configuration data: output of 'perl configdata.pm --dump' - OS Name, Version, Hardware platform - Compiler Details (name, version) - Application Details (name, version) - Problem Description (steps that will reproduce the problem, if known) - Stack Traceback (if the application dumps core) Just because something doesn't work the way you expect does not mean it is necessarily a bug in OpenSSL. Use the openssl-users email list for this type of query. HOW TO CONTRIBUTE TO OpenSSL ---------------------------- See CONTRIBUTING LEGALITIES ---------- A number of nations restrict the use or export of cryptography. If you are potentially subject to such restrictions you should seek competent professional legal advice before attempting to develop or distribute cryptographic code.
Hello
I got some errors when I try to add this macro OPENSSL_NO_ENGINE to CMakelist.txt. I try to add it to CMakelist.txt like this:
set( CONF "
#define OPENSSL_NO_MD2
#define OPENSSL_NO_RC5
#define OPENSSL_NO_RFC3779
#define OPENSSL_NO_EC_NISTP_64_GCC_128
#define OPENSSL_NO_ASYNC
#define OPENSSL_NO_ENGINE
${CONF}" )
I got some errors when I try to build the libs. It looks like blow:
/path/openssl-cmake-linux/crypto/engine/eng_all.c:11:
/path/openssl-cmake-linux/crypto/engine/eng_local.h:134:5: error: unknown type name 'ENGINE_CIPHERS_PTR'
ENGINE_CIPHERS_PTR ciphers;
In fact ENGINE_CIPHERS_PTR
is shielded by macro OPENSSL_NO_ENGINE
in include/openssl/engine.h
.
According to my experience, if this macro is defined, the engine-related source files will not participate in the compilation.
The same issue also occurs when using another macro OPENSSL_NO_COMP
.
So I want to confirm whether it currently supports the use of macros to customize some functions?
Thanks very much.
Hi!
Thanks for this project which is quite useful.
Would it be possible to use target_include_directories to link the include folders to the targets? Like that the include directories are automatically linked to any target having ssl and/or crypto as dependency instead of having to set them manually.
output:
/home/txz/test/testCMake/t10/build-android/src/openssl/crypto/threads_pthread.c:183: error: undefined reference to 'pthread_atfork'
clang38: error: linker command failed with exit code 1 (use -v to see invocation)
crypto/CMakeFiles/crypto.dir/build.make:16552: recipe for target 'crypto/libcrypto.so' failed
make[5]: *** [crypto/libcrypto.so] Error 1
compile command:
/cross/github/jni/android-ndk-r14b/
is my android-ndk path.
cmake -DCMAKE_TOOLCHAIN_FILE=/cross/github/jni/android-ndk-r14b/build/cmake/android.toolchain.cmake -DANDROID_TOOLCHAIN=clang -DANDROID_ABI=armeabi-v7a -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang ..;
and how can i compile crypto with static option?
i found this code on this project
set( CMAKE_THREAD_PREFER_PTHREAD TRUE )
find_package ( Threads )
if( NOT Threads_FOUND )
add_submodule ( . threads_none.c )
elseif( WIN32 )
add_submodule ( . threads_win.c )
else()
add_submodule ( . threads_pthread.c )
endif()
if( ANDROID )
add_library( crypto SHARED ${LIBSRC} ${OBJECTS_SRC} )
else()
add_library( crypto ${LIBSRC} ${OBJECTS_SRC} )
endif()
on my demo project:
set(ANDROID_BUILD_ARGS "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}"
"-DCMAKE_TOOLCHAIN_FILE=/cross/github/jni/android-ndk-r14b/build/cmake/android.toolchain.cmake"
"-DANDROID_UNIFIED_HEADERS=ON"
"-DANDROID_TOOLCHAIN=clang"
"-DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=/cross/github/jni/android-ndk-r14b/my-android-toolchain"
"-DANDROID_ABI=armeabi-v7a"
"-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang")
if(ANDROID)
LIST(APPEND MY_CMAKE_ARGS ${ANDROID_BUILD_ARGS})
endif()
externalproject_add(
openssl
#GIT_REPOSITORY https://github.com/janbar/openssl-cmake.git
URL ${CMAKE_SOURCE_DIR}/vendor/openssl-cmake-1.1.1.tar.gz
#CONFIGURE_COMMAND ""
CMAKE_COMMAND ${CMAKE_COMMAND}
BUILD_COMMAND make
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
#UPDATE_DISCONNECTED 1
CMAKE_ARGS
${MY_CMAKE_ARGS}
# "-DCMAKE_CXX_FLAGS=-fPIC"
#"-DCMAKE_C_FLAGS=-fPIC"
BUILD_IN_SOURCE 1
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
)
I have tried to use the resulting libssl.a and libcrypto.a to compile it with python cryptography and apart from the issue that it requires -fPIC t be defined, the resulting libraries don't work with cryptography and mitmproxy that fails to access the necessary features it needs.
In particular, it seems that the resulting libraries under Ubuntu don't contain version information. It seems that a lot of compilation options used with the makefile are not generated by the cmake.
The openssl version 1.1.1n works fine.
I try this, not working.
FetchContent_Declare(
OpenSSL
GIT_REPOSITORY https://github.com/janbar/openssl-cmake.git
GIT_TAG "1.1.1k-20210430"
)
FetchContent_GetProperties(OpenSSL)
FetchContent_MakeAvailable(OpenSSL)
Please fix this -
crypto\threads_none.c(146,12):
return return 0;
Love the fork btw. Thanks for your work.
Hi,
I tried tons of things, as subdirectory etc.
But actually, I just need to create DLLs to ship with my executable and they cannot be found from a reliable source online.
And actually, I see that you use add_library
with shared but I don't get DLL output only lib :/ Any idea?
I got some errors.
Error C4235 nonstandard extension used: '__int128' keyword not supported on this architecture crypto e:\ue4proj\openssl-cmake-up_to_1.1.1\crypto\poly1305\poly1305_base2_44.c 21
In
openssl-cmake/crypto/CMakeLists.txt
Line 286 in 8ffd927
You should add user32 advapi32
. For example when disabling default libraries, I'm missing theses symbols:
lld-link-9: error: undefined symbol: __imp__GetProcessWindowStation@0
>>> referenced by libcrypto-1_1.lib(cryptlib.c.obj):(_OPENSSL_isservice)
lld-link-9: error: undefined symbol: __imp__GetUserObjectInformationW@20
>>> referenced by libcrypto-1_1.lib(cryptlib.c.obj):(_OPENSSL_isservice)
>>> referenced by libcrypto-1_1.lib(cryptlib.c.obj):(_OPENSSL_isservice)
lld-link-9: error: undefined symbol: __imp__MessageBoxA@16
>>> referenced by libcrypto-1_1.lib(cryptlib.c.obj):(_OPENSSL_showfatal)
lld-link-9: error: undefined symbol: __imp__RegisterEventSourceA@8
>>> referenced by libcrypto-1_1.lib(cryptlib.c.obj):(_OPENSSL_showfatal)
lld-link-9: error: undefined symbol: __imp__ReportEventA@36
>>> referenced by libcrypto-1_1.lib(cryptlib.c.obj):(_OPENSSL_showfatal)
lld-link-9: error: undefined symbol: __imp__DeregisterEventSource@4
>>> referenced by libcrypto-1_1.lib(cryptlib.c.obj):(_OPENSSL_showfatal)
When we want to link a static library to a dynamic one, the static lib has to be compiled with -fPIC on non-windows platforms.
It would be great if this option was available. With cmake it's just a simple line for both ssl and crypto:
set_property(TARGET ssl PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET crypto PROPERTY POSITION_INDEPENDENT_CODE ON)
Would you like me to make a PR for this?
Edit : for people having the same problem, I ended up adding -DCMAKE_POSITION_INDEPENDENT_CODE=ON
to the command line to set it without modifying the project.
In my project, it will stop at the download process.
Is someone have the success use with CPM cpmfindpackage()?
cmake_minimum_required(VERSION 3.5.1)
project(j2534-rpc)
set(CMAKE_CXX_STANDARD 11)
# architecture
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCHITECTURE_SLUG "x64")
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCHITECTURE_SLUG "ia32")
endif()
# variables
set(MSGPACK_USE_BOOST OFF CACHE BOOL "")
# dependencies
add_subdirectory("deps/msgpack-c")
add_subdirectory("deps/openssl-cmake")
add_subdirectory("deps/curl")
# diag test
add_executable(j2534-rpc-diag-test-${ARCHITECTURE_SLUG} SHARED j2534-rpc-diag-test.cpp)
target_link_libraries(j2534-rpc-diag-test-${ARCHITECTURE_SLUG} curl msgpack)
Brandons-MacBook-Air:j2534-rpc-js brandonros 2022-02-19 19:11:44 $ rm -rf output && cmake -S . -B "output"
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Doxygen: /opt/homebrew/bin/doxygen (found version "1.9.3") found components: doxygen missing components: dot
-- OpenSSL version 1.1.1m
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of long
-- Check size of long - done
-- Check size of long long
-- Check size of long long - done
-- Check size of int
-- Check size of int - done
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- curl version=[7.82.0-DEV]
-- Performing Test HAVE_SOCKADDR_IN6_SIN6_ADDR
-- Performing Test HAVE_SOCKADDR_IN6_SIN6_ADDR - Success
-- Performing Test HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
-- Performing Test HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID - Success
-- Found Perl: /usr/bin/perl (found version "5.30.3")
-- Looking for dlopen in ;-framework SystemConfiguration
-- Looking for dlopen in ;-framework SystemConfiguration - found
-- Looking for connect in socket;-framework SystemConfiguration
-- Looking for connect in socket;-framework SystemConfiguration - not found
-- Looking for gethostbyname in c
-- Looking for gethostbyname in c - found
-- Looking for gethostname
-- Looking for gethostname - found
CMake Error at /opt/homebrew/Cellar/cmake/3.22.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
/opt/homebrew/Cellar/cmake/3.22.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/opt/homebrew/Cellar/cmake/3.22.2/share/cmake/Modules/FindOpenSSL.cmake:574 (find_package_handle_standard_args)
deps/curl/CMakeLists.txt:436 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/brandonros/Desktop/j2534-rpc-js/output/CMakeFiles/CMakeOutput.log".
See also "/Users/brandonros/Desktop/j2534-rpc-js/output/CMakeFiles/CMakeError.log".
Brandons-MacBook-Air:j2534-rpc-js brandonros 2022-02-19 19:12:02 $
I am trying to build and use this library in android.
This is my cp/CMakeLists.txt's content:
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp)
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log)
file(GLOB_RECURSE OPENSSL_SOURCES "openssl/*.c")
include_directories(openssl/include)
add_library(openssl SHARED ${OPENSSL_SOURCES})
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib})
When I try to build this, I get this error:
C:/Users/admin/AndroidStudioProjects/CPR/app/src/main/cpp/openssl/crypto/bn/bn_depr.c:15:10: fatal error: 'openssl/opensslconf.h' file not found
What is the problem?
Thanks in advance.
My job is intergrate openssl to the c++ project of our team by cmake , and I found your repo, this repo.
Really nice repo.
But when I found the code in openssl-cmake/CMakeLists.txt:
...
if( MSVC )
include( MSVCRuntime )
configure_msvc_runtime()
...
MSVCRuntime.cmake
this file change all the C++ compiler options, make my project don't understand c++ syntax like:
syntax error: identifier '...'
Finally, I remove these two lines and get everything well.
include( MSVCRuntime )
configure_msvc_runtime()
Wish you consider about it.
i have a problem
CMakeLists.txt:144 (check_type_size)
in this line :
cmake version: 3.11 and 3.17
OS
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
Cmake log :
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
not exits in /root/worker/cmake/LinuxCMakeBuilder/build/SimpleQmlNotify/CMake/crossplatform/Linux/.cmake
LIB_OUTPUT_DIR = /root/worker/cmake/LinuxCMakeBuilder/build/SimpleQmlNotify/build/Release
-- buid type Release
-- Project QmlNotyfyService
-- c compiler /usr/bin/cc
-- cxx compiler /usr/bin/c++
-- build shared
-- qmake exec
using ccache in /usr/bin/ccache
using ccache in /usr/bin/ccache
not exits in /root/worker/cmake/LinuxCMakeBuilder/build/QtNetworkProtocol/QuasarAppLib/CMake/crossplatform/Linux/.cmake
LIB_OUTPUT_DIR = /root/worker/cmake/LinuxCMakeBuilder/build/QtNetworkProtocol/QuasarAppLib/build/Release
-- buid type Release
-- Project QuasarApp
-- c compiler /usr/bin/cc
-- cxx compiler /usr/bin/c++
-- build shared
-- qmake exec
-- OpenSSL version 1.1.1e
CMake Error at /usr/share/cmake-3.10/Modules/CheckIncludeFile.cmake:46 (configure_file):
configure_file attempted to configure a file:
/root/worker/cmake/LinuxCMakeBuilder/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
into a source directory.
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/CheckTypeSize.cmake:223 (check_include_file)
QtNetworkProtocol/openssl-cmake/CMakeLists.txt:144 (check_type_size)
-- Configuring incomplete, errors occurred!
See also "/root/worker/cmake/LinuxCMakeBuilder/build/CMakeFiles/CMakeOutput.log".
program finished with exit code 1
elapsedTime=2.454305
Any help please.
I notices that because this builds OpenSSL with library names like:
crypto_1_1x
instead of crypto
it means if you build/install OpenSSL with this repo, it won't be findable via find_package(OpenSSL)
So I made a little flag in my fork to prevent that renaming. It's called OPENSSL_BUILD_WITH_INSTALL_NAMES
I'm sending a PR if you want to take it!
I cloned the repo on a Raspberry Pi running Bullseye 64-bit. Running CMake in the root directory results in:
CMake Error at /usr/share/cmake-3.18/Modules/CheckIncludeFile.cmake:55 (configure_file):
configure_file attempted to configure a file:
/home/pi/dev/openssl-cmake/CMakeFiles/CMakeTmp/CheckIncludeFile.c into a
source directory.
Call Stack (most recent call first):
/usr/share/cmake-3.18/Modules/CheckTypeSize.cmake:230 (check_include_file)
CMakeLists.txt:144 (check_type_size)
Anybody have an idea?
hi:
I want to compile openssl-cmake on window7 platform.when I run this command:
D:\software\openssl-cmake>cmake -DCMAKE_INSTALL_PREFIX=D:\software\openssl-cmake -DCMAKE_BUILD_TYPE=debug -G "MinGW Makefiles" .
I get some error:
-- Detecting CXX compile features - done
-- OpenSSL version 1.1.1b
CMake Error at D:/software/gt_compress/3thparty/win_lib/CMake/share/cmake-3.9/Modules/CheckIncludeFile.cmake:46 (configure_file):
configure_file attempted to configure a file:
D:/software/openssl-cmake/CMakeFiles/CMakeTmp/CheckIncludeFile.c into a
source directory.
Call Stack (most recent call first):
D:/software/gt_compress/3thparty/win_lib/CMake/share/cmake-3.9/Modules/CheckTypeSize.cmake:223 (check_include_file)
CMakeLists.txt:144 (check_type_size)
I need your help.thanks.
Right now CMake gives the following warning:
CMake Deprecation Warning at CMakeLists.txt:29 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of CMake.
Thus the minimum version should be raised or a MAX
tag should be added to the CMake script.
The logic used in CMakeLists.txt#L149 can lead to the situation that on a 32-bit system where long long has size 8, the decision is made that SIXTY_FOUR_BIT
should be defined and thus BN_BYTES
becomes defined equal to 8 in header /include/openssl/bn.h. This situation occurs for example on Windows compiled with a 32-bit Visual Studio compiler.
This became recently evident to me in a seemingly invalid bug report of mine against the original openssl project (version 1.1.1t) openssl #20208, which has a new file /crypto/bn/rsa_sup_mul.c added, and an inappropriate preprocessor branch is entered in this case, namely rsa_sup_mul.c#L112 stopping with a linkage error due to the invalid attempt to use the 64-bit intrinsic _umul128
under 32-bit.
It seems to me that CMakeLists.txt#L149 should be corrected such that it only is entered on a system, where the pointer size is also equal to 8. One possible way of ensuring this could be by using the additional condition CMAKE_SIZEOF_VOID_P EQUAL 8
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.