134 lines
4.7 KiB
CMake
134 lines
4.7 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(cevo-evo VERSION 0.1 LANGUAGES CXX)
|
|
|
|
option(CEVO_WITH_APP "Build the game application (widget/media + cevo-evo executable)" ON)
|
|
option(CEVO_WITH_AI "Build and install the bundled stdai AI plugin (turn off to rely on a third-party AI module instead)" ON)
|
|
if(NOT CEVO_WITH_APP AND NOT CEVO_WITH_AI)
|
|
message(FATAL_ERROR "Nothing to build: enable at least one of CEVO_WITH_APP or CEVO_WITH_AI")
|
|
endif()
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
set(CMAKE_AUTOMOC ON)
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# ai/stdai has no Qt dependency, so only require Qt when building the app.
|
|
if(CEVO_WITH_APP)
|
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Multimedia Xml LinguistTools)
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Multimedia Xml LinguistTools)
|
|
endif()
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
# Extra install dirs, following GNUInstallDirs' own CACHE PATH convention
|
|
# (relative to CMAKE_INSTALL_PREFIX unless given as an absolute path).
|
|
set(CMAKE_INSTALL_AIDIR "${CMAKE_INSTALL_LIBDIR}/cevo-evo/ai" CACHE PATH
|
|
"AI plugin modules (e.g. stdai) - where the game looks for loadable AI brains")
|
|
set(CMAKE_INSTALL_RESOURCEDIR "${CMAKE_INSTALL_DATADIR}/cevo-evo" CACHE PATH
|
|
"Game resources (graphics, music, sounds, resource translations)")
|
|
foreach(_cevo_dir AIDIR RESOURCEDIR)
|
|
if(IS_ABSOLUTE "${CMAKE_INSTALL_${_cevo_dir}}")
|
|
set(CMAKE_INSTALL_FULL_${_cevo_dir} "${CMAKE_INSTALL_${_cevo_dir}}")
|
|
else()
|
|
set(CMAKE_INSTALL_FULL_${_cevo_dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${_cevo_dir}}")
|
|
endif()
|
|
endforeach()
|
|
|
|
# ai/ is the generic AI-plugin interface: needed by the app (to load AI
|
|
# modules at runtime) and by the bundled stdai plugin (as its base classes).
|
|
if(CEVO_WITH_APP OR CEVO_WITH_AI)
|
|
add_subdirectory(ai)
|
|
endif()
|
|
# stdai is a dynamically-loaded AI plugin (see ai/stdai/CMakeLists.txt): built
|
|
# here but deliberately NOT linked into the cevo-evo target below.
|
|
if(CEVO_WITH_AI)
|
|
add_subdirectory(ai/stdai)
|
|
endif()
|
|
|
|
if(CEVO_WITH_APP)
|
|
add_subdirectory(widget)
|
|
add_subdirectory(media)
|
|
add_subdirectory(common)
|
|
add_subdirectory(resources)
|
|
|
|
set(TS_FILES cevo-evo_en_US.ts)
|
|
|
|
set(PROJECT_SOURCES
|
|
main.cpp
|
|
mainwindow.cpp
|
|
mainwindow.h
|
|
mainwindow.ui
|
|
${TS_FILES}
|
|
)
|
|
|
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
|
qt_add_executable(cevo-evo
|
|
MANUAL_FINALIZATION
|
|
${PROJECT_SOURCES}
|
|
)
|
|
# Define target properties for Android with Qt 6 as:
|
|
# set_property(TARGET cevo-evo APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
|
|
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
|
|
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
|
|
|
|
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
|
else()
|
|
if(ANDROID)
|
|
add_library(cevo-evo SHARED
|
|
${PROJECT_SOURCES}
|
|
)
|
|
# Define properties for Android with Qt 5 after find_package() calls as:
|
|
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
|
|
else()
|
|
add_executable(cevo-evo
|
|
${PROJECT_SOURCES}
|
|
)
|
|
endif()
|
|
|
|
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
|
endif()
|
|
|
|
target_link_libraries(cevo-evo PRIVATE Qt${QT_VERSION_MAJOR}::Widgets dpiwidgets cevowidgets uosmedia cevocommon cevoai)
|
|
|
|
# dpiwidgets/cevowidgets/uosmedia are installed to lib/cevo-evo (not the
|
|
# default library directory), so the installed binary needs an explicit
|
|
# rpath to find them at runtime.
|
|
set_target_properties(cevo-evo PROPERTIES
|
|
INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/cevo-evo"
|
|
)
|
|
|
|
# Default, compile-time-known locations the game looks for its AI plugins
|
|
# and its resources (graphics/music/sounds/translations) at runtime.
|
|
target_compile_definitions(cevo-evo PRIVATE
|
|
CEVO_AI_DIR="${CMAKE_INSTALL_FULL_AIDIR}"
|
|
CEVO_RESOURCE_DIR="${CMAKE_INSTALL_FULL_RESOURCEDIR}"
|
|
)
|
|
|
|
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
|
# If you are developing for iOS or macOS you should consider setting an
|
|
# explicit, fixed bundle identifier manually though.
|
|
if(${QT_VERSION} VERSION_LESS 6.1.0)
|
|
set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.cevo-evo)
|
|
endif()
|
|
set_target_properties(cevo-evo PROPERTIES
|
|
${BUNDLE_ID_OPTION}
|
|
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
|
MACOSX_BUNDLE TRUE
|
|
WIN32_EXECUTABLE TRUE
|
|
)
|
|
|
|
install(TARGETS cevo-evo
|
|
BUNDLE DESTINATION .
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
)
|
|
|
|
if(QT_VERSION_MAJOR EQUAL 6)
|
|
qt_finalize_executable(cevo-evo)
|
|
endif()
|
|
endif() # CEVO_WITH_APP
|