Skip to content

Commit

Permalink
Fix build on Linux (Ubuntu)
Browse files Browse the repository at this point in the history
In order to statically link the libssh2 library from the `.deps` folder using
the ExternalProjects module for Cmake, the static library needs to be compiled
with the `-fPIC` flag. In Cmake, this is the `CMAKE_POSITION_INDEPENDENT_CODE`
property and it can be set using the `-D` flag in the `CMAKE_ARGS` property for
the external project. Note, the `CMAKE_POSITION_INDEPENDENT_CODE` property is
`ON` by default for a _shared_ library, but it is `OFF` by default for a
_static_ library. Thus, it needs to be explicitly set to `ON` for the static
linking on Linux system.
  • Loading branch information
volks73 committed May 8, 2019
1 parent 6864819 commit 94eeb86
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if(BUILD_DEPS)
UPDATE_COMMAND ""
CMAKE_GENERATOR ${LIBSSH2_CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${LIBSSH2_CMAKE_GENERATOR_PLATFORM}
CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DCRYPTO_BACKEND=OpenSSL -DOPENSSL_ROOT_DIR=${OPENSSL_BINARY_DIR}
CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DCRYPTO_BACKEND=OpenSSL -DOPENSSL_ROOT_DIR=${OPENSSL_BINARY_DIR} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
BUILD_IN_SOURCE NO
TEST_COMMAND ""
INSTALL_COMMAND ""
Expand Down

0 comments on commit 94eeb86

Please sign in to comment.