Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake support #11

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
adding examples
Ernesto Cruz committed Mar 26, 2021
commit e0346a5f060bc08175a079b3cf0aae8ee9678870
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -38,3 +38,4 @@ build-*
docs/html
build
*.txt.user
.vscode
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -51,5 +51,15 @@ set(SRC_FILES
)

add_library(${PROJECT_NAME} ${SRC_FILES})
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/priv)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/priv)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Qml project_options_and_warnings)


option(ENABLE_EXAMPLES "Enable Test Builds" ON)

if(ENABLE_EXAMPLES)
message(STATUS "Building Examples")
add_subdirectory(examples/faketrello)
endif()

46 changes: 46 additions & 0 deletions examples/faketrello/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 3.14)

project(Faketrello LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ ${CMAKE_BINARY_DIR}/imports CACHE STRING "" FORCE)

message(STATUS "QML_IMPORT_PATH: ${QML_IMPORT_PATH}")

find_package(
QT NAMES Qt6 Qt5
COMPONENTS Core Quick Qml
REQUIRED)

find_package(
Qt${QT_VERSION_MAJOR}
COMPONENTS Core Quick Qml
REQUIRED)

set(SRC_FILES
${CMAKE_CURRENT_SOURCE_DIR}/appdelegate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/appdelegate.h
${CMAKE_CURRENT_SOURCE_DIR}/board.cpp
${CMAKE_CURRENT_SOURCE_DIR}/board.h
${CMAKE_CURRENT_SOURCE_DIR}/card.cpp
${CMAKE_CURRENT_SOURCE_DIR}/card.h
${CMAKE_CURRENT_SOURCE_DIR}/list.cpp
${CMAKE_CURRENT_SOURCE_DIR}/list.h
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qml.qrc
)

add_executable(${PROJECT_NAME} ${SRC_FILES})

target_compile_definitions(
${PROJECT_NAME}
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

add_dependencies(${PROJECT_NAME} QSyncable)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Quick
QSyncable)