Cmake Openssl not found - cmake

Want to cross-compile a C application that uses Azure IoT SDK, which unfortunately requires Cmake. Cmake refuses to build my toolchain because it claims that it cannot find Openssl that I've compiled for my target architecture.
I've tried adding OPENSSL_ROOT_DIR to the folder it's in.
SET(OPENSSL_ROOT_DIR /path/to/openssl)
I continually get the error:
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES) (found
version "1.0.2g")
I also tried setting system variables to these folder as the error suggests, but it seemingly ignores them and prompts the same error. I've tried adding it to the same folder as my C compiler also to no avail.
I've run out of things to try and this point and I do not understand why it doesn't work. Any suggestions?

In Linux, I didn't have any problem setting OpenSSL.
In Windows, I solved as explained below.
Try removing CMakeCache.txt file and then do again. The cache Cmake is the main problem.
For instance, I did cmake . -DOPENSSL_ROOT_DIR=C:\openssl-1.0.2 -DOPENSSL_INCLUDE_DIR=C:\openssl-1.0.2\include -DOPENSSL_CRYPTO_LIBRARY=C:\openssl-1.0.2\crypto and everything got solved. The logic is same.

For MacOs I encounter the same error while installing ton'slite client (cmake ~/lite-client)
Solved as follows: I have open the "CMakeCache.txt" file in "liteclient-build" directory, find the line
OPENSSL_INCLUDE_DIR:PATH=OPENSSL_INCLUDE_DIR-NOTFOUND
and change it to with my openssl location
OPENSSL_INCLUDE_DIR:PATH=/usr/local/opt/openssl/include

Related

Compiling project that depend on LLVM using CMake on Windows

I'm a *nix user, installing LLVM is easy for me, just download the precompiled file, set LLVM_DIR, and you're done. But I'm having a lot of problems with Windows ...
I downloaded LLVM-<version>-win64.exe from the GitHub release, but I can't find LLVMConfig.cmake file. Then I tried to compile LLVM from the source following this documentation.
When I started compiling my own project, I got this error:
'C:/<...>/Debug/libLLVMSupport.lib', needed by '<...>.exe', missing and no known rule to make it
I guess maybe I'm missing some compile options. but I can't find the documentation for LLVM_ENABLE_PROJECTS or BUILD_SHARED_LIBS, not even a list of component names.
I tried to add -DBUILD_SHARED_LIBS=ON but CMake told me BUILD_SHARED_LIBS option is not supported on Windows.

wxWidgets CMake Windows Setup Troubles

I am really struggling to setup wxWidgets to work on Windows and CMake and would appreciate some help.
I have downloaded wxWidgets 3.1.4, run the setup (which extracted to C:\CPP_lib\wxWidgets) and then ran the following commands in the terminal:
cd C:\CPP_lib
mkdir wxWidgets-install
cmake C:\CPP_lib\wxWidgets -DCMAKE_INSTALL_PREFIX=C:\CPP_lib\wxWidgets-install -DwxBUILD_SHARED=OFF
cd wxWidgets-install
cmake --build . --target install
I have environment variables CMAKE_PREFIX_PATH set to C:\CPP_lib and wxWidgets_DIR and wxWidgets_ROOT_DIR both set to C:\CPP_lib\wxWidgets-install.
However, when I have a simple CMake project that calls find_package(wxWidgets), I get the following message in the terminal:
Found wxWidgets: winmm;comctl32;uuid;oleacc;uxtheme;rpcrt4;shlwapi;version;wsock32
missing components: core base png tiff jpeg zlib regex expat
Please help - I have been struggling for a while now :(
It turns out the issue was a very specific one related to vcpkg.
I had pointed CMake to my vcpkg toolchain file (even though wxWidgets was installed independent of vcpkg) and this was causing issues with finding wxWidgets i.e. vcpkg was preventing wxWidgets (a non-vcpkg installation) from being found.
I believe this is a vcpkg bug, although am not sure, but have reported it anyways.

CMake Error with Eigen 3.3.4

I am trying to compile dolfin on openSUSE Leap 42.3. I get an error with CMake when it tries to find Eigen3. I have Eigen3.3.4 installed on my machine and the error is
CMake Error at cmake/modules/FindEigen3.cmake:42 (file):
file failed to open for reading (No such file or directory):
/usr//usr/include/eigen3/Eigen/src/Core/util/Macros.h
I don't know why the extra /usr/ is popping up at the beginning. Can anyone help me? I can't find a solution online.
Okay, this was an...interesting, but perhaps silly error. Forgive me...I'm new to openSUSE. I originally installed eigen3 through YaST. This did not come with a CMakeList.txt file, so naturally I was confused by the answer in c++ - Unable to find Eigen3 with CMake. Moreover I was confused because Eigen is just header files, so naturally I assumed there would be nothing to make.
Long story short, there are MakeList's for Eigen. You just have to download the tarball from eigen.tuxfamily.org, then build them with cmake.
dolfin? I want to know are you in the CFD area.
I also have Eigen installed in my leap 42.3. But i installed it from the official website of Eigen. I think you may have a try and then specify the folder of the Eigne in Cmake-gui.
Good luck to you.

Libgit2 and libssh2 CMake package 'libssh2' not found

So trying to CMake libgit on windows, ive build a valid libssh2 but I'm getting this error when compiling libgit
checking for module 'libssh2'
package 'libssh2' not found
LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.
Configuring done
now ive tried setting the default prefix path and ive tried setting library paths but I just cant get it to see my libssh2? any ideas?
its getting quite frustrating as I have it right here and it cant find it :D
maybe someone could tell me the correct path it should be installed?
Kind regards
Rob
****************Update 1****************
so i pulled out of the make file this....seems to have changed but as far as i can see PKG_CHECK_MODULES(LIBSSH2 libssh2) is the check, maybe it doesnt set LIBSSH2_FOUND?
# Optional external dependency: libssh2
IF (USE_SSH)
PKG_CHECK_MODULES(LIBSSH2 libssh2)
ENDIF()
IF (LIBSSH2_FOUND)
ADD_DEFINITIONS(-DGIT_SSH)
INCLUDE_DIRECTORIES(${LIBSSH2_INCLUDE_DIRS})
LINK_DIRECTORIES(${LIBSSH2_LIBRARY_DIRS})
LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
#SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${LIBSSH2_LDFLAGS}")
SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES})
CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS)
ADD_DEFINITIONS(-DGIT_SSH_MEMORY_CREDENTIALS)
ENDIF()
ELSE()
MESSAGE(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
ENDIF()
ive tried setting LIBSSH2_INCLUDE_DIRS /LIBSSH2_INCLUDE_DIR and LIBSSH2_LIBRARIES to no avail?
****************Update 2****************
So as per sugested its searching for the .pc file. well i found it....pointed it directly at it and it still couldnt find it? i even pointed it several directories up from it. the paths in the pc file seem to match the locations i would expect.? is this make file just completly borked?
checking for module 'libssh2'
package 'libssh2' not found
LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.
****************Update 3****************
So update 3 i installed a binary of openssl on windows, further download libssh2-master and used cmake gui to build a visual studio solution which had no errors, the solution compiled and built. I made an install and package from the solution and installed in the suggested default location, i also took the header files, and library files and put them in my vc folder, and once i tried building the shared lib and put the dll in system32 etc so ive tried quite a lot :) libgit still cant find it
Hope thats a bit more info
****************Update 4****************
So fixed it in the end... i went back through the git history and blamed the make file. found someone originally wrote it with FIND_PACKAGE but changed it to suit their own needs.
so i changed it back and used the below. no longer complains and finds what it needs and compiles and works. so yay thanks for your help
IF (USE_SSH)
FIND_PACKAGE(LIBSSH2)
ENDIF()
IF (LIBSSH2_FOUND)
ADD_DEFINITIONS(-DGIT_SSH)
INCLUDE_DIRECTORIES(${LIBSSH2_INCLUDE_DIR})
LINK_DIRECTORIES(${LIBSSH2_LIBRARY_DIRS})
LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} libssh2")
SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES})
ADD_DEFINITIONS(-DGIT_SSH_MEMORY_CREDENTIALS)
ENDIF()
I actually started a new thread on this, i successfully managed it in the end. Answer is on
libgit2 with libssh2 and libopenssl on windows
so effectively
LIBSSH2_FOUND (set it to TRUE)
LIBSSH2_INCLUDE_DIRS
LIBSSH2_LIBRARY_DIRS

CMake does not find the source directory (installing Eigen)

I was installing the library Eigen on Ubuntu. I followed the instructions by creating a "build directory" alongside the downloaded source directory. That is, I have two directories: eigen-eigen-1306d75b4a21 for source, and an empty eigen-build for build.
Then I did:
cd eigen-build
cmake ../eigen-eigen-1306d75b4a21/
sudo make install
An error occurred immediately after make install and it stops the installation:
CMake Error: The source directory "/home/username/something/eigen-eigen-1306d75b4a21" does not exist.
Obviously the directory exists. What is wrong with my CMake? (I don't know much about CMake. I observed some warnings during the second step, saying lots of things such as Qt4 are missing, but I don't think this is the cause, because of what the error message suggests.)
Probably your directory does not include the CMakeLists.txt file.