Hi,
I am falling in the same problem. For the first time I work with IDL files. I thoug C++ doesn't need IDL file compilation so I learned C++ and Qt framework in last 2 months to work with your API and it doesn't work. I prefer CMake but I tried both variants. Here are my examples of configs.
*.pro for qmake
- Code: Select all
QT -= gui
INCLUDEPATH += include
win32 {
MIDL_FILES = "include/BMDSwitcherAPI.idl"
MIDL.name = Compiling IDL
MIDL.input = MIDL_FILES
MIDL.output = ${QMAKE_FILE_BASE}.h
MIDL.variable_out = HEADERS
MIDL_CONFIG += no_link
contains(QMAKE_TARGET.arch, x86_64) {
MIDL.commands = midl.exe /env win64 /h ${QMAKE_FILE_BASE}.h /W1 /char signed /D "NDEBUG" /robust /nologo ${QMAKE_FILE_IN}
} else {
MIDL.commands = midl.exe /env win32 /h ${QMAKE_FILE_BASE}.h /W1 /char signed /D "NDEBUG" /robust /nologo ${QMAKE_FILE_IN}
}
QMAKE_EXTRA_COMPILERS += MIDL
}
CONFIG += c++11 console
CONFIG -= app_bundle
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
CMake:
- Code: Select all
cmake_minimum_required(VERSION 3.14)
project(stream-controll-desktop-client LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
add_executable(stream-controll-desktop-client
main.cpp
)
target_link_libraries(stream-controll-desktop-client Qt${QT_VERSION_MAJOR}::Core)
set(MIDL_OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/BMDSwitcherAPI.h
)
set(MIDL_FILE
${CMAKE_CURRENT_LIST_DIR}/BMDSwitcherAPI.idl
)
add_custom_command(
OUTPUT ${MIDL_OUTPUT}
COMMAND midl /h BMDSwitcherAPI.h ${MIDL_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${MIDL_FILE}
VERBATIM
)
target_sources(${PROJECT_NAME} PRIVATE ${MIDL_FILE} ${MIDL_OUTPUT})
These two applications are just generated new console apps by Qt Creator. I am not Cmake nor qmake expert. *.pro file is compileable, but nothing is generated. CMake is not compileable.
Any advice, how to setup MIDL correctly? For qmake I followed this topic, for CMake I followed
https://stackoverflow.com/questions/468 ... from-cmakeAnyone any ideas? Thank you, Matej S.