cmake: You have called ADD_LIBRARY for library cryptopp without any source files - c++

Windows 64bit using cmake to compile c++ project: github.com/iHateInventNames/synergy-through-usb
I fixed a previous issue in this post: Compile issues: LIBUSB_1 with cmake project on Windows
So when I hit cmake now I get the following error:
> cmake .
-- Found libusb-1.0:
-- - Includes: C:/local/libs/libusbx
-- - Libraries: C:/local/libs/libusbx/libusb-1.0.lib
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
-- Generating done
-- Build files have been written to: C:/local/projects/synergy-usb/synergy-through-usb-master
What does this mean? how can I solve it / move on?
Links to the install instructions
both goto 404 errors...
http://synergy-project.org/projects/synergy/wiki/Readme/?hl=pm
http://synergy-project.org/projects/synergy/wiki/Compiling/?hl=pm

Based on a quick browse through the project's CMakeLists, it would seem you're supposed to unpack tools/cryptopp562.zip into a directory called tools/cryptopp562 before running CMake. This should definitely have been mentioned in the projects' installation instructions, if any.
More precisely, the file tools/CMakeLists.txt contains this code:
set(cpp_dir cryptopp562)
file(GLOB cpp_src ${cpp_dir}/*.cpp)
# ...
add_library(cryptopp STATIC ${cpp_src})
This means that the variable cpp_src is filled with source files taken from directory cryptopp562 (relative to the CMakeList's directory, i.e. tools), and is then used to define the source files of library cryptopp. However, the project's distribution only contains tools/cryptopp562.zip. Unpacking that into directory tools/cryptopp562 should provide the missing files.

Related

meson cannot find a conan package, despite setting pkg_config path?

I am trying to build on windows using meson and conan.
I installed packages for VS 2017 using conan and generated the PC files in the build directory.
Inside my conan.py I have the snippet:
meson = Meson(self)
self.output.warn(self.folders.generators)
meson.configure(build_folder="build", args=[
f"-Dpkg_config_path={self.folders.generators}",
f"-Db_sanitize=undefined"
])
meson.build(args=['-j2'])
I have checked and confirmed this works and that the directory is correct.
I also tried using absolute paths by doing:
os.path.abspath(self.folders.generators)
But meson still cannot find the package for some reason.
The exact error is:
Found pkg-config: C:\msys64\mingw64\bin\pkg-config.EXE (1.8.0)
Found CMake: C:\Program Files\CMake\bin\cmake.EXE (3.22.1)
Run-time dependency vulkan-memory-allocator found: NO (tried pkgconfig and cmake)
..\meson.build:97:0: ERROR: Dependency "vulkan-memory-allocator" not found, tried pkgconfig and cmake
A full log can be found at C:\Users\Makogan\Documents\neverengine\build\meson-logs\meson-log.txt
FAILED: build.ninja
"C:\Python311\Scripts\meson" "--internal" "regenerate" "C:\Users\Makogan\Documents\neverengine" "C:\Users\Makogan\Documents\neverengine\build" "--backend" "ninja"
ninja: error: rebuilding 'build.ninja': subcommand failed
ERROR: conanfile.py: Error in build() method, line 108
meson.build(args=['-j2'])
ConanException: Error 1 while executing ninja -C "C:\Users\Makogan\Documents\neverengine\build" -j2
It does work if I do meson --reconfigure -Dpkg_config=<path>.
I am confused.
Try specify instead -Dbuild.pkg_config_path=... from this
Since 0.51.0, some options are specified per machine rather than
globally for all machine configurations. Prefixing the option with
build. just affects the build machine configuration...
build.pkg_config_path controls the paths pkg-config will search for
just native: true dependencies (build machine).
PS, the version of meson and that you have native build I deduced from your previous question ;)

Meson on windows cannot find llvm-lib?

I am trying to port a Linux Library to windows, the library uses meson for compilation. I have a dummy meson.build file:
project(
'Dummy',
'cpp',
version: '0.0.1',
license: 'GPL',
default_options : [
'cpp_std=c++latest',
'default_library=static',
'optimization=3',
'buildtype=debugoptimized'])
When I run meson configure I get:
PS C:\Users\Makogan\Documents\neverengine\build> meson compile
[0/1] Regenerating build files.
The Meson build system
Version: 0.60.3
Source dir: C:\Users\Makogan\Documents\neverengine
Build dir: C:\Users\Makogan\Documents\neverengine\build
Build type: native build
Project name: NeverEngine
Project version: 0.0.1
C++ compiler for the host machine: cl (msvc 19.13.26131.1 "Microsoft (R) C/C++ Optimizing Compiler Version 19.13.26131.1 for x64")
C++ linker for the host machine: link link 14.13.26131.1
..\meson.build:1:0: ERROR: Unknown linker(s): [['lib'], ['llvm-lib']]
The following exception(s) were encountered:
Running "lib /?" gave "[WinError 2] The system cannot find the file specified"
Running "llvm-lib /?" gave "[WinError 2] The system cannot find the file specified"
A full log can be found at C:\Users\Makogan\Documents\neverengine\build\meson-logs\meson-log.txt
FAILED: build.ninja
"C:\Python311\Scripts\meson" "--internal" "regenerate" "C:\Users\Makogan\Documents\neverengine" "C:\Users\Makogan\Documents\neverengine\build" "--backend" "ninja"
ninja: error: rebuilding 'build.ninja': subcommand failed
Why is meson automatically searching for these libraries when it is aware it is on windows?
Those aren't libraries, those are static linkers (also called archivers), which are used to produce static libraries (those ending in .a or .lib, usually). Those are pretty important to meson, and it assumes that it can find the three pieces of the toolchain (The compiler, the archiver, and the [dynamic] linker) for any given language + machine.
It is interesting to me that meson is able to pick up the cl.exe and link.exe, but not lib.exe

cmake + cpp: No such file or directory

I've I'm trying to build this "Hello World" wxWidgets example on Linux, using the following cmake script:
cmake_minimum_required (VERSION 2.6)
project (wxL)
find_package(wxWidgets 3.0.0 REQUIRED
COMPONENTS base core net xml html adv qa richtext
)
file(GLOB SOURCES "src/*.cpp")
add_executable(wxL ${SOURCES})
Building the project yields this error:
src/wxL.cpp:3:10: fatal error: wx/wxprec.h: No such file or directory
The file specified in the include, wx/wxprec.h can be found on disk at this location:
/usr/include/wx-3.0/wx/wxprec.h
Furthermore, another program that I have built from source includes the same file (also using cmake) and builds just fine.
So, how do I use cmake to tell the compiler that the file should be included from somewhere in the system directories?
I know I'm missing something basic, but I can't figure out what.
Although you've found the package, your executable does not know anything about it.
For the executable to compile correctly, it needs to find header files for your package together with the .so / .a files. Following example should get you started:
include_directories(${wxWidgets_INCLUDE_DIRS})
add_executable(wxL <add-source-files-here>)
target_link_libraries(wxL ${wxWidgets_LIBRARIES}) // links wxWidgets libraries to your executable
Please note that using glob is not a recommended way of adding source files to your project.

What this CMake Error means? My variables are set to NOTFOUND

I am trying to run some code from my university, but when I do "cmake .." inside "build" I get the following error:
CMake Error: The following variables are used in this project, but
they are set to NOTFOUND. Please set them or make sure they are set
and tested correctly in the CMake files: iceutil_lib
linked by target "cppgui" in directory /Users/alej/Desktop/project1
linked by target "project1" in directory /Users/alej/Desktop/project1
-- Configuring incomplete, errors occurred!
Any of my friends are getting errors, can you help me?
CMake tries to find all the libraries necessary to create the library or executable you are trying to build from the code from your university.
The found paths to those libraries are stored in special variables in CMake. By default, those variables carry the value <Library-Name>-NOTFOUND. This NOTFOUND flag is what makes CMake prompt the error message.
In general there are two possible reasons, why CMake can not find the library for you:
The library is not installed on your system
The library is installed somewhere CMake did not search for it. In this case you can help CMake by setting the library installation path into the respective CMake variables. To do this, open the file CMakeCache.txt with a text editor and search for ICEUTIL_LIB. Replace the blabla-NOTFOUND value with the actual (absolute) path of the library. There might be other variables with the ICEUTIL prefix. One of them might be named like ICEUTIL_HEADERS or ICEUTIL_INCLUDE_DIR. Replace the value of this one with the absolute path of where the .h files for ICEUTIL are found. If the include path is not set, CMake might run fine without errors, but later you will run into compiler errors saying include file not found.

Adding LLVM to my Cmake Project: Why are there hardcoded paths in LLVM's Cmake file?

I'm using LLVM/Clang in my C++ project. I can build and run everything fine with a Makefile.
I'm now trying to move to Cmake and I can't get things to work. Let me explain what I've done.
I'm following this tutorial:
http://llvm.org/docs/CMake.html#embedding
A relevant snippet from that webpage is:
From LLVM 3.5 onwards both the CMake and autoconf/Makefile build
systems export LLVM libraries as importable CMake targets.
Great! I'll go download LLVM 3.5 and I should be good to go. I went to the download page:
http://llvm.org/releases/download.html
and downloaded the pre-built binaries for Clang for Ubuntu 14.04 Linux.
Then, I added the following to my CMakeLists.txt file:
find_path (LLVM_DIR LLVM-Config.cmake
/home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake
)
message(STATUS "LLVM_DIR = ${LLVM_DIR}")
find_package(LLVM REQUIRED CONFIG)
(This is the same as the tutorial, except I set LLVM_DIR since it is currently in a non-standard location.)
When I run cmake, I get the following error:
[dev#beauty:/path/to/project/build (develop)] $ cmake ..
-- LLVM_DIR = /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake
CMake Error at /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake/LLVMConfig.cmake:50 (include):
include could not find load file:
/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake/LLVMExports.cmake
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)
CMake Error at /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake/LLVMConfig.cmake:53 (include):
include could not find load file:
/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake/LLVM-Config.cmake
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)
So Cmake seems to be finding LLVM's Cmake file, but Cmake is complaining about some path starting with /home/ben/.
Indeed, it appears that LLVM's LLVMConfig.cmake file has some absolute paths in it that are not relevant for my machine. For example:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu ] $ head ./share/llvm/cmake/LLVMConfig.cmake
# This file provides information and services to the final user.
set(LLVM_INSTALL_PREFIX "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install")
set(LLVM_VERSION_MAJOR 3)
set(LLVM_VERSION_MINOR 5)
set(LLVM_VERSION_PATCH 0)
set(LLVM_PACKAGE_VERSION 3.5.0)
set(LLVM_COMMON_DEPENDS )
Who's ben and what's he doing in this file? He shows up in a few more places:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu ] $ grep ben ./share/llvm/cmake/LLVMConfig.cmake
set(LLVM_INSTALL_PREFIX "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install")
set(LLVM_INCLUDE_DIRS "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/include")
set(LLVM_LIBRARY_DIRS "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/lib")
set(LLVM_CMAKE_DIR "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake")
set(LLVM_TOOLS_BINARY_DIR "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/bin")
Needless to say, those paths do not exist on my machine. I'm confused as to why these files have these paths in them? Am I supposed to run a tool or something to change these paths for my machine? Or do I need to change them all manually?
EDIT: Out of curiosity, I manually changed all those paths to point to paths on my machine:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake ] $ sed -i -e's/.home.ben.development.llvm.3.5.final.Phase3.Release.llvmCore-3.5.0-final.install/\/home\/dev\/Downloads\/clang+llvm-3.5.0-x86_64-linux-gnu/g' *
After that, Cmake no longer complained and my build proceeded.
I'd still like to know why I needed to do that.
Sounds like a LLVM bug. Feel free to enter it: http://llvm.org/bugs
We just have to build with 'Ninja' instead of 'Unix Makefiles' and that's all