1

I exactly followed the instruction in API help to create visual studio project: The CMakeLists.txt File guide

but I got this error:

CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

by the way , this error didn't stop the process and CMake generate the build folder for me but as you can see it didn't create some files i think , there are no helloworld.vcxproj & helloworld.vcxproj.filters

Missing Files

FYI : i use Cmake 3.16.4 and visual studio 2017

Amin Khormaei
  • 379
  • 3
  • 8
  • 23
  • 1
    Please, show **complete** output of CMake. At the end of that output should be a line, which tells whether the configuration is completed or failed. – Tsyvarev Mar 17 '20 at 12:40

2 Answers2

1

The tutorial is incomplete, as it is missing the project() command. Your CMake project should always have at least one project() command, as it is used to initialize some pretty essential variables, and the language used in the CMake file, among other things. From the CMake documentation:

The top-level CMakeLists.txt file for a project must contain a literal, direct call to the project() command; loading one through the include() command is not sufficient. If no such call exists, CMake will issue a warning and pretend there is a project(Project) at the top to enable the default languages (C and CXX).

Using the set() command to initialize PROJECT_NAME is bad practice, as the project() call also does this for you. I would suggest modifying the CMake file to include the project() command instead:

cmake_minimum_required(VERSION 2.8)

include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)

# Set the project here.
project(exampleNode)

set(RESOURCES_FILES myResource.xpm)

set(MEL_FILES 
     exampleNode.mel)

set(SOURCE_FILES
     exampleNode.cpp
     ${MEL_FILES}
)

set(LIBRARIES
    OpenMaya Foundation
)

find_package(MtoA)
find_alembic()
build_plugin()
Kevin
  • 16,549
  • 8
  • 60
  • 74
  • 1
    @AminKhormaei You can try removing your build folder, and running CMake *from scratch*, which will guarantee that the old CMake cache is removed. – Kevin Mar 17 '20 at 14:50
  • I did that too , – Amin Khormaei Mar 17 '20 at 15:11
  • 1
    @AminKhormaei The message in your question post is not an error, it is a **warning**. It does not indicate whether or not CMake completely successfully, so as requested by Tsyvarev, please provide the **full** CMake output in your question post. It would also be helpful to provide the code in `pluginEntry.cmake` to better understand what might be going wrong. – Kevin Mar 17 '20 at 15:15
  • i added project() after minimum requirement and solved my problem – Amin Khormaei Mar 17 '20 at 15:47
0

this is the correct CMakeLists.txt :

cmake_minimum_required(VERSION 2.8)
project(test)

set(PROJECT_NAME test)


include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)



set(RESOURCES_FILES myResource.xpm)

set(MEL_FILES 
    test.mel)

set(SOURCE_FILES
        test.cpp
        ${MEL_FILES}
    )

set(LIBRARIES
    OpenMaya Foundation
    )

build_plugin()
Amin Khormaei
  • 379
  • 3
  • 8
  • 23
  • The syntax here is incorrect. Using `project()` without a project name will generate a CMake error. – Kevin Mar 17 '20 at 16:43