Skip to content

Commit

Permalink
CMake: The OpenSSL formula now uses CMAKE_C_COMPILER
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrogario authored and Smjert committed Aug 25, 2019
1 parent 299a5e0 commit f4f71e5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
43 changes: 42 additions & 1 deletion libraries/cmake/formula/modules/utils.cmake
Expand Up @@ -133,11 +133,14 @@ function(importFormula library_name)
"${log_folder_path}/${library_name}.txt"
)

getCompilationFlags(c c_compilation_flags)
getCompilationFlags(cxx cxx_compilation_flags)

add_custom_command(
OUTPUT ${output_file_list}
COMMAND "${CMAKE_COMMAND}" -E make_directory "${log_folder_path}"
COMMAND "${CMAKE_COMMAND}" -E remove -f "${log_file_path}"
COMMAND "${CMAKE_COMMAND}" ${formula_dependency_settings} "${project_directory_path}" >> "${log_file_path}" 2>&1
COMMAND "${CMAKE_COMMAND}" -DC_FLAGS:STRING="${c_compilation_flags}" -DCXX_FLAGS:STRING="${c_compilation_flags}" ${formula_dependency_settings} "${project_directory_path}" >> "${log_file_path}" 2>&1
COMMAND "${CMAKE_COMMAND}" --build . --config "${CMAKE_BUILD_TYPE}" >> "${log_file_path}" 2>&1
WORKING_DIRECTORY "${build_directory_path}"
COMMENT "Running formula: ${library_name} (${log_file_path})"
Expand Down Expand Up @@ -176,3 +179,41 @@ function(importFormula library_name)
message(STATUS " Revision: ${metadata_revision}")
message(STATUS " Dependencies: ${metadata_dependencies}")
endfunction()

function(getCompilationFlags language output_variable)
if("${language}" STREQUAL "c")
set(target_name_list "c_settings")

elseif("${language}" STREQUAL "cxx")
set(target_name_list "cxx_settings")

else()
message(FATAL_ERROR "Invalid language specified. Valid options are c and cxx")
endif()

list(APPEND target_name_list
global_settings
)

unset("${output_variable}")

foreach(target_name ${target_name_list})
get_target_property(compile_option_list "${target_name}" INTERFACE_COMPILE_OPTIONS)
get_target_property(compile_def_list "${target_name}" INTERFACE_COMPILE_DEFINITIONS)

if(NOT "${compile_option_list}" STREQUAL "compile_option_list-NOTFOUND")
list(APPEND "${output_variable}" ${compile_option_list})
endif()

if(NOT "${compile_def_list}" STREQUAL "compile_def_list-NOTFOUND")
foreach(compile_def ${compile_def_list})
list(APPEND "${output_variable}"
"-D${compile_def}"
)
endforeach()
endif()
endforeach()

string(REPLACE ";" "," "${output_variable}" "${${output_variable}}")
set("${output_variable}" "${${output_variable}}" PARENT_SCOPE)
endfunction()
16 changes: 11 additions & 5 deletions libraries/cmake/formula/openssl/CMakeLists.txt
Expand Up @@ -13,14 +13,19 @@ function(opensslMain)
return()
endif()

# TODO(alessandro): Port all the settings from the original formula AND make sure it uses CMAKE_C_COMPILER
# The formula will be configured with the C_FLAGS and CXX_FLAGS parameters; we should
# forward them to the configure script when possible
message(WARNING "TODO: Use C_FLAGS")

# TODO(alessandro): Port all the settings from the original formula
# TODO(alessandro): Use the compilation flags we got from the main project (C_FLAGS, CXX_FLAGS)
ExternalProject_Add(
openssl
URL "http://www.openssl.org/source/openssl-1.0.2o.tar.gz"
URL "https://www.openssl.org/source/openssl-1.0.2o.tar.gz"

CONFIGURE_COMMAND
perl ./Configure "--prefix=${CMAKE_INSTALL_PREFIX}"
"--openssldir=${CMAKE_INSTALL_PREFIX}/etc/openssl"
"${CMAKE_COMMAND}" -E env CC="${CMAKE_C_COMPILER}"
perl ./Configure "--prefix=${CMAKE_INSTALL_PREFIX}" "--openssldir=${CMAKE_INSTALL_PREFIX}/etc/openssl"
no-ssl2
no-ssl3
no-asm
Expand All @@ -33,7 +38,8 @@ function(opensslMain)
linux-x86_64

BUILD_COMMAND
"${CMAKE_COMMAND}" -E make_directory "${CMAKE_INSTALL_PREFIX}/etc/openssl" &&
"${CMAKE_COMMAND}" -E env CC="${CMAKE_C_COMPILER}"
"${CMAKE_COMMAND}" -E make_directory "${CMAKE_INSTALL_PREFIX}/etc/openssl" &&
$(MAKE) depend -j 10 &&
$(MAKE) -j 10

Expand Down

0 comments on commit f4f71e5

Please sign in to comment.