Well I finallly managed to get it thanks to http://qtnode.net/wiki/Qt4_with_cmake

So this is a template of CMakeLists.txt for a classe called "MACLASSE" that would inherit from QObject (which was the problem because you then have to use QT_WRAPP_CPP
Qt Code:
  1. cmake_minimum_required(VERSION 2.6)
  2. project(MACLASSE)
  3. set(LIBRARY_OUTPUT_PATH lib)
  4. find_package(Qt4 REQUIRED)
  5. INCLUDE(${QT_USE_FILE})
  6. include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} include)
  7.  
  8. SET (MACLASSE_SRCS src/MACLASSE.cpp)
  9. SET (MACLASSE_HEADERS include/MACLASSE.h)
  10.  
  11. MESSAGE( STATUS "sources: " ${MACLASSE_SRCS} )
  12. MESSAGE( STATUS "headers: " ${MACLASSE_HEADERS} )
  13.  
  14. qt4_wrap_cpp(MACLASSE_HEADERS_MOC ${MACLASSE_HEADERS}) #in there you put the headers and ONLY the headers
  15.  
  16. add_library(MACLASSE SHARED ${MACLASSE_SRCS} ${MACLASSE_HEADERS_MOC} )
  17. target_link_libraries(MACLASSE ${QT_LIBRARIES})
To copy to clipboard, switch view to plain text mode