I'm facing a cmake error while trying to build openvpn3 for android platform on my ubuntu system. The CMake generate steps fail stating:
CMake Error at test/ovpncli/CMakeLists.txt:10 (add_library):
Target "xkey" links to target "OpenSSL::SSL" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?
CMake Error at test/ovpncli/CMakeLists.txt:20 (add_executable):
Target "ovpncli" links to target "OpenSSL::SSL" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
CMake Error at test/ovpncli/CMakeLists.txt:20 (add_executable):
Target "ovpncli" links to target "OpenSSL::SSL" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
If a persist and try to execute the make command for the failed build file this is the error I get
[ 20%] Building C object test/ovpncli/CMakeFiles/xkey.dir/__/__/openvpn/openssl/xkey/xkey_helper.c.o
In file included from /home/e03014/e03014/openvpn3/openvpn/openssl/xkey/xkey_helper.c:15:
/home/e03014/e03014/openvpn3/openvpn/openssl/xkey/xkey_common.h:24:10: fatal error: 'openssl/opensslv.h' file not found
24 | #include <openssl/opensslv.h>
| ^~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [test/ovpncli/CMakeFiles/xkey.dir/build.make:76: test/ovpncli/CMakeFiles/xkey.dir/__/__/openvpn/openssl/xkey/xkey_helper.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:190: test/ovpncli/CMakeFiles/xkey.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
The cmake command that I'm executing at the root level is as follows:
cmake -DOPENSSL_ROOT_DIR=../openssl -DOPENSSL_LIBRARY=../openssl/build/lib/libssl.so -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-21 -DBUILD_TESTING=OFF -DOPENSSL_CRYPTO_LIBRARY=../openssl/build/lib/libcrypto.so -DOPENSSL_INCLUDE_DIR=/home/userName/userName/openssl/build/include -DASIO_INCLUDE_DIR=/home/userName/userName/asio/asio/include -DLZ4_INCLUDE_DIR=/home/userName/userName/lz4/lib -DLZ4_LIBRARY=/home/userName/userName/lz4/lib/liblz4.so -DOPENVPN3_BUILD_OVPNCLI=OFF -Bbuild
The paths mentioned above are well verified; The only reason which might generate the error mentioned above is the wrong path provided for the flag -DOPENSSL_INCLUDE_DIR, but I've verified time and time again that the patch provided is correct and it does contains the .h files required.
If I figured out the solution for the same and therefore was able to execute the cmake command properly; The problem lied with the cmake command and apprently the OPENSSL_ROOT_DIR flag should've been pointing to the build directory. Hereby is the cmake command I used:
cmake -DANDROID_ABI=arm64-v8a -DOPENSSL_ROOT_DIR=../openssl/build -DOPENSSL_CRYPTO_LIBRARY=../openssl/build/lib/libcrypto.so -DOPENSSL_SSL_LIBRARY=../openssl/build/lib/libssl.so -DOPENSSL_INCLUDE_DIR=../openssl/build/include -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake -DBUILD_SHARED_LIBS=ON -DANDROID_PLATFORM=android-24 -DBUILD_TESTING=OFF -DASIO_INCLUDE_DIR=/home/e03014/e03014/asio/asio/include -DLZ4_INCLUDE_DIR=/home/e03014/e03014/lz4/lib -DLZ4_LIBRARY=/home/e03014/e03014/lz4/lib/liblz4.so -DBUILD_SWIG_LIB=ON -Bbuild