d-mac
d-mac

Reputation: 122

make: No targets provided near line 28 (CMake)

I am having newbie problems with CMake. The error I get is make: No targets provided near line 28

My setup is as follows:

The steps I have followed are listed on CMake Tutorial | CMake in the first section A Basic Starting Point (Step1).

Quoting from the website...

The most basic project is an executable built from source code files. For simple projects a two line CMakeLists.txt file is all that is required. This will be the starting point for our tutorial. The CMakeLists.txt file looks like:


    cmake_minimum_required (VERSION 2.6)
    project (Tutorial)
    add_executable(Tutorial tutorial.cxx)

Note that this example uses lower case commands in the CMakeLists.txt file. Upper, lower, and mixed case commands are supported by CMake. The source code for tutorial.cxx will compute the square root of a number and the first version of it is very simple, as follows:


    // A simple program that computes the square root of a number
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    int main (int argc, char *argv[])
    {
        if (argc < 2)
        {
            fprintf(stdout,"Usage: %s number\n",argv[0]);
            return 1;
        }
        double inputValue = atof(argv[1]);
        double outputValue = sqrt(inputValue);
        fprintf(stdout,"The square root of %g is %g\n",
              inputValue, outputValue);
        return 0;
    }

Commands


    c:\HW>cd c:\hw\tutorial

    c:\HW\tutorial>cd build

    c:\HW\tutorial\build>cmake ../src
    -- Building for: NMake Makefiles
    -- The C compiler identification is MSVC 19.0.23026.0
    -- The CXX compiler identification is MSVC 19.0.23026.0
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
    14.0/VC/bin/cl.exe
    -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
    14.0/VC/bin/cl.exe -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
    o 14.0/VC/bin/cl.exe
    -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
    o 14.0/VC/bin/cl.exe -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/HW/tutorial/build

    c:\HW\tutorial\build>make
    make: No targets provided near line 28

Lines 26 to 31 of Makefile, line 28 emphasized:


    !IF "$(OS)" == "Windows_NT"
    NULL=
    !ELSE
    NULL=nul
    !ENDIF
    SHELL = cmd.exe

(Incidentally when I ran GNU make (just to see what would happen) I got
makefile:28: *** missing separator. Stop.)

Upvotes: 1

Views: 283

Answers (1)

You're using CMake's generator NMake Makefiles, which generates a buildsystem for nmake. So run nmake instead of make to do the build.

Upvotes: 1

Related Questions