I am trying to create rcc
files using CMake
using the qt5_add_binary_resources(target inputfile ... OPTIONS ... DESTINATION ...)
macro qt5_add_binary_resources(target inputfile ... OPTIONS ... DESTINATION ...)
:
qt5_add_binary_resources(myApp "themes/redTheme.qrc" OPTIONS ARGS -binary)
Since I use other macros such as add_executable
in my CMakeLists
file (which asks for target
), I get the following error:
CMake Error at C:/Qt/5.5/msvc2013/lib/cmake/Qt5Core/Qt5CoreMacros.cmake:255 (add_custom_target): add_custom_target cannot create target "myApp" because another target with the same name already exists. The existing target is an executable created in source directory [..]
Note that my CMakeLists
file is nested in the CMakeLists
root.
EDIT: I took a look at the definition (l.226) of the qt5_add_binary_resources
macro. The last line is the command causing my error. He seems to be doing nothing:
add_custom_target(${target} ALL DEPENDS ${rcc_destination})
I donโt understand why the macro needs target
?
EDIT: here is the contents of my CMakeLists.txt
, although simplified for clarity.
CMAKE_MINIMUM_REQUIRED(VERSION 3.4) CMAKE_POLICY(SET CMP0002 NEW) PROJECT(myApp) SET(RCC_EXECUTABLE ${CMAKE_PREFIX_PATH}/bin/rcc.exe) # Find includes in corresponding build directories SET(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed SET(CMAKE_AUTOMOC ON) SET(CMAKE_AUTORCC ON) FIND_PACKAGE(Qt5Core 5.5.0 REQUIRED) FIND_PACKAGE(Qt5Widgets 5.5.0 REQUIRED) FIND_PACKAGE(Qt5Qml 5.5.0 REQUIRED) FIND_PACKAGE(Qt5Quick 5.5.0 REQUIRED) INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIRS}) # etc. SET(myApp_LIBRARIES ${BOOST_THREAD_LIBRARIES} ${BOOSTALL_LIBRARIES} Qt5::Core Qt5::Widgets Qt5::Qml Qt5::Quick ) SET(myApp_LIBRARIES ${myApp_LIBRARIES} ) SET(myApp_SOURCES source/main.cpp ) SET(myApp_RESOURCES resources/qml.qrc ) SET(myApp_EXTERNAL_BINARY_RESOURCES themes/redTheme.qrc themes/blueTheme.qrc ) ADD_EXECUTABLE(myApp WIN32 ${myApp_SOURCES} ${myApp_RESOURCES} ) FOREACH(_qrc_file ${myApp_EXTERNAL_BINARY_RESOURCES}) STRING(REPLACE "qrc" "rcc" _rcc_file ${_qrc_file}) # This is where I'd like to create my binary resources # QT5_ADD_BINARY_RESOURCES("test.rcc" ${_qrc_file}) # Current working process, but not clean EXECUTE_PROCESS(COMMAND ${RCC_EXECUTABLE} -binary ${CMAKE_CURRENT_SOURCE_DIR}/${_qrc_file} -o ${CMAKE_CURRENT_SOURCE_DIR}/${_rcc_file}) ENDFOREACH()
According to this file, I am trying to create two rcc
files: redTheme.rcc
and blueTheme.rcc
.
source share