Win11 Home (x86-64)
cygwin 3.7.0
/usr/bin/cmake 4.2.1I am totally confused. I am going through the tutorial and at the end of Step 1 Exercise 2 I have created a CMakeLists.txt file which generates a working Makefile but for which
> cmake --build buildgenerates an error saying there is no rule for making the MathFunctions target. In looking at the TODO expansions it looks like they are the same as in my CMakeLists.txt file. Any idea what I’ve done wrong?
Another issue is the statement that I have to include #include <MathFunctions.h>. I have tried all of the following followed by > make:
- Failure:
#include <MathFunctions.h> - Success:
#include "MathFunctions/MathFunctions.h" - Success:
no include statement?
I guess I can understand 1 & 2. I did something wrong. But 3?
shell > clear;rm -rf build/*;cmake -B build;cmake --build build
Diagnostic message
gmake[2]: *** No rule to make target '/d/home/skidmarks/Projects/Test/cmake/src/MathFunctions/MathFunctions.cpp', needed by 'CMakeFiles/MathFunctions.dir/MathFunctions/MathFunctions.cpp.o'. Stop.
gmake[1]: *** [CMakeFiles/Makefile2:122: CMakeFiles/MathFunctions.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
File CMakeLists.txt
# TODO1: Set the minimum required version of CMake to be 3.23
cmake_minimum_required(VERSION 3.23)
# TODO2: Create a project named Tutorial
project(Tutorial)
# TODO3: Add an executable target called Tutorial to the project
add_executable(Tutorial)
# TODO4: Add the Tutorial/Tutorial.cxx source file to the Tutorial target
target_sources(Tutorial PRIVATE Tutorial.cpp)
# TODO7: Add the MathFunctions library as a linked dependency
# to the Tutorial target
target_link_libraries(Tutorial PRIVATE MathFunctions)
# TODO11: Add the Tutorial subdirectory to the project
# TODO5: Add a library target called MathFunctions to the project
add_library(MathFunctions)
# TODO6: Add the source and header file located in Step1/MathFunctions to the
# MathFunctions target, note that the intended way to include the
# MathFunctions header is:
#
#include <MathFunctions.h>
target_sources(MathFunctions
PRIVATE MathFunctions/MathFunctions.cpp
PUBLIC
FILE_SET mathheaders
TYPE HEADERS
BASE_DIRS MathFunctions
FILES MathFunctions/MathFunctions.h
)
# TODO13: Add the MathFunctions subdirectory to the project