53Fermer55
deleted2Le 08/05/2015 à 22:36
F*ck yeah !!! Mon premier CMakeLists.txt qui marche enfin love
Bon, c'est certainement pas académique du tout, et ça doit etre bien laid, mais ça marche tongue
cmake_minimum_required(VERSION 2.8.11)
project(tbl)

# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_POSITION_INDEPENDANT_CODE ON)

# Find the QtWidgets library
find_package(Qt5 REQUIRED Widgets)
include_directories(${} ${Qt5Widgets_INCLUDE_DIRS})

# Executable to create
add_executable(
    tbl
    main.cpp
    tbl.cpp
    )

install(TARGETS tbl RUNTIME DESTINATION bin)

Aller détente, une après-midi/soirée de doc, ça tue grin
(ah tiens, on voit qu'il n'y a rien pour dire comment linker : normal, j'ai inclus des headers Qt, mais pas écrit une ligne de code, donc ça compile... rien grin)



Bon en fait j'arrive pas à lacher embarrassed

Quelle est la différence entre ce qui précède, et ce genre de CMakeLists :
cmake_minimum_required(VERSION 2.8.11)
project(tbl)

# Find the QtWidgets library
find_package(Qt5 REQUIRED Widgets)

# Create target
add_executable(tbl
    main.cpp
    tbl.cpp
    )

target_include_directories(tbl PUBLIC ${Qt5Widgets_INCLUDE_DIRS})
set_target_properties(tbl PROPERTIES
    POSITION_INDEPENDENT_CODE ON
    AUTOMOC ON)

# Installation
install(TARGETS tbl RUNTIME DESTINATION bin)

Comme on voit, les options de CMake sont définies pour un target et non au niveau global. C'est vraiment comme on veut, ou il vaut mieux que je sache quelque chose maintenant ?