[CMake] compilation projet qt
Bonjour,
cela fait deux jours que je m'arrache les cheveux à utiliser cmake.
Mon projet compile bien avec qmake mais pas avec cmake.
Voici l'organisation de mon projet :
dans la racine :
- un dossier compilation. Il est vide, c'est depuis ce dossier que je lance la commande cmake.
- un dossier bin. C'est la que le fichier binaire executable doit etre placé par cmake.
- un dossier test. Il ne contient que le fichier contenant mon main().
- plusieurs dossiers contenant differentes classes
Voici mes CMakeLists.txt :
Celui situe a la racine du projet :
Citation:
PROJECT (INTERFACE)
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (CMAKE_BUILD_TYPE Release)
SET (CMAKE_VERBOSE_MAKEFILE true)
SET (INTERFACE_DIR ${CMAKE_SOURCE_DIR} )
SET (INTERFACE_SOURCE_DIR ${INTERFACE_DIR}/test ${INTERFACE_DIR}/manager ${INTERFACE_DIR}/player ${INTERFACE_DIR}/tree ${INTERFACE}/mainwindow )
ADD_DEFINITIONS( -Wall -g -O2 -pipe)
FIND_PACKAGE (Qt4 REQUIRED)
INCLUDE( ${QT_USE_FILE} )
SET (LIBRARY_OUTPUT_PATH ${INTERFACE_DIR}/build)
SET (EXECUTABLE_OUTPUT_PATH ${INTERFACE_DIR}/bin)
ADD_SUBDIRECTORY (player)
ADD_SUBDIRECTORY (manager)
ADD_SUBDIRECTORY (tree)
ADD_SUBDIRECTORY (mainwindow)
ADD_SUBDIRECTORY (test)
Celui du repertoire test:
Citation:
INCLUDE_DIRECTORIES(
${LIBRARY_OUTPUT_PATH}
${INTERFACE_SOURCE_DIR}
${INTERFACE_MAINWINDOW_SOURCE_DIR}
${INTERFACE_SAMPLERMANAGER_SOURCE_DIR}
${INTERFACE_TREE_SOURCE_DIR}
${INTERFACE_PLAYER_SOURCE_DIR}
)
LINK_DIRECTORIES( ${LIBRARY_OUTPUT_PATH} )
ADD_EXECUTABLE(executable main.cpp)
TARGET_LINK_LIBRARIES(executable Tree_LIB Player_LIB SamplerManager_LIB MainWindow_LIB ${QT_LIBRARIES} )
Celui d'un repertoire contenant differents classes :
Citation:
PROJECT(INTERFACE_PLAYER)
INCLUDE_DIRECTORIES(
${INTERFACE_NEWMAT_SOURCE_DIR}
${INTERFACE_SOURCE_DIR}
)
ADD_LIBRARY(Player_LIB
player.h
player.cpp
)
Et pour finir voici le mesage d'erreur que j'obtientts à la toute fin de compilation :
Citation:
[100%] Building CXX object test/CMakeFiles/executable.dir/main.cpp.o
cd /home/pierrick/files/projet-synthese/devlpt/devlpt/compilation/test && /usr/bin/c++ -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NO_DEBUG -O3 -DNDEBUG -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/home/pierrick/files/projet-synthese/devlpt/devlpt/build -I/home/pierrick/files/projet-synthese/devlpt/devlpt/test -I/home/pierrick/files/projet-synthese/devlpt/devlpt/manager -I/home/pierrick/files/projet-synthese/devlpt/devlpt/player -I/home/pierrick/files/projet-synthese/devlpt/devlpt/tree -I/mainwindow -I/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow -Wall -g -O2 -pipe -o CMakeFiles/executable.dir/main.cpp.o -c /home/pierrick/files/projet-synthese/devlpt/devlpt/test/main.cpp
Linking CXX executable ../../bin/executable
cd /home/pierrick/files/projet-synthese/devlpt/devlpt/compilation/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/executable.dir/link.txt --verbose=1
/usr/bin/c++ -O3 -DNDEBUG -fPIC CMakeFiles/executable.dir/main.cpp.o -o ../../bin/executable -rdynamic -L/home/pierrick/files/projet-synthese/devlpt/devlpt/build ../../build/libTree_LIB.a ../../build/libPlayer_LIB.a ../../build/libSamplerManager_LIB.a ../../build/libMainWindow_LIB.a /usr/lib64/qt4/libQtGui.so -lpng -lSM -lICE -lXrender -lXrandr -lXcursor -lXfixes -lfreetype -lfontconfig -lXext -lX11 -lm /usr/lib64/qt4/libQtCore.so /lib64/libz.so -lgthread-2.0 -lglib-2.0 -lrt -lpthread -ldl -Wl,-rpath,/home/pierrick/files/projet-synthese/devlpt/devlpt/build:/usr/lib64/qt4:/lib64
../../build/libMainWindow_LIB.a(mainwindow.cpp.o): In function `~MainWindow':
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:183: undefined reference to `vtable for MainWindow'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:183: undefined reference to `vtable for MainWindow'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:183: undefined reference to `vtable for MainWindow'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:183: undefined reference to `vtable for MainWindow'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:183: undefined reference to `vtable for MainWindow'
../../build/libMainWindow_LIB.a(mainwindow.cpp.o):/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:183: more undefined references to `vtable for MainWindow' follow
../../build/libMainWindow_LIB.a(mainwindow.cpp.o): In function `MainWindow':
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:127: undefined reference to `Arborescence::Arborescence(QString, QWidget*)'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:130: undefined reference to `SamplerManager::SamplerManager(QString, QWidget*)'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:133: undefined reference to `Player::Player(QString, QWidget*)'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:3: undefined reference to `vtable for MainWindow'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:3: undefined reference to `vtable for MainWindow'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:127: undefined reference to `Arborescence::Arborescence(QString, QWidget*)'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:130: undefined reference to `SamplerManager::SamplerManager(QString, QWidget*)'
/home/pierrick/files/projet-synthese/devlpt/devlpt/mainwindow/mainwindow.cpp:133: undefined reference to `Player::Player(QString, QWidget*)'
collect2: ld returned 1 exit status
make[2]: *** [../bin/executable] Error 1
make[2]: Leaving directory `/home/pierrick/files/projet-synthese/devlpt/devlpt/compilation'
make[1]: *** [test/CMakeFiles/executable.dir/all] Error 2
make[1]: Leaving directory `/home/pierrick/files/projet-synthese/devlpt/devlpt/compilation'
make: *** [all] Error 2
Désolé pour ce message assez long mais au moins je pense avoir donne toutes les informations.