Changing qmake to cmake
Unsolved
General and Desktop
-
I have a small c++ project im trying to convert from qmake to cmake.
The pro and cmake files can be found on github https://github.com/bit-shift-io/audiobookMy setup seems to be okay till the build gets to 100%. It fails with the errors bellow. I assume this is because I rely on the LibTag library... How can I include this in my cmake?
[100%] Linking CXX executable audiobook /usr/bin/ld: CMakeFiles/audiobook.dir/src/library.cpp.o: in function `Library::get_time_msec(QFileInfo)': library.cpp:(.text+0x999): undefined reference to `TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle)' /usr/bin/ld: library.cpp:(.text+0x9bd): undefined reference to `TagLib::FileRef::file() const' /usr/bin/ld: library.cpp:(.text+0x9d4): undefined reference to `TagLib::AudioProperties::lengthInMilliseconds() const' /usr/bin/ld: library.cpp:(.text+0x9e6): undefined reference to `TagLib::FileRef::~FileRef()' /usr/bin/ld: library.cpp:(.text+0xa33): undefined reference to `TagLib::FileRef::~FileRef()' /usr/bin/ld: CMakeFiles/audiobook.dir/src/audioutil.cpp.o: in function `AudioUtil::get_time_msec(QString const&)': audioutil.cpp:(.text+0x396): undefined reference to `TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle)' /usr/bin/ld: audioutil.cpp:(.text+0x3ae): undefined reference to `TagLib::FileRef::file() const' /usr/bin/ld: audioutil.cpp:(.text+0x3c5): undefined reference to `TagLib::AudioProperties::lengthInMilliseconds() const' /usr/bin/ld: audioutil.cpp:(.text+0x3d7): undefined reference to `TagLib::FileRef::~FileRef()' /usr/bin/ld: audioutil.cpp:(.text+0x413): undefined reference to `TagLib::FileRef::~FileRef()' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/audiobook.dir/build.make:210: audiobook] Error 1 make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/audiobook.dir/all] Error 2 make: *** [Makefile:130: all] Error 2
-
I'm a novice in cmake myself, so I'm not sure about this, but I think you need to add your libtag to:
target_link_libraries(audiobook Qt5::Widgets)
Perhaps something like this will work:
target_link_libraries(audiobook Qt5::Widgets taglib)
-
I think the problem is in my config bellow.
The libtag doesnt look like its building correctly ${CMAKE_CURRENT_SOURCE_DIR}/build/taglib/lib/libtag.so does not exists.
${CMAKE_CURRENT_BINARY_DIR}/taglib/src/taglib is empty also!# TagLib ExternalProject_Add( taglib URL https://taglib.org/releases/taglib-${TAGLIB_VERSION}.tar.gz URL_MD5 ${TAGLIB_CHECKSUM} CONFIGURE_COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_BINARY_DIR}/taglib/src/taglib -DCMAKE_MAKE_PROGRAM=${UNIX_MAKE_PROGRAM} -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/build/taglib/ PREFIX taglib INSTALL_COMMAND ${UNIX_MAKE_PROGRAM} install ) add_library(tag SHARED IMPORTED) set_target_properties(tag PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/build/taglib/lib/libtag.so)
-