Errors compiling MinGW for CMake - c++

after making a breakthrough with my earlier MiniGW problem i have come across another. This is very diffrent from my understanding. from what i see everything compiles ok and i dont have a good enough understanding of cmake to know what the problem is.
here is the Error log
||=== Build: Icarus in Icarus (compiler: GNU GCC Compiler) ===|
CMakeFiles\Makefile2|60|recipe for target 'CMakeFiles/Icarus.dir/all' failed|
CMakeFiles\Makefile2|72|recipe for target 'CMakeFiles/Icarus.dir/rule' failed|
D:\Projects\SVN\Icarus\build\Makefile|110|recipe for target 'Icarus' failed|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
Here is the line in the makefile it points to
# Build rule for target.
Icarus: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 Icarus
.PHONY : Icarus
And here is the first section it points to in makefile2
CMakeFiles/Icarus.dir/all:
$(MAKE) -f CMakeFiles/Icarus.dir/build.make CMakeFiles/Icarus.dir/depend
$(MAKE) -f CMakeFiles/Icarus.dir/build.make CMakeFiles/Icarus.dir/build
$(CMAKE_COMMAND) -E cmake_progress_report D:/Projects/SVN/Icarus/build/CMakeFiles
#echo "Built target Icarus"
.PHONY : CMakeFiles/Icarus.dir/all
And finally here is the final section
# Build rule for subdir invocation for target.
CMakeFiles/Icarus.dir/rule: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start D:/Projects/SVN/Icarus/build/CMakeFiles 31
$(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/Icarus.dir/all
$(CMAKE_COMMAND) -E cmake_progress_start D:/Projects/SVN/Icarus/build/CMakeFiles 0
.PHONY : CMakeFiles/Icarus.dir/rule
hopefully this is enough information to fix the error.
Edit information from about the error
Running command: c:/MinGW/bin/make.exe -f "D:/Projects/SVN/Icarus/build/Makefile" VERBOSE=1 Icarus
"c:/Program Files (x86)/CMake/bin/cmake.exe" -HD:/Projects/SVN/Icarus -BD:/Projects/SVN/Icarus/build --check-build-system CMakeFiles/Makefile.cmake 0
c:/MinGW/bin/make.exe -f CMakeFiles/Makefile2 Icarus
make.exe[1]: Entering directory 'D:/Projects/SVN/Icarus/build'
"c:/Program Files (x86)/CMake/bin/cmake.exe" -HD:/Projects/SVN/Icarus -BD:/Projects/SVN/Icarus/build --check-build-system CMakeFiles/Makefile.cmake 0
"c:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_start D:/Projects/SVN/Icarus/build/CMakeFiles 31
c:/MinGW/bin/make.exe -f CMakeFiles/Makefile2 CMakeFiles/Icarus.dir/all
make.exe[2]: Entering directory 'D:/Projects/SVN/Icarus/build'
c:/MinGW/bin/make.exe -f CMakeFiles/Icarus.dir/build.make CMakeFiles/Icarus.dir/depend
make.exe[3]: Entering directory 'D:/Projects/SVN/Icarus/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" D:\Projects\SVN\Icarus D:\Projects\SVN\Icarus D:\Projects\SVN\Icarus\build D:\Projects\SVN\Icarus\build D:\Projects\SVN\Icarus\build\CMakeFiles\Icarus.dir\DependInfo.cmake --color=
make.exe[3]: Leaving directory 'D:/Projects/SVN/Icarus/build'

Related

'ld' Error while compiling a module (Ubuntu 22.04)

I am trying to compile a module https://github.com/In-line/grip
I have installed the below tools
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib
sudo apt-get install -y build-essential
sudo apt-get install -y libc6-dev libc6-dev-i386
sudo apt-get install -y cmake
I am getting the below error
root#test:/home/ubuntu/grip# make
/usr/bin/cmake -S/home/ubuntu/grip -B/home/ubuntu/grip --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/ubuntu/grip/CMakeFiles /home/ubuntu/grip//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/ubuntu/grip'
make -f rust/CMakeFiles/grip-rust_target.dir/build.make rust/CMakeFiles/grip-rust_target.dir/depend
make[2]: Entering directory '/home/ubuntu/grip'
cd /home/ubuntu/grip && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/ubuntu/grip /home/ubuntu/grip/rust /home/ubuntu/grip /home/ubuntu/grip/rust /home/ubuntu/grip/rust/CMakeFiles/grip-rust_target.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/ubuntu/grip'
make -f rust/CMakeFiles/grip-rust_target.dir/build.make rust/CMakeFiles/grip-rust_target.dir/build
make[2]: Entering directory '/home/ubuntu/grip'
make[2]: Nothing to be done for 'rust/CMakeFiles/grip-rust_target.dir/build'.
make[2]: Leaving directory '/home/ubuntu/grip'
[ 25%] Built target grip-rust_target
make -f CMakeFiles/grip.dir/build.make CMakeFiles/grip.dir/depend
make[2]: Entering directory '/home/ubuntu/grip'
cd /home/ubuntu/grip && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/ubuntu/grip /home/ubuntu/grip /home/ubuntu/grip /home/ubuntu/grip /home/ubuntu/grip/CMakeFiles/grip.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/ubuntu/grip'
make -f CMakeFiles/grip.dir/build.make CMakeFiles/grip.dir/build
make[2]: Entering directory '/home/ubuntu/grip'
[ 50%] Linking CXX shared library grip_amxx_i386.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/grip.dir/link.txt --verbose=1
/usr/bin/c++ -fPIC -Wall -Wextra -Wzero-as-null-pointer-constant -Wunknown-pragmas -m32 -O3 -mtune=generic -fvisibility=hidden -flto -fPIC -static-libgcc -static-libstdc++ -Wl,--gc-sections -Wl,--version-script=/home/ubuntu/grip/version_script.lds -fuse-ld=lld -shared -Wl,-soname,grip_amxx_i386.so -o grip_amxx_i386.so CMakeFiles/grip.dir/cpp/main.cpp.o CMakeFiles/grip.dir/third_party/amxmodx/public/sdk/amxxmodule.cpp.o rust/i686-unknown-linux-gnu/debug/libgrip_rust.a -lpthread
collect2: fatal error: cannot find ‘ld’
compilation terminated.
make[2]: *** [CMakeFiles/grip.dir/build.make:117: grip_amxx_i386.so] Error 1
make[2]: Leaving directory '/home/ubuntu/grip'
make[1]: *** [CMakeFiles/Makefile2:103: CMakeFiles/grip.dir/all] Error 2
make[1]: Leaving directory '/home/ubuntu/grip'
make: *** [Makefile:94: all] Error 2
root#test:/home/ubuntu/grip#
which ld output
root#test:/home/ubuntu/grip# which ld
/usr/bin/ld
echo $PATH output
/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin
Can someone please help to solve this. I tried searching the web but couldn't get anything relevant.
One of my friend suggested to do
apt install lld
and the issue got resolved.

How to link with binary using mingw32 in wine

I have made this minimal project to reproduce my link problem using mingw32 in wine32:
CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project("tst" VERSION 1.1.0)
add_executable("tst" "main.cpp")
add_library("resource" "text.o")
set_target_properties("resource" PROPERTIES LINKER_LANGUAGE CXX)
add_custom_command(OUTPUT "text.o"
MAIN_DEPENDENCY "text"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/text" "text"
COMMAND ${CMAKE_LINKER} -r -b binary "text" -o "text.o"
)
set_source_files_properties("text" PROPERTIES GENERATED true EXTERNAL_OBJECT true)
target_link_libraries("tst" "resource")
main.cpp
#include <iostream>
#include <string>
extern char _binary_text_start[];
extern char _binary_text_end[];
int main()
{
std::string text{ _binary_text_start, _binary_text_end };
std::cout << text << std::endl;
}
text
Hello, World!
This project builds and runs using mingw-w64 on Linux; however, when I try to build the project in wine32, I got this output:
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -SZ:\var\cache\deploy\cpp -BZ:\var\cache\deploy\cpp\build\windows --check-build-system CMakeFiles\Makefile.cmake 0
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -E cmake_progress_start Z:\var\cache\deploy\cpp\build\windows\CMakeFiles Z:\var\cache\deploy\cpp\build\windows\\CMakeFiles\progress.marks
mingw32-make -f CMakeFiles\Makefile2 all
mingw32-make[1]: Entering directory `Z:/var/cache/deploy/cpp/build/windows'
mingw32-make -f CMakeFiles\resource.dir\build.make CMakeFiles/resource.dir/depend
mingw32-make[2]: Entering directory `Z:/var/cache/deploy/cpp/build/windows'
[ 25%] Generating text.o
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -E copy Z:/var/cache/deploy/cpp/text text
Z:\mingw32\bin\ld.exe -r -b binary text -o text.o
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -E cmake_depends "MinGW Makefiles" Z:\var\cache\deploy\cpp Z:\var\cache\deploy\cpp Z:\var\cache\deploy\cpp\build\windows Z:\var\cache\deploy\cpp\build\windows Z:\var\cache\deploy\cpp\build\windows\CMakeFiles\resource.dir\DependInfo.cmake --color=
mingw32-make[2]: Leaving directory `Z:/var/cache/deploy/cpp/build/windows'
mingw32-make -f CMakeFiles\resource.dir\build.make CMakeFiles/resource.dir/build
mingw32-make[2]: Entering directory `Z:/var/cache/deploy/cpp/build/windows'
[ 50%] Linking CXX static library libresource.a
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -P CMakeFiles\resource.dir\cmake_clean_target.cmake
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -E cmake_link_script CMakeFiles\resource.dir\link.txt --verbose=1
Z:\mingw32\bin\ar.exe qc libresource.a text.o
Z:\mingw32\bin\ranlib.exe libresource.a
mingw32-make[2]: Leaving directory `Z:/var/cache/deploy/cpp/build/windows'
[ 50%] Built target resource
mingw32-make -f CMakeFiles\tst.dir\build.make CMakeFiles/tst.dir/depend
mingw32-make[2]: Entering directory `Z:/var/cache/deploy/cpp/build/windows'
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -E cmake_depends "MinGW Makefiles" Z:\var\cache\deploy\cpp Z:\var\cache\deploy\cpp Z:\var\cache\deploy\cpp\build\windows Z:\var\cache\deploy\cpp\build\windows Z:\var\cache\deploy\cpp\build\windows\CMakeFiles\tst.dir\DependInfo.cmake --color=
mingw32-make[2]: Leaving directory `Z:/var/cache/deploy/cpp/build/windows'
mingw32-make -f CMakeFiles\tst.dir\build.make CMakeFiles/tst.dir/build
mingw32-make[2]: Entering directory `Z:/var/cache/deploy/cpp/build/windows'
[ 75%] Building CXX object CMakeFiles/tst.dir/main.cpp.obj
Z:\mingw32\bin\g++.exe -O3 -DNDEBUG -o CMakeFiles\tst.dir\main.cpp.obj -c Z:\var\cache\deploy\cpp\main.cpp
[100%] Linking CXX executable tst.exe
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -E cmake_link_script CMakeFiles\tst.dir\link.txt --verbose=1
Z:\cmake-3.19.1-win32-x86\bin\cmake.exe -E rm -f CMakeFiles\tst.dir/objects.a
Z:\mingw32\bin\ar.exe cr CMakeFiles\tst.dir/objects.a #CMakeFiles\tst.dir\objects1.rsp
Z:\mingw32\bin\g++.exe -O3 -DNDEBUG -Wl,--whole-archive CMakeFiles\tst.dir/objects.a -Wl,--no-whole-archive -o tst.exe -Wl,--out-implib,libtst.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\tst.dir\linklibs.rsp
z:/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles\tst.dir/objects.a(main.cpp.obj):main.cpp:(.text.startup+0x43): undefined reference to `_binary_text_end'
z:/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles\tst.dir/objects.a(main.cpp.obj):main.cpp:(.text.startup+0x48): undefined reference to `_binary_text_start'
z:/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles\tst.dir/objects.a(main.cpp.obj):main.cpp:(.text.startup+0x68): undefined reference to `_binary_text_start'
z:/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles\tst.dir/objects.a(main.cpp.obj):main.cpp:(.text.startup+0x16f): undefined reference to `_binary_text_start'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [tst.exe] Error 1
mingw32-make[2]: Leaving directory `Z:/var/cache/deploy/cpp/build/windows'
mingw32-make[1]: *** [CMakeFiles/tst.dir/all] Error 2
mingw32-make[1]: Leaving directory `Z:/var/cache/deploy/cpp/build/windows'
mingw32-make: *** [all] Error 2
nm libresource.a
text.o:
0000000d D _binary_text_end
0000000d A _binary_text_size
00000000 D _binary_text_start
objdump -f libresource.a
In archive libresource.a:
text.o: file format pe-i386
architecture: i386, flags 0x00000038:
HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x00000000
cmake: https://github.com/Kitware/CMake/releases/download/v3.19.1/cmake-3.19.1-win32-x86.zip
mingw: https://pilotfiber.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/ray_linn/GCC-10.x-with-ada/mingw32-10.2.0-crt-8.0.0-with-ada.7z
mingw-make: https://phoenixnap.dl.sourceforge.net/project/mingw/MinGW/Extension/make/mingw32-make-3.80-3/mingw32-make-3.80.0-3.tar.gz

How do I debug missing headers in CMake project?

What would be the general algorithm I should follow to debug issues such as this one?
23:28:12: Running steps for project jumper-qt...
23:28:12: Starting: "/usr/bin/cmake" --build . --target all
/usr/bin/cmake -S/home/skrat/Workspace/jumper-qt -B/home/skrat/Workspace/jumper-qt/build/Debug --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/skrat/Workspace/jumper-qt/build/Debug/CMakeFiles /home/skrat/Workspace/jumper-qt/build/Debug/CMakeFiles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/skrat/Workspace/jumper-qt/build/Debug'
/usr/bin/make -f src/CMakeFiles/jumper-qt_autogen.dir/build.make src/CMakeFiles/jumper-qt_autogen.dir/depend
make[2]: Entering directory '/home/skrat/Workspace/jumper-qt/build/Debug'
cd /home/skrat/Workspace/jumper-qt/build/Debug && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/skrat/Workspace/jumper-qt /home/skrat/Workspace/jumper-qt/src /home/skrat/Workspace/jumper-qt/build/Debug /home/skrat/Workspace/jumper-qt/build/Debug/src /home/skrat/Workspace/jumper-qt/build/Debug/src/CMakeFiles/jumper-qt_autogen.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/skrat/Workspace/jumper-qt/build/Debug'
/usr/bin/make -f src/CMakeFiles/jumper-qt_autogen.dir/build.make src/CMakeFiles/jumper-qt_autogen.dir/build
make[2]: Entering directory '/home/skrat/Workspace/jumper-qt/build/Debug'
[ 14%] Automatic MOC and UIC for target jumper-qt
cd /home/skrat/Workspace/jumper-qt/build/Debug/src && /usr/bin/cmake -E cmake_autogen /home/skrat/Workspace/jumper-qt/build/Debug/src/CMakeFiles/jumper-qt_autogen.dir/AutogenInfo.json Debug
make[2]: Leaving directory '/home/skrat/Workspace/jumper-qt/build/Debug'
[ 14%] Built target jumper-qt_autogen
/usr/bin/make -f src/CMakeFiles/jumper-qt.dir/build.make src/CMakeFiles/jumper-qt.dir/depend
make[2]: Entering directory '/home/skrat/Workspace/jumper-qt/build/Debug'
cd /home/skrat/Workspace/jumper-qt/build/Debug && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/skrat/Workspace/jumper-qt /home/skrat/Workspace/jumper-qt/src /home/skrat/Workspace/jumper-qt/build/Debug /home/skrat/Workspace/jumper-qt/build/Debug/src /home/skrat/Workspace/jumper-qt/build/Debug/src/CMakeFiles/jumper-qt.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/skrat/Workspace/jumper-qt/build/Debug'
/usr/bin/make -f src/CMakeFiles/jumper-qt.dir/build.make src/CMakeFiles/jumper-qt.dir/build
make[2]: Entering directory '/home/skrat/Workspace/jumper-qt/build/Debug'
[ 28%] Building CXX object src/CMakeFiles/jumper-qt.dir/magnum_item.cpp.o
cd /home/skrat/Workspace/jumper-qt/build/Debug/src && /usr/bin/g++ -DCORRADE_IS_DEBUG_BUILD -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_QMLMODELS_LIB -DQT_QML_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -I/home/skrat/Workspace/jumper-qt/build/Debug/src -I/home/skrat/Workspace/jumper-qt/src -I/home/skrat/Workspace/jumper-qt/build/Debug/src/jumper-qt_autogen/include -isystem /usr/include/MagnumExternal/OpenGL -isystem /usr/include/qt -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -isystem /usr/include/qt/QtQuick -isystem /usr/include/qt/QtQmlModels -isystem /usr/include/qt/QtQml -isystem /usr/include/qt/QtNetwork -isystem /usr/include/qt/QtGui -DQT_QML_DEBUG -g -DQT_QML_DEBUG -Wall -Wextra -Wold-style-cast -Winit-self -Werror=return-type -Wmissing-declarations -Wpedantic -fvisibility=hidden -fvisibility-inlines-hidden -Wzero-as-null-pointer-constant -Wdouble-promotion -fPIC -std=gnu++14 -o CMakeFiles/jumper-qt.dir/magnum_item.cpp.o -c /home/skrat/Workspace/jumper-qt/src/magnum_item.cpp
In file included from /home/skrat/Workspace/jumper-qt/src/magnum_item.cpp:4:
/usr/include/Magnum/GL/Renderer.h: In static member function ‘static void Magnum::GL::Renderer::flush()’:
/usr/include/Magnum/GL/Renderer.h:1838:31: error: ‘glFlush’ was not declared in this scope; did you mean ‘flush’?
1838 | static void flush() { glFlush(); }
| ^~~~~~~
| flush
/usr/include/Magnum/GL/Renderer.h: In static member function ‘static void Magnum::GL::Renderer::finish()’:
/usr/include/Magnum/GL/Renderer.h:1846:32: error: ‘glFinish’ was not declared in this scope; did you mean ‘finish’?
1846 | static void finish() { glFinish(); }
| ^~~~~~~~
| finish
In file included from /home/skrat/Workspace/jumper-qt/src/magnum_item.cpp:4:
/usr/include/Magnum/GL/Renderer.h: In static member function ‘static Magnum::GL::Renderer::Error Magnum::GL::Renderer::error()’:
/usr/include/Magnum/GL/Renderer.h:2053:58: error: ‘glGetError’ was not declared in this scope
2053 | static Error error() { return static_cast<Error>(glGetError()); }
| ^~~~~~~~~~
make[2]: *** [src/CMakeFiles/jumper-qt.dir/build.make:122: src/CMakeFiles/jumper-qt.dir/magnum_item.cpp.o] Error 1
make[2]: Leaving directory '/home/skrat/Workspace/jumper-qt/build/Debug'
make[1]: Leaving directory '/home/skrat/Workspace/jumper-qt/build/Debug'
make[1]: *** [CMakeFiles/Makefile2:118: src/CMakeFiles/jumper-qt.dir/all] Error 2
make: *** [Makefile:107: all] Error 2
23:28:15: The process "/usr/bin/cmake" exited with code 2.
Error while building/deploying project jumper-qt (kit: Desktop)
When executing step "CMake Build"
23:28:15: Elapsed time: 00:04.
The example project use both Qt (Quick 2) and Magnum, both of these libraries make extensive use of OpenGL. When I start example projects for them separately, they both work well and build with no error. When I try to marry them, it falls a part.
So what would be a procedure to follow in this case? How do I find out out why these (glFlush) declarations are missing? I tried adding find_package(OpenGL.... to my project, with no success. I'm interested in the process of finding out what's the problem, not in a solution to this particular problem.
Thank you SO
UPDATE: CMake files here https://gist.github.com/skrat/c5b20d6753e6476a4a0d60227cb73cda
Before including Magnum, I had the same project, where I included find_package(OpenGL... and was able to use raw OpenGL calls successfully. In a separate Magnum only project, I don't have to find package OpenGL and all is fine, I assume Magnum's CMake files do the hard work.
Also this might be relevant https://github.com/mosra/magnum-bootstrap/blob/base-qt/modules/FindMagnum.cmake

CMake C++ compile command

I'm currently learning CMake, which I understand to be a build file generator, and I wanted to see the exact command that CMake was running to compile and link my C++ files. For example, if I'm working with a single file main.cpp and I were to compile it with gcc, I would run gcc -o main main.cpp. How would I see the C++ command that CMake is running? I tried make VERBOSE=1 but that only reveals CMake-related commands instead of C++ compiler commands.
// main.cpp
#include <iostream>
int main()
{
std::cout << "Hello world" << std::endl;
}
//CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
project(example LANGUAGES CXX)
add_executable(main main.cpp)
This creates a Makefile with the following contents:
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.14
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.14.5/bin/cmake
# The command to remove a file.
RM = /usr/local/Cellar/cmake/3.14.5/bin/cmake -E remove -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /Users/.../Desktop/cpp
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /Users/.../Desktop/cpp/build
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target rebuild_cache
rebuild_cache:
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/local/Cellar/cmake/3.14.5/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# Special rule for the target edit_cache
edit_cache:
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
/usr/local/Cellar/cmake/3.14.5/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /Users/.../Desktop/cpp/build/CMakeFiles /Users/.../Desktop/cpp/build/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /Users/.../Desktop/cpp/build/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named main
# Build rule for target.
main: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 main
.PHONY : main
# fast build rule for target.
main/fast:
$(MAKE) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/build
.PHONY : main/fast
main.o: main.cpp.o
.PHONY : main.o
# target to build an object file
main.cpp.o:
$(MAKE) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/main.cpp.o
.PHONY : main.cpp.o
main.i: main.cpp.i
.PHONY : main.i
# target to preprocess a source file
main.cpp.i:
$(MAKE) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/main.cpp.i
.PHONY : main.cpp.i
main.s: main.cpp.s
.PHONY : main.s
# target to generate assembly for a file
main.cpp.s:
$(MAKE) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/main.cpp.s
.PHONY : main.cpp.s
# Help Target
help:
#echo "The following are some of the valid targets for this Makefile:"
#echo "... all (the default if no target is provided)"
#echo "... clean"
#echo "... depend"
#echo "... rebuild_cache"
#echo "... edit_cache"
#echo "... main"
#echo "... main.o"
#echo "... main.i"
#echo "... main.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
make VERBOSE=1 returns:
/usr/local/Cellar/cmake/3.14.5/bin/cmake -S/Users/.../Desktop/cpp -B/Users/.../Desktop/cpp/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.14.5/bin/cmake -E cmake_progress_start /Users/.../Desktop/cpp/build/CMakeFiles /Users/.../Desktop/cpp/build/CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/depend
cd /Users/.../Desktop/cpp/build && /usr/local/Cellar/cmake/3.14.5/bin/cmake -E cmake_depends "Unix Makefiles" /Users/.../Desktop/cpp /Users/.../Desktop/cpp /Users/.../Desktop/cpp/build /Users/.../Desktop/cpp/build /Users/.../Desktop/cpp/build/CMakeFiles/main.dir/DependInfo.cmake --color=
Dependee "/Users/.../Desktop/cpp/build/CMakeFiles/main.dir/DependInfo.cmake" is newer than depender "/Users/.../Desktop/cpp/build/CMakeFiles/main.dir/depend.internal".
Dependee "/Users/.../Desktop/cpp/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/Users/.../Desktop/cpp/build/CMakeFiles/main.dir/depend.internal".
Scanning dependencies of target main
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/build
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -o CMakeFiles/main.dir/main.cpp.o -c /Users/.../Desktop/cpp/main.cpp
[100%] Linking CXX executable main
/usr/local/Cellar/cmake/3.14.5/bin/cmake -E cmake_link_script CMakeFiles/main.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/main.dir/main.cpp.o -o main
[100%] Built target main
/usr/local/Cellar/cmake/3.14.5/bin/cmake -E cmake_progress_start /Users/.../Desktop/cpp/build/CMakeFiles 0

Why does cmake not add a library link command in the makefile?

I Ubuntu, I am learning about cmake and make, and just trying a simple example. I have two directories: src and build. In src, I have two files: main.cpp, with just a simple hello world example, and CMakeLists.txt, with the following text:
add_executable(test main.cpp)
target_link_libraries(test blas)
Here, blas is just some arbitrary library that I've found at /usr/lib/libblas.so. My main.cpp file does not actually use it, but I am just testing things out...
Now, if I enter the build directory, and run cmake ../src, then a makefile is generated in build. The contents of that makefile is pasted below.
What I am puzzled about, is why there is no mention of the blas library at all? Shouldn't cmake be adding a line such as -lblas?
Thanks :)
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E remove -f
# Escaping for special characters.
EQUALS = =
# The program to use to edit the cache.
CMAKE_EDIT_COMMAND = /usr/bin/cmake-gui
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/ejohns/Projects/Test2/src
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/ejohns/Projects/Test2/build
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target edit_cache
edit_cache:
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
/usr/bin/cmake-gui -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target rebuild_cache
rebuild_cache:
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/ejohns/Projects/Test2/build/CMakeFiles /home/ejohns/Projects/Test2/build/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /home/ejohns/Projects/Test2/build/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named test
# Build rule for target.
test: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 test
.PHONY : test
# fast build rule for target.
test/fast:
$(MAKE) -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
.PHONY : test/fast
main.o: main.cpp.o
.PHONY : main.o
# target to build an object file
main.cpp.o:
$(MAKE) -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/main.cpp.o
.PHONY : main.cpp.o
main.i: main.cpp.i
.PHONY : main.i
# target to preprocess a source file
main.cpp.i:
$(MAKE) -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/main.cpp.i
.PHONY : main.cpp.i
main.s: main.cpp.s
.PHONY : main.s
# target to generate assembly for a file
main.cpp.s:
$(MAKE) -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/main.cpp.s
.PHONY : main.cpp.s
# Help Target
help:
#echo "The following are some of the valid targets for this Makefile:"
#echo "... all (the default if no target is provided)"
#echo "... clean"
#echo "... depend"
#echo "... edit_cache"
#echo "... rebuild_cache"
#echo "... test"
#echo "... main.o"
#echo "... main.i"
#echo "... main.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
CMake uses a 3-level hierarchy of makefiles. The line you're looking for will be either in CMakeFiles/Makefile2 or in build.make somewhere under CMakeFiles (and probably a test directoty as well).