diff --git a/CMakeLists.txt b/CMakeLists.txt index e1976ce..096b656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,94 +21,6 @@ set(SOURCE_DIR "${CMAKE_SOURCE_DIR}/src") set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") include(AddGitSubmodule) -add_git_submodule(external openssl https://github.com/openssl/openssl.git) - -set(OPENSSL_PATH "${EXTERNAL_DIR}/openssl") - -if (NOT EXISTS "${OPENSSL_PATH}/CMakeLists.txt") - - include(ExternalProject) - - if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - - # Add the directory containing Perl to the CMAKE_PREFIX_PATH variable - list(APPEND CMAKE_PREFIX_PATH "E://Strawberry_Perl//perl//bin") - find_package(Perl) - - if(${PERL_FOUND}) - message(STATUS "Found perl: ${PERL_EXECUTABLE}") - else() - message(FATAL_ERROR "Perl executable not found.") - endif() - - set(CONFIGURE_COMMAND ${PERL_EXECUTABLE} Configure --prefix=${OPENSSL_PATH}/build --openssldir=${OPENSSL_PATH}/build/ssl ) - - elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(CONFIGURE_COMMAND ./Configure --prefix=${OPENSSL_PATH}/build --openssldir=${OPENSSL_PATH}/build/ssl ) - - endif() - - find_program(MAKE_EXE NAMES nmake make) - - if(MAKE_EXE) - message(STATUS "Found platform specific make executable: ${MAKE_EXE}") - else() - message(FATAL_ERROR "nmake not found. Please make sure it is installed.") - endif() - - - if(NOT EXISTS "${OPENSSL_PATH}/build") - - execute_process( - COMMAND ${CONFIGURE_COMMAND} - WORKING_DIRECTORY ${OPENSSL_PATH} - RESULT_VARIABLE result - ) - - - if(result) - message(FATAL_ERROR "Configuration Command failed.") - endif() - - execute_process( - COMMAND ${MAKE_EXE} - WORKING_DIRECTORY ${OPENSSL_PATH} - RESULT_VARIABLE result - ) - - if(result) - message(FATAL_ERROR "make Command failed.") - endif() - - set(MAKE_EXE_INSTALL ${MAKE_EXE} install) - - execute_process( - COMMAND ${MAKE_EXE_INSTALL} - WORKING_DIRECTORY ${OPENSSL_PATH} - RESULT_VARIABLE result - ) - - if(result) - message(FATAL_ERROR "make install Command failed.") - endif() - - endif() - - #This will be executed during build time not CMake Time. - #ExternalProject_Add( - # OpenSSL_deps - # PREFIX ${CMAKE_BINARY_DIR}/external - # DOWNLOAD_COMMAND "" # No download command since we're not downloading, assuming Makefile is already present - # SOURCE_DIR ${OPENSSL_PATH} # Specify the path to the directory containing the Makefile - # BINARY_DIR ${OPENSSL_PATH}/lib #All the build file will be present here, if BUILD_IN_SOURCE is not set. - # CONFIGURE_COMMAND ${CONFIGURE_COMMAND} # No configure command needed for Makefile-based projects - # BUILD_COMMAND ${MAKE_EXE} # Command to build the project using make - # INSTALL_COMMAND "" # No install command needed for Makefile-based projects - # BUILD_IN_SOURCE 0 # Build the project in the source directory - #) - -endif() - set(OPENSSL_USE_STATIC_LIBS TRUE) find_package(OpenSSL) @@ -119,9 +31,99 @@ if( OPENSSL_FOUND ) message(STATUS "OpenSSL found: ${OPENSSL_LIBRARIES}") else() message(FATAL_ERROR "System OpenSSL not found") - endif() +endif() if( NOT OPENSSL_FOUND ) + + add_git_submodule(external openssl https://github.com/openssl/openssl.git) + + set(OPENSSL_PATH "${EXTERNAL_DIR}/openssl") + + if (NOT EXISTS "${OPENSSL_PATH}/CMakeLists.txt") + + include(ExternalProject) + + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + + # Add the directory containing Perl to the CMAKE_PREFIX_PATH variable + list(APPEND CMAKE_PREFIX_PATH "E://Strawberry_Perl//perl//bin") + find_package(Perl) + + if(${PERL_FOUND}) + message(STATUS "Found perl: ${PERL_EXECUTABLE}") + else() + message(FATAL_ERROR "Perl executable not found.") + endif() + + set(CONFIGURE_COMMAND ${PERL_EXECUTABLE} Configure --prefix=${OPENSSL_PATH}/build --openssldir=${OPENSSL_PATH}/build/ssl ) + + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(CONFIGURE_COMMAND ./Configure --prefix=${OPENSSL_PATH}/build --openssldir=${OPENSSL_PATH}/build/ssl ) + + endif() + + find_program(MAKE_EXE NAMES nmake make) + + if(MAKE_EXE) + message(STATUS "Found platform specific make executable: ${MAKE_EXE}") + else() + message(FATAL_ERROR "nmake not found. Please make sure it is installed.") + endif() + + + if(NOT EXISTS "${OPENSSL_PATH}/build") + + execute_process( + COMMAND ${CONFIGURE_COMMAND} + WORKING_DIRECTORY ${OPENSSL_PATH} + RESULT_VARIABLE result + ) + + + if(result) + message(FATAL_ERROR "Configuration Command failed.") + endif() + + execute_process( + COMMAND ${MAKE_EXE} + WORKING_DIRECTORY ${OPENSSL_PATH} + RESULT_VARIABLE result + ) + + if(result) + message(FATAL_ERROR "make Command failed.") + endif() + + set(MAKE_EXE_INSTALL ${MAKE_EXE} install) + + execute_process( + COMMAND ${MAKE_EXE_INSTALL} + WORKING_DIRECTORY ${OPENSSL_PATH} + RESULT_VARIABLE result + ) + + if(result) + message(FATAL_ERROR "make install Command failed.") + endif() + + endif() + + #This will be executed during build time not CMake Time. + #ExternalProject_Add( + # OpenSSL_deps + # PREFIX ${CMAKE_BINARY_DIR}/external + # DOWNLOAD_COMMAND "" # No download command since we're not downloading, assuming Makefile is already present + # SOURCE_DIR ${OPENSSL_PATH} # Specify the path to the directory containing the Makefile + # BINARY_DIR ${OPENSSL_PATH}/lib #All the build file will be present here, if BUILD_IN_SOURCE is not set. + # CONFIGURE_COMMAND ${CONFIGURE_COMMAND} # No configure command needed for Makefile-based projects + # BUILD_COMMAND ${MAKE_EXE} # Command to build the project using make + # INSTALL_COMMAND "" # No install command needed for Makefile-based projects + # BUILD_IN_SOURCE 0 # Build the project in the source directory + #) + + endif() + + find_package(OpenSSL PATHS "${OPENSSL_PATH}/build") if( OPENSSL_FOUND )