简体   繁体   中英

why i have some missing files when cmake generate build folder ? (Maya 2020 - CMake 3.16.4 - VS 2017)

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

丢失文件

FYI : i use Cmake 3.16.4 and visual studio 2017

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()

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM