Ok, et bien merci pour tout. J'ai pas mal potassé à nouveau.
Utilisant Qt5, j'ai vu que c'est maintenant Qt qui fournit son propre support pour CMake :
http://file:///usr/share/doc/cmake-data/html/manual/cmake-qt.7.html et
http://doc.qt.io/qt-5/cmake-manual.html (attention, vous devez installer une Debian Testing x86_64 pour visiter le premier lien
)
D'où les variables parachutées, maintenant ça c'est bon.
A ce niveau, je me suis également aidé d'un petit tuto très bien fait :
http://www.kdab.com/using-cmake-with-qt-5/Kevin Kofler (./55) :
Attention, ça s'écrit CMAKE_POSITION_INDEPENDENT_CODE, sinon ça n'aura aucun effet!
C'est ça quand on veut modifier un post en l'éditant à la main, mais dans mon fichier, c'était bon
Merci quand meme.
En fait, j'ai fini par virer cette ligne, parce que
Qt5 ça powate :
The recommended way to use Qt libraries and headers with CMake 2.8.11 is to use the target_link_libraries command. In CMake 2.8.11 and later versions, this command automatically adds appropriate include directories, compile definitions, the position-independent-code flag
, and links to the qtmain.lib library on Windows.
Merci pour tes conseils sur le côté target/global des settings, c'est à moi de réfléchir en fait, tout simplement.
Pour les variables cached, j'ai pas encore lu de doc à ce sujet, je m'y mets. Je comprends pas trop l'intérêt au premier abord. Pourquoi devoir rajouter CACHE à certaines variables ? Bon en tout cas, pour un projet portable, il me semble mieux de définir ces vars dans CMakeLists.txt, non ?
Ecoute merci pour tout, je vais continuer à plancher, la suite au prochain numéro
J'en étais arrivé là hier soir :
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
project(tbl)
# Find the QtWidgets library
find_package(Qt5 REQUIRED Widgets)
# Include that globally, so KDevelop can find the headers
include_directories(tbl PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${Qt5Widgets_INCLUDE_DIRS}
)
# Create target
add_executable(tbl
main.cpp
tbl.cpp
)
target_compile_options(tbl PUBLIC
-std=c++11
)
target_link_libraries(tbl
${Qt5Widgets_LIBRARIES}
)
set_target_properties(tbl PROPERTIES
AUTOMOC ON
)
# Installation
install(TARGETS tbl RUNTIME DESTINATION bin)