Files
c-evo-evo/CMakeLists.txt
T

241 lines
8.8 KiB
CMake

# This file is part of c-evo-evo.
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
cmake_minimum_required(VERSION 3.16)
project(c-evo-evo VERSION 0.1 LANGUAGES CXX)
option(CEVO_WITH_APP "Build the game application (widget/media + c-evo-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}/c-evo-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}/c-evo-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 c-evo-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(game)
add_subdirectory(resources)
set(TS_FILES c-evo-evo_en_US.ts)
set(PROJECT_SOURCES
main.cpp
game/mainwindow.cpp
game/mainwindow.h
game/mainwindow.ui
game/Back.cpp
game/Back.h
game/Brain.cpp
game/Brain.h
game/Direct.cpp
game/Direct.h
game/GameServer.cpp
game/GameServer.h
game/GameServerInternal.h
game/GameServer.ClientCallPlumbing.cpp
game/GameServer.Lifecycle.cpp
game/GameServer.MoveAndCombat.cpp
game/GameServer.Server.cpp
game/GameServer.TurnProcessing.cpp
game/Global.cpp
game/Global.h
game/Inp.cpp
game/Inp.h
game/Inp.ui
game/Log.cpp
game/Log.h
game/Log.ui
game/Messg.cpp
game/Messg.h
game/Messg.ui
game/localplayer/KeyBindings.cpp
game/localplayer/KeyBindings.h
game/localplayer/ClientTools.cpp
game/localplayer/ClientTools.h
game/localplayer/CityType.cpp
game/localplayer/CityType.h
game/localplayer/CityType.ui
game/localplayer/Diagram.cpp
game/localplayer/Diagram.h
game/localplayer/Diagram.ui
game/localplayer/Diplomacy.cpp
game/localplayer/Diplomacy.h
game/localplayer/IsoEngine.cpp
game/localplayer/IsoEngine.h
game/localplayer/Rates.cpp
game/localplayer/Rates.h
game/localplayer/Rates.ui
game/localplayer/TechTree.cpp
game/localplayer/TechTree.h
game/localplayer/TechTree.ui
game/localplayer/Term.cpp
game/localplayer/Term.h
game/localplayer/Tribes.cpp
game/localplayer/Tribes.h
game/localplayer/Help.cpp
game/localplayer/Help.h
game/localplayer/Help.ui
game/localplayer/Wonders.cpp
game/localplayer/Wonders.h
game/localplayer/Wonders.ui
game/localplayer/NatStat.cpp
game/localplayer/NatStat.h
game/localplayer/NatStat.ui
game/localplayer/Draft.cpp
game/localplayer/Draft.h
game/localplayer/Draft.ui
game/localplayer/UnitStat.cpp
game/localplayer/UnitStat.h
game/localplayer/UnitStat.ui
game/localplayer/MessgEx.cpp
game/localplayer/MessgEx.h
game/localplayer/MessgEx.ui
game/localplayer/CityScreen.cpp
game/localplayer/CityScreen.h
game/localplayer/CityScreen.ui
game/localplayer/Select.cpp
game/localplayer/Select.h
game/localplayer/Select.ui
${TS_FILES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(c-evo-evo
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET c-evo-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(c-evo-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(c-evo-evo
${PROJECT_SOURCES}
)
endif()
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
target_link_libraries(c-evo-evo PRIVATE Qt${QT_VERSION_MAJOR}::Widgets dpiwidgets cevowidgets uosmedia cevocommon cevogame cevoai)
# Lets flat game/ files use simple quoted includes (e.g. "Global.h",
# "localplayer/Tribes.h") regardless of which game/ subdirectory the
# including file itself lives in.
target_include_directories(c-evo-evo PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/game)
# dpiwidgets/cevowidgets/uosmedia are installed to lib/c-evo-evo (not the
# default library directory), so the installed binary needs an explicit
# rpath to find them at runtime.
set_target_properties(c-evo-evo PROPERTIES
INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/c-evo-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(c-evo-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.c-evo-evo)
endif()
set_target_properties(c-evo-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 c-evo-evo
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(c-evo-evo)
endif()
endif() # CEVO_WITH_APP