Skip to content

Commit

Permalink
Fixed broken crosscompiler support (#228)
Browse files Browse the repository at this point in the history
* Fixed broken --with-target-path handling. Changed OpenSSL detection to handle broken cross-compiler pkg-config.
  • Loading branch information
ethouris authored and rndi committed Jan 22, 2018
1 parent 1891e76 commit 1b8a4c2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
31 changes: 28 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,35 @@ if ( USE_GNUTLS )
message(STATUS "SSL Dependency: using GNUTLS with Nettle, as requested")
else()
set (SSL_REQUIRED_MODULES "openssl libcrypto zlib")
find_package(OpenSSL REQUIRED)
set (SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
set (SSL_LIBRARIES ${OPENSSL_LIBRARIES})

if (USE_OPENSSL_PC)

pkg_check_modules(SSL REQUIRED ${SSL_REQUIRED_MODULES})

# We have some cases when pkg-config is improperly configured
# When it doesn't ship the -L and -I options, and the CMAKE_PREFIX_PATH
# is set (also through `configure`), then we have this problem. If so,
# set forcefully the -I and -L contents to prefix/include and
# prefix/lib.

if ("${SSL_LIBRARY_DIRS}" STREQUAL "")
if (NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
message(STATUS "WARNING: pkg-config has incorrect prefix - enforcing target path prefix: ${CMAKE_PREFIX_PATH}")
set (SSL_LIBRARY_DIRS ${CMAKE_PREFIX_PATH}/lib)
set (SSL_INCLUDE_DIRS ${CMAKE_PREFIX_PATH}/include)
endif()
endif()

link_directories(
${SSL_LIBRARY_DIRS}
)
message(STATUS "SSL REPORT: -L ${SSL_LIBRARY_DIRS} -I ${SSL_INCLUDE_DIRS} -l;${SSL_LIBRARIES}")
else()

find_package(OpenSSL REQUIRED)
set (SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
set (SSL_LIBRARIES ${OPENSSL_LIBRARIES})
endif()
add_definitions(
-DHAICRYPT_USE_OPENSSL_EVP=1
-DHAICRYPT_USE_OPENSSL_AES
Expand Down
15 changes: 9 additions & 6 deletions configure-data.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ proc preprocess {} {
if { [info exists ::optval(--with-target-path)] } {
set ::target_path $::optval(--with-target-path)
unset ::optval(--with-target-path)
puts "NOTE: Explicit target path: $::target_path"
}

# # Now finally turn --with-compiler-prefix into cmake-c-compiler etc.
Expand Down Expand Up @@ -302,10 +303,11 @@ proc postprocess {} {
return no
}

if { ![info exists ::target_path)] } {
if { ![info exists ::target_path] } {
# Try to autodetect the target path by having the basic 3 directories.
set target_path ""
set compiler_prefix [file dirname $compiler_path] ;# strip 'bin' directory
puts "NOTE: no --with-target-path found, will try to autodetect at $compiler_path"
foreach path [list $compiler_path $compiler_prefix/$target] {
if { [check-target-path $path] } {
set target_path $path
Expand All @@ -326,9 +328,6 @@ proc postprocess {} {
exit 1
}
puts "NOTE: Using explicit target path: $target_path"

# Prevent --with-target-path from being translated
unset ::optval(--with-target-path)
}

# Add this for cmake, should it need for something
Expand All @@ -337,9 +336,13 @@ proc postprocess {} {
# Add explicitly the path for pkg-config
# which lib
if { [file isdir $target_path/lib64/pkgconfig] } {
set env(PKG_CONFIG_PATH) $target_path/lib64/pkgconfig
set ::env(PKG_CONFIG_PATH) $target_path/lib64/pkgconfig
puts "PKG_CONFIG_PATH: Found pkgconfig in lib64 for '$target_path' - using it"
} elseif { [file isdir $target_path/lib/pkgconfig] } {
set env(PKG_CONFIG_PATH) $target_path/lib/pkgconfig
set ::env(PKG_CONFIG_PATH) $target_path/lib/pkgconfig
puts "PKG_CONFIG_PATH: Found pkgconfig in lib for '$target_path' - using it"
} else {
puts "PKG_CONFIG_PATH: NOT changed, no pkgconfig in '$target_path'"
}
# Otherwise don't set PKG_CONFIG_PATH and we'll see.
}
Expand Down

0 comments on commit 1b8a4c2

Please sign in to comment.