magpie/CMakeLists.txt

78 lines
1.7 KiB
CMake
Raw Normal View History

# SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
# SPDX-License-Identifier: GPL-3.0-or-later
2023-11-22 23:13:33 +00:00
cmake_minimum_required(VERSION 3.21.1)
2023-12-03 14:39:48 +00:00
project(magpie
2023-11-22 23:13:33 +00:00
VERSION 1.0
LANGUAGES CXX
)
set(PROJECT_LICENSE "GPL-3.0")
2023-11-22 23:13:33 +00:00
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()
2023-12-03 14:39:48 +00:00
qt_add_executable(magpie
2023-11-22 23:13:33 +00:00
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()
2023-12-03 14:39:48 +00:00
target_compile_options(magpie PRIVATE -Oz -g0)
target_link_options(magpie PRIVATE -0z -g0 --closure 1)
2023-11-22 23:13:33 +00:00
endif()
message("building for emscripten")
2023-12-03 14:39:48 +00:00
target_sources(magpie PRIVATE main_web.cpp)
2023-11-22 23:13:33 +00:00
else()
if (CMAKE_BUILD_TYPE STREQUAL Debug)
else()
2023-12-03 14:39:48 +00:00
target_compile_options(magpie PRIVATE -O3)
2023-11-22 23:13:33 +00:00
endif()
message("building for desktop")
2023-12-03 14:39:48 +00:00
target_sources(magpie PRIVATE main.cpp)
2023-11-22 23:13:33 +00:00
endif()
if (CMAKE_BUILD_TYPE STREQUAL Debug)
else()
2023-12-03 14:39:48 +00:00
target_compile_options(magpie PRIVATE -flto)
target_link_options(magpie PRIVATE -flto)
2023-11-22 23:13:33 +00:00
endif()
add_subdirectory(qml)
2023-11-24 23:48:01 +00:00
add_subdirectory(API)
2023-11-22 23:13:33 +00:00
2023-12-03 14:39:48 +00:00
target_link_libraries(magpie PRIVATE
2023-11-22 23:13:33 +00:00
Qt6::Core
Qt6::Gui
Qt6::Qml
Qt6::Quick
Qt6::QuickControls2
Qt6::QuickLayouts
)
include(GNUInstallDirs)
2023-12-03 14:39:48 +00:00
install(TARGETS magpie
2023-11-22 23:13:33 +00:00
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)