No problem

I add some other info I hope it helps


- you don't need to set DEVKIT_LOCATION when you defined them in your env
vars or batch file

- this is wrong: set(ENV{DEVKIT_LOCATION}
"${CMAKE_SOURCE_DIR}/external/devkitBase")
- ENV will be used when you defined your env var outside of the
CMakeLists.txt so in this case you just need to use it like: $ENV{
DEVKIT_LOCATION}

- for Qt dependencies I told you you should use
find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL REQUIRED)
target_link_libraries($ENV{TARGET_NAME} Qt5::Core Qt5::Widgets Qt5::Gui
Qt5::OpenGL)

- you don't need to add  CMAKE_MODULE_PATH  to your CMakeLists.txt file
however, (I forgot to mention) you should define this env var
set Qt5_DIR=%SDKS_LOCATION%/Qt5/lib/cmake
in your windows env var or your build.bat file

- if you want to have multithreaded things, instead of
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")

you can use this
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")

this is my DEVKIT_OCATION
in batch file:
set SDKS_LOCATION=D:/myPath/sdks
set DEVKIT_LOCATION=%SDKS_LOCATION%/Maya_2019
in CMakeListx.txt file:
include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
- at the end, you don't need to set things like:
CMAKE_MODULE_PATH
MAYA_INCLUDE_DIR
MAYA_LIBRARIES

all of these settings will be managed automatically

you just need to have a cleaner CMakeLists.txt file and do things based on
this order:
1. in *build.bat: * call the vcvarsall.bat
@REM  VCVARS_LOCATION: C:\Program Files\Microsoft Visual
Studio\2022\Community\VC\Auxiliary\Build
call "%VCVARS_LOCATION%/vcvarsall.bat" x64
2. in *build.bat: *Set your env Variables like :QT_DIR, DEVKIT_LOCATION, ...

3. in *build.bat: *call the cmake command from inside build directory
cd build
cmake -G "Visual Studio 17 2022" -A x64 ..
4. in *CMakeLists.txt*: active the maya module finder:
include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)

5. in *CMakeLists.txt*: turn on Automatic builder of QT
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

6. in *CMakeLists.txt: *Set your Project files and your libraries, or maya
libraries like *OpenMaya*, *Foundation*

7. in *CMakeLists.txt: *call this function of maya cmake module:
build_plugin()
8. in *CMakeLists.txt: *adding Qt related dependencies:
find_package(Qt5 COMPONENTS Core Widgets Gui REQUIRED)
target_link_libraries($ENV{TARGET_NAME} Qt5::Core Qt5::Widgets Qt5::Gui)
I hope it is detailed enough
this is the way I usually work, there are lots of ways to build softwares,
all experimental and true, just need to follow errors! let us know if you
need more data
cheers


On Wed, Nov 8, 2023 at 6:44 PM Andrew Golubev <golube...@gmail.com> wrote:

> Hey Reza!
> Thank you so much for your answer, I really appreciate it!
>
> So I tried to do as you said and rework a little my cmake files build. I
> added pluginEntry.cmake
> It seems like OpenGL is there (I haven't tested it yet in VisualStudio, by
> I can see in terminal that there was an ouput that OpenGl was found (I also
> looked a little into pluginEntry.cmake and there find_opengl part).
>
> Can I ask you, how are you adding Qt dependencies to your project in CMake?
> previously I was able to make it work, but my approach was a bit messy,
> basically almost half was done manually in Visual Studio. I understand that
> it is incorrect and there is shoud be CMake way to do that.
>
> I tried several things, for example in devkit there cmake folder with all
> additional Qt folders which have Qt cmake files.
> My initial thought was that I just need to include those cmake's into my
> build and after that linking will work as expected. I even wrote a tiny
> cmake script which adds each qt folder as module folder into my CMake build
> but it does not helped. I have this error, in which it seems that Qt
> dependencied are not there:
>
> """
> CMake Error at src/CMakeLists.txt:30 (find_package):
>   By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
>   asked CMake to find a package configuration file provided by "Qt5", but
>   CMake did not find one.
>
>   Could not find a package configuration file provided by "Qt5" with any of
>   the following names:
>
>     Qt5Config.cmake
>     qt5-config.cmake
>
>   Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set
> "Qt5_DIR"
>   to a directory containing one of the above files.  If "Qt5" provides a
>   separate development package or SDK, be sure it has been installed.
>
>
> -- Configuring incomplete, errors occurred!"""
>
> I also tried to use FindMaya_Qt.cmake (this file I found in AutodeskUSD
> repository, it also does not working, but gives me slightly different error.
>
>
>
>
>
> A little information about my project.
>
> I launched it just as you said:
> cmake -G "Visual Studio 16 2019" -A x64 -DMAYA_VERSION=2023
> ../CMakeLists.txt
>
>
> The repository structure looks like that:
>
> root
>  |-build
>  |-modules
>  |    |_FindMaya.cmake
>  |   |_FindMaya_Qt.cmake
>  |
>  |-src
>  |    |_CMakeLists.txt
>  |
>  |-external
>  |     |_devkitBase
>  |
>  |_CMakeLists.txt
>
>
> root CMakeLists.txt:
> # go to build folder and launch this command in terminal:
> # cmake -G "Visual Studio 16 2019" -A x64 -DMAYA_VERSION=2023
> ../CMakeLists.txt
>
> cmake_minimum_required(VERSION 3.12)
>
> project(maya_viewport_collisions_plugin)
>
> set(EXTERNAL_DIR "${CMAKE_SOURCE_DIR}/external")
> set(DEVKIT_LOCATION "${CMAKE_SOURCE_DIR}/external/devkitBase")
> set(ENV{DEVKIT_LOCATION} "${CMAKE_SOURCE_DIR}/external/devkitBase")
>
> list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/modules")
> list(APPEND CMAKE_MODULE_PATH "${DEVKIT_LOCATION}/cmake")
>
>
> # # Function to recursively add subdirectories
> # function(add_subdirectories_to_module_path base_dir)
> #     # Get all subdirectories
> #     file(GLOB children RELATIVE ${base_dir} ${base_dir}/*)
> #     foreach(child ${children})
> #         if(IS_DIRECTORY ${base_dir}/${child})
> #             list(APPEND CMAKE_MODULE_PATH "${base_dir}/${child}")
> #         endif()
> #     endforeach()
> #     # Set the CMAKE_MODULE_PATH variable to the updated list
> #     set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
> # endfunction()
>
> # # Call the function with the base directory path
> # add_subdirectories_to_module_path("${DEVKIT_LOCATION}/cmake")
>
>
> message(STATUS "===CMAKE_MODULE_PATH is: ${CMAKE_MODULE_PATH}")
>
> include(${DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
>
> add_subdirectory(src)
>
>
>
>
>
> src CMakeLists.txt:
> cmake_minimum_required(VERSION 3.12)
> project(MayaViewportCollisionsPlugin)
>
>
> set(BULLET_ROOT "${EXTERNAL_DIR}/bullet3")
> add_subdirectory("${BULLET_ROOT}" "${CMAKE_BINARY_DIR}/bullet3")
>
> link_directories("${EXTERNAL_DIR}/boost_1_83_0/libs")
>
> include(${DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
>
> set(CMAKE_AUTOMOC ON)
> set(CMAKE_AUTORCC ON)
> set(CMAKE_AUTOUIC ON)
>
> file(GLOB_RECURSE MY_SOURCES CONFIGURE_DEPENDS
> "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
> message("My sources: ${MY_SOURCES}")
>
> file(GLOB_RECURSE MY_HEADERS CONFIGURE_DEPENDS
> "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
> message("My headers: ${MY_HEADERS}")
>
> set(HEADER_FILES ${MY_HEADERS})
> set(SOURCE_FILES ${MY_SOURCES})
>
> list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") #
> Adjust the path to where FindMaya.cmake and FindMaya_Qt.cmake are located
> # include(FindMaya)
> # include(FindMaya_Qt)
>
> find_package(Maya REQUIRED)
> find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL REQUIRED)
>
> add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${HEADER_FILES})
>
> target_include_directories(${PROJECT_NAME}
>     PRIVATE
>         ${MAYA_INCLUDE_DIR}
>         "${EXTERNAL_DIR}/boost_1_83_0"
>         "${BULLET_ROOT}/src"
>     PUBLIC
>         "${CMAKE_CURRENT_BINARY_DIR}"
>         "${CMAKE_CURRENT_SOURCE_DIR}"
> )
>
> target_link_libraries(${PROJECT_NAME} PRIVATE
>     ${MAYA_LIBRARIES}
>     Qt5::Core
>     Qt5::Widgets
>     Qt5::Gui
>     Qt5::OpenGL
>     BulletDynamics
>     BulletCollision
>     LinearMath
>     )
>
> # Your custom MAYA_PLUGIN function/macro - make sure it is defined before
> this call
> MAYA_PLUGIN(${PROJECT_NAME})
>
> install(TARGETS ${PROJECT_NAME} ${MAYA_TARGET_TYPE} DESTINATION plug-ins/
> ${MAYA_VERSION})
>
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
> set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
>
>
>
> FindMaya.cmake I took version from Chad Vernon:
> https://github.com/chadmv/cgcmake/blob/master/modules/FindMaya.cmake
>
> FindMaya_Qt.cmake from AutodeskUSD repo:
>
> https://github.com/Autodesk/maya-usd/blob/dev/cmake/modules/FindMaya_Qt.cmake
> On Wednesday, 8 November 2023 at 00:42:01 UTC Reza Aarabi wrote:
>
>> Hello My Friend
>>
>> I don't know how did you manage your CMakeLists.txt file and your build
>> system, so it should be related to many things, from Visual Studio version,
>> to debug and release versions of your build ... but specifically about
>> building Qt5 related UIs with *.mll *plugins of maya ( I did it
>> experimentally years ago) and for finding Qt related cmake config, you
>> should be able to build your tool successfully if you have these:
>>
>> - In your CmakeLists.txt you should have these settings
>> include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
>> $ENV{DEVKIT_LOCATION}: is my Env Variable of the Maya SDKS root location
>> You should enable these settings for Qt:
>> set(CMAKE_AUTOMOC ON)
>> set(CMAKE_AUTORCC ON)
>> set(CMAKE_AUTOUIC ON)
>>
>> After adding your Source files and Maya Libraries
>> # set SOURCE_FILES
>> set(SOURCE_FILES
>>     myPlugin.cpp
>>     main.cpp
>> )
>>
>> # set linking libraries
>> set(LIBRARIES
>>      OpenMaya
>>      Foundation
>> )
>>
>> You should add codes like this:
>> # Build plugin
>> build_plugin() # this will be find in maya sdk cmake config file
>>
>> find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL REQUIRED)
>> target_link_libraries($ENV{TARGET_NAME} Qt5::Core Qt5::Widgets Qt5::Gui
>> Qt5::OpenGL)
>> $ENV{TARGET_NAME}: you can set TARGET_NAME or PROJECT_NAME as your
>> plugin name
>> - I recommend to build your project through cmake with:
>>
>> cd build
>> cmake -G "Visual Studio 17 2022" -A x64 ..
>>
>> - It seems you are using GL/gl.h that I'm not sure it is related to Maya
>> or QT, but for OpenGL try to add this line to your CMakeLists.txt too
>> find_package(OpenGL REQUIRED)
>> Then open .sln file inside Visual Studio and build it in Debug and
>> release mode and see the difference!
>> I hope it helps you, if you have more Questions, please provide more data
>> like your CMakeLists.txt or build.bat file We can help more
>>
>>
>>
>> On Tue, Nov 7, 2023 at 10:00 AM Andrew Golubev <golu...@gmail.com> wrote:
>>
>>> Yeah, I downloaded the devkit, extracted it and linked all included QT
>>> Libs.
>>> I will have a look with DependencyWalker; it may be more apparent with
>>> which exact dll is missing; thank you!
>>> It seems that overall, QT is working there, but when I override some
>>> OpenGL functions, I have this error.
>>> On Tuesday, 7 November 2023 at 15:22:02 UTC Marcus Ottosson wrote:
>>>
>>>> This rings a bell, but it's too late in the day to hear which one. Are
>>>> you linking with QtCore and relevant Qt binaries?
>>>>
>>>> There's this neat tool you can try, which lists relevant dependencies
>>>> of a binary, including a Maya .mll
>>>>
>>>> - https://dependencywalker.com/
>>>>
>>>> [image: Screenshot 2023-11-07 152019.jpg]
>>>>
>>>> On Tuesday, 7 November 2023 at 15:09:16 UTC golu...@gmail.com wrote:
>>>>
>>>>> Hey everyone!
>>>>> I hope you are all doing well)
>>>>>
>>>>> I wanted to ask a question about Maya C++ plugin building. I'm
>>>>> currently struggling with an issue I can't resolve for a couple of days.
>>>>>
>>>>> I created a custom context with manips, and it is working and building
>>>>> very well, but at some point, I needed to create a small QDialog with QT
>>>>> libraries, which uses OpenGL, and this is my main issue. I downloaded Maya
>>>>> Devkit, added a linker and include libs.
>>>>>
>>>>> I also tried to use FindMaya_Qt.cmake from the Autodesk USD
>>>>> repository. But I can't go over a linker error, which appears during
>>>>> compilation.It seems to me that some DLLs or libraries are missing, but I
>>>>> don't get which one. Maybe someone had a similar issue?
>>>>>
>>>>> I also tried to add opengl32.dll but it doesn't do nothing. It seems
>>>>> to me that something is wrong with my Qt config, or cpp class which uses
>>>>> OpenGL.
>>>>>
>>>>>
>>>>>
>>>>> Here is my errors from Visual studio:
>>>>> Severity Code Description Project File Line Suppression State Error
>>>>> LNK2019 unresolved external symbol __imp_glViewport referenced in 
>>>>> function "protected:
>>>>> virtual void __cdecl DebugRenderer::resizeGL(int,int)" (?
>>>>> resizeGL@DebugRenderer@@MEAAXHH@Z) maya_plugin C:
>>>>> \Users\golub\Documents\maya_plugin\build\src\debugDialog.obj 1 Error
>>>>> LNK2019 unresolved external symbol __imp_glBegin referenced in function 
>>>>> "protected:
>>>>> virtual void __cdecl DebugRenderer::paintGL(void)" (?
>>>>> paintGL@DebugRenderer@@MEAAXXZ) maya_plugin C:
>>>>> \Users\golub\Documents\maya_plugin\build\src\debugDialog.obj 1 Error
>>>>> LNK2019 unresolved external symbol __imp_glClear referenced in function 
>>>>> "protected:
>>>>> virtual void __cdecl DebugRenderer::paintGL(void)" (?
>>>>> paintGL@DebugRenderer@@MEAAXXZ) maya_plugin C:
>>>>> \Users\golub\Documents\maya_plugin\build\src\debugDialog.obj 1 Error
>>>>> LNK2019 unresolved external symbol __imp_glClearColor referenced in
>>>>> function "protected: virtual void __cdecl
>>>>> DebugRenderer::initializeGL(void)" (?initializeGL@DebugRenderer
>>>>> @@MEAAXXZ) maya_plugin C:
>>>>> \Users\golub\Documents\maya_plugin\build\src\debugDialog.obj 1 Error
>>>>> LNK2019 unresolved external symbol __imp_glColor3f referenced in function 
>>>>> "protected:
>>>>> virtual void __cdecl DebugRenderer::paintGL(void)" (?
>>>>> paintGL@DebugRenderer@@MEAAXXZ) maya_plugin C:
>>>>> \Users\golub\Documents\maya_plugin\build\src\debugDialog.obj 1 Error
>>>>> LNK2019 unresolved external symbol __imp_glEnd referenced in function 
>>>>> "protected:
>>>>> virtual void __cdecl DebugRenderer::paintGL(void)" (?
>>>>> paintGL@DebugRenderer@@MEAAXXZ) maya_plugin C:
>>>>> \Users\golub\Documents\maya_plugin\build\src\debugDialog.obj 1 Error
>>>>> LNK2019 unresolved external symbol __imp_glVertex3f referenced in 
>>>>> function "protected:
>>>>> virtual void __cdecl DebugRenderer::paintGL(void)" (?
>>>>> paintGL@DebugRenderer@@MEAAXXZ) maya_plugin C:
>>>>> \Users\golub\Documents\maya_plugin\build\src\debugDialog.obj 1
>>>>>
>>>>>
>>>>>
>>>>> And also, class which gives me an error:
>>>>> #pragma once #include <reactphysics3d/reactphysics3d.h> #include
>>>>> <maya/MQtUtil.h> #include <QtWidgets/qdialog.h> #include
>>>>> <QtWidgets/QVBoxLayout> #include <QtOpenGL/qglfunctions.h> #include
>>>>> <QtGui/QOpenGLFunctions> #include <QtWidgets/QOpenGLWidget> #include
>>>>> <GL/gl.h> #include <QtGui/qopenglext.h> class DebugRenderer : public
>>>>> QOpenGLWidget, protected QOpenGLFunctions { // Updated inheritance
>>>>> public: DebugRenderer(rp3d::PhysicsWorld* physicsWorld, QWidget*
>>>>> parent = nullptr); protected: void initializeGL() override; void
>>>>> resizeGL(int w, int h) override; void paintGL() override; private:
>>>>> rp3d::PhysicsWorld* physicsWorld; }; class DebugDialog : public
>>>>> QDialog { public: DebugDialog(rp3d::PhysicsWorld* physicsWorld,
>>>>> QWidget* parent = nullptr); };
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to python_inside_m...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/9e1a9f52-abaf-4f9d-86b1-e1ed43c7ac2fn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/9e1a9f52-abaf-4f9d-86b1-e1ed43c7ac2fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>>
>>
>> ---------------------
>> *--= Reza Aarabi =--*
>> *https://madoodia.com <https://madoodia.com>*
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/a790c293-b3a6-4cde-837a-9ff3da9ede9bn%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/a790c293-b3a6-4cde-837a-9ff3da9ede9bn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 


---------------------
*--= Reza Aarabi =--*
*https://madoodia.com <https://madoodia.com>*

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CADvbQw%2BEc2%3DezeVEuXjB1XrXD0_Q%2B8wTH8CbbMS%3Doh6bZicuEg%40mail.gmail.com.

Reply via email to