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

两盒软妹~` 提交于 2020-03-25 18:38:58

问题


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


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



回答2:


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


来源:https://stackoverflow.com/questions/60721235/why-i-have-some-missing-files-when-cmake-generate-build-folder-maya-2020-cm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!