I'm trying to create rcc
files with CMake
, using the qt5_add_binary_resources(target inputfile ... OPTIONS ... DESTINATION ...)
macro:
qt5_add_binary_resources(myApp "themes/redTheme.qrc" OPTIONS ARGS -binary)
Since I'm using other macros such as add_executable
in my CMakeLists
file (which asks for a target
), I'm getting 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 a root CMakeLists
.
EDIT: I took a look at the definition (l.226) of the qt5_add_binary_resources
macro. The last line is the command provoking my error. It doesn't seem to be doing anything:
add_custom_target(${target} ALL DEPENDS ${rcc_destination})
I don't understand why the macro needs a target
?
EDIT: here's the content of my CMakeLists.txt
, though simplified for clarity reasons.
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'm trying to generate two rcc
files: redTheme.rcc
and blueTheme.rcc
.