82 lines
1.9 KiB
CMake
82 lines
1.9 KiB
CMake
# SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
cmake_minimum_required(VERSION 3.21.1)
|
|
|
|
project(magpie
|
|
VERSION 1.0
|
|
LANGUAGES CXX
|
|
)
|
|
set(PROJECT_LICENSE "GPL-3.0")
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
# set(CMAKE_AUTORCC ON)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
find_package(Qt6 6.6 REQUIRED COMPONENTS Core Gui Qml Quick QuickControls2 QuickLayouts)
|
|
|
|
qt_standard_project_setup()
|
|
|
|
qt_policy(SET QTP0001 NEW)
|
|
|
|
if(NOT EMSCRIPTEN AND CMAKE_TOOLCHAIN_FILE MATCHES ".*Emscripten\.cmake$")
|
|
set(EMSCRIPTEN TRUE)
|
|
endif()
|
|
|
|
qt_add_executable(magpie
|
|
root.cpp
|
|
)
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Debug)
|
|
endif ()
|
|
message("Build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
if (EMSCRIPTEN)
|
|
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
set(CMAKE_CXX_FLAGS "-gsource-map")
|
|
else()
|
|
target_compile_options(magpie PRIVATE -Oz -g0)
|
|
target_link_options(magpie PRIVATE -0z -g0 --closure 1)
|
|
endif()
|
|
message("building for emscripten")
|
|
target_sources(magpie PRIVATE main_web.cpp)
|
|
else()
|
|
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
else()
|
|
target_compile_options(magpie PRIVATE -O3)
|
|
endif()
|
|
message("building for desktop")
|
|
target_sources(magpie PRIVATE main.cpp)
|
|
endif()
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
else()
|
|
target_compile_options(magpie PRIVATE -flto)
|
|
target_link_options(magpie PRIVATE -flto)
|
|
endif()
|
|
|
|
add_subdirectory(qml)
|
|
add_subdirectory(API)
|
|
add_subdirectory(models)
|
|
add_subdirectory(utils)
|
|
add_subdirectory(resources)
|
|
|
|
target_include_directories(magpie PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_link_libraries(magpie PRIVATE
|
|
Qt6::Core
|
|
Qt6::Gui
|
|
Qt6::Qml
|
|
Qt6::Quick
|
|
Qt6::QuickControls2
|
|
Qt6::QuickLayouts
|
|
)
|
|
|
|
include(GNUInstallDirs)
|
|
install(TARGETS magpie
|
|
BUNDLE DESTINATION .
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
)
|