1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| # Version minimale requise pour CMAKE
cmake_minimum_required(VERSION 3.21)
# Nom du projet et version de la librairie
project(MaLibQml VERSION 1.0)
# Répertoires
SET(CMAKE_PREFIX_PATH "C:/Qt/5.15.2/msvc2019_64")
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTORCC ON)
SET(CMAKE_AUTOUIC ON)
# pour trouver les packages Qt
include_directories(${Qt5Core_INCLUDE_DIRS})
find_package(Qt5 COMPONENTS Core REQUIRED)
# Ajoutez vos fichiers source C++ (.cpp et .h)
SET(SOURCES
mabibliotheque.cpp
# main.cpp
)
SET(HEADERS
mabibliotheque.h
)
# Ajoutez tous les fichiers QML nécessaires
# Dans le cas où on veut utiliser des fichiers QML et C++ dans la librairie.
# Ce n'est pas le cas ici
# set(QML_FILES
# qml_plugin/MyLibrary.qml
# )
# affichage des fichiers
message("Liste des Fichiers h: ")
foreach(h_file ${HEADERS})
message(STATUS " ${h_file}")
endforeach()
message(STATUS "Liste des Fichiers cpp: ")
foreach(source_file ${SOURCES})
message(STATUS " ${source_file}")
endforeach()
message(STATUS "Liste des Fichiers qml : ")
foreach(qml_file ${QML_FILES})
message(STATUS " ${qml_file}")
endforeach()
# Ajouter une bibliothèque partagée (Shared Library)
add_library(MaLibQml SHARED ${SOURCES} ${HEADERS})
# Configurer la version de votre bibliothèque
set_target_properties(MaLibQml PROPERTIES VERSION ${PROJECT_VERSION})
# Installez la bibliothèque et les fichiers d'en-tête
install(TARGETS MaLibQml
LIBRARY DESTINATION lib/MaLibQml
ARCHIVE DESTINATION lib/MaLibQml
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(FILES ${HEADERS} DESTINATION include/MaLibQml)
#add_library(MyLibrary ${SOURCES})
# Configurer l'inclusion des fichiers d'en-tête
#target_include_directories(MyLibrary PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# Lien avec les bibliothèques Qt
#target_link_libraries(MyLibrary PUBLIC Qt5::Core Qt5::Qml)
# Configurer la propriété C++11 pour la bibliothèque
#set_property(TARGET MyLibrary PROPERTY CXX_STANDARD 11)
#target_sources(MyLibrary PRIVATE ${QML_FILES})
# Créer la bibliothèque QML
#add_library(MyQmlLibrary MODULE qml_plugin/qmldir)
# Lien avec la bibliothèque C++
#target_link_libraries(MyQmlLibrary PRIVATE MyLibrary) |
Partager