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

Refactor: CMake Support #889

Merged
merged 33 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
35d94e4
Refactor: CMake Support
BenjamenMeyer Oct 3, 2024
192d39e
Bug Fix: Package executable locations
BenjamenMeyer Oct 5, 2024
013ef24
Cleanup
BenjamenMeyer Oct 5, 2024
ee42e59
Merge branch 'master' into refactor_cmake_2
BenjamenMeyer Oct 12, 2024
ef710c0
Windows CI: Move CMakePresets to root with CMake
BenjamenMeyer Oct 12, 2024
94ede27
Bug Fix: fix relative paths
BenjamenMeyer Oct 12, 2024
47d2e9d
Bug Fix: update package and build scripts for CI
BenjamenMeyer Oct 13, 2024
0b2cf6a
Bug Fix: Tests
BenjamenMeyer Oct 13, 2024
8e6fa03
Bug Fixes
BenjamenMeyer Oct 17, 2024
287d533
Merge branch 'master' into refactor_cmake_2
BenjamenMeyer Oct 17, 2024
8f1f239
Merge branch 'master' into refactor_cmake_2
BenjamenMeyer Dec 24, 2024
251bd77
Merge branch 'master' into refactor_cmake_2
BenjamenMeyer Dec 26, 2024
86da290
Bug Fix: Windows Dependencies
BenjamenMeyer Dec 27, 2024
bb5e251
Bug Fix: Windows - relocate files
BenjamenMeyer Dec 27, 2024
057801e
WIP rearranging a few things
stephengtuggy Jan 2, 2025
d67f339
Merge branch 'refs/heads/master' into refactor_cmake_2_sgt
stephengtuggy Jan 2, 2025
94d2458
engine/CMakeLists.txt: Include full path to config.h
stephengtuggy Jan 2, 2025
a1ff591
6x *.yml in .github/workflows: update actions/checkout version; synch…
stephengtuggy Jan 2, 2025
1ce8fa6
CMakeLists.txt, engine/CMakeLists.txt: Fix PIE problems with gtest, a…
stephengtuggy Jan 2, 2025
ff96fe2
Update script/bootstrap
stephengtuggy Jan 2, 2025
8987b38
Stop building on Fedora 41 and openSUSE 15.6 for now, since those bui…
stephengtuggy Jan 2, 2025
5f6c50b
gh-actions-pr.yml: Allow build failures for Rocky Linux 9.5, openSUSE…
stephengtuggy Jan 2, 2025
89b64bc
python_tests.cpp: #include boost/python.hpp at top of file to work ar…
stephengtuggy Jan 4, 2025
0cf94af
python_utils.cpp: Replace Py_SetPath call with newer constructs
stephengtuggy Jan 4, 2025
a759642
init.cpp: Replace Py_SetPath call with newer constructs
stephengtuggy Jan 4, 2025
3d21db4
faction_generic.cpp, gfxlib_struct.cpp: Fix some warnings
stephengtuggy Jan 4, 2025
3618531
init.cpp, python_utils.cpp: Initialize the PyWideStringList
stephengtuggy Jan 4, 2025
fcf95bb
init.cpp, python_utils.cpp, engine/CMakeLists.txt: Set `config.isolat…
stephengtuggy Jan 4, 2025
7c98024
python_tests.cpp: Replace Py_SetPath call with newer constructs
stephengtuggy Jan 5, 2025
e9904eb
Merge branch 'master' into refactor_cmake_2_sgt
stephengtuggy Jan 9, 2025
4e1808a
gh-actions-release.yml: Further adjust the set of distros we build re…
stephengtuggy Jan 9, 2025
343b111
python_utils.cpp: Drop the "yaml" nomenclature
stephengtuggy Jan 9, 2025
877b72e
Merge pull request #2 from stephengtuggy/refactor_cmake_2_sgt
BenjamenMeyer Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#====================================
# @file : CMakeLists.txt
# @brief : cmake configuration file for VegaStrike
#====================================
# create a build directory somewhere outside of this source tree
# > cd .. && mkdir build && cd build
# run > cmake <path to source tree>
# run > make
# to change build target (in Release, RelWithDebInfo, Debug, Profiler)
# > cmake -DCMAKE_BUILD_TYPE=Debug <path to source tree>
#====================================
# Copyright (C) 2001-2023 safemode, Anth0rx, pyramid, Roy Falk,
# Nachum Barcohen, Rune Morling, Stephen G. Tuggy, Benjamen Meyer, s0600204,
# Evert Vorster, and other Vega Strike contributors.
#
# https://github.com/vegastrike/Vega-Strike-Engine-Source
#
# This file is part of Vega Strike.
#
# Vega Strike is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Vega Strike is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Vega Strike. If not, see <https://www.gnu.org/licenses/>.


CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR)

# There are a number of custom CMake packages
# Tell CMake where to find them
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

SET(VEGASTRIKE_VERSION_MAJOR "0")
SET(VEGASTRIKE_VERSION_MINOR "10")
SET(VEGASTRIKE_VERSION_PATCH "0")

IF (DEFINED ENV{SHORT_SHA} AND NOT "$ENV{SHORT_SHA}" STREQUAL "")
SET(VEGASTRIKE_VERSION_TWEAK "$ENV{SHORT_SHA}")
ELSE ()
SET (GIT_ROOT_DIR "${CMAKE_SOURCE_DIR}")
MESSAGE("-- CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}")
MESSAGE("-- GIT_ROOT_DIR = ${GIT_ROOT_DIR}")
EXECUTE_PROCESS(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${GIT_ROOT_DIR}
OUTPUT_VARIABLE VEGASTRIKE_VERSION_TWEAK
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ENDIF ()

SET(VEGASTRIKE_VERSION_LONG_STR "${VEGASTRIKE_VERSION_MAJOR}.${VEGASTRIKE_VERSION_MINOR}.${VEGASTRIKE_VERSION_PATCH}-${VEGASTRIKE_VERSION_TWEAK}")
SET(VEGASTRIKE_VERSION_SHORT_STR "${VEGASTRIKE_VERSION_MAJOR}.${VEGASTRIKE_VERSION_MINOR}.${VEGASTRIKE_VERSION_PATCH}")
SET(VEGASTRIKE_PKG_VERSION_STR "${VEGASTRIKE_VERSION_MAJOR}.${VEGASTRIKE_VERSION_MINOR}.${VEGASTRIKE_VERSION_PATCH}")

IF (DEFINED ENV{TAG_NAME} AND NOT "$ENV{TAG_NAME}" STREQUAL "")
STRING(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" TAG_VERSION_MAJOR "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" TAG_VERSION_MINOR "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" TAG_VERSION_PATCH "$ENV{TAG_NAME}")
STRING(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" TAG_VERSION_TWEAK "$ENV{TAG_NAME}")

SET(TAG_VERSION_SHORT_STR "${TAG_VERSION_MAJOR}.${TAG_VERSION_MINOR}.${TAG_VERSION_PATCH}")

IF (NOT "${VEGASTRIKE_VERSION_SHORT_STR}" VERSION_EQUAL "${TAG_VERSION_SHORT_STR}")
MESSAGE(FATAL_ERROR "!! Project version spelled out in CMake file does not match project version from TAG_NAME environment variable")
ENDIF ()
IF (NOT "${TAG_VERSION_TWEAK}" STREQUAL "")
SET(VEGASTRIKE_VERSION_LONG_STR "${VEGASTRIKE_VERSION_MAJOR}.${VEGASTRIKE_VERSION_MINOR}.${VEGASTRIKE_VERSION_PATCH}${TAG_VERSION_TWEAK}-${VEGASTRIKE_VERSION_TWEAK}")
SET(VEGASTRIKE_PKG_VERSION_STR "${VEGASTRIKE_VERSION_MAJOR}.${VEGASTRIKE_VERSION_MINOR}.${VEGASTRIKE_VERSION_PATCH}${TAG_VERSION_TWEAK}")
ENDIF ()
ENDIF ()

# API Version for Game Assets
# This is an incrementing number similar to the Google Android API Version
# allowing us to differentiate our Assets API across multiple versions.
# If a release is missing this value, then version `1` can be assumed.
SET(VEGASTRIKE_ASSETS_API_VERSION "2")

#IF (COMMAND cmake_policy)
# CMAKE_POLICY (SET CMP0003 NEW)
#ENDIF (COMMAND cmake_policy)
#
## VERSION Policy
#IF (POLICY CMP0048)
# CMAKE_POLICY (SET CMP0048 NEW)
#ENDIF (POLICY CMP0048)
#
## Used to be that without this, CMake couldn't find pow() -- at least not on my Windows machine.
#IF (POLICY CMP0066)
# CMAKE_POLICY (SET CMP0066 NEW)
#ENDIF ()
#
## FindOpenGL prefers GLVND by default when available. But there is an option to override that.
#IF (POLICY CMP0072)
# CMAKE_POLICY (SET CMP0072 NEW)
#ENDIF (POLICY CMP0072)
#
## find_package() uses <PackageName>_ROOT variables
#IF (POLICY CMP0074)
# CMAKE_POLICY (SET CMP0074 NEW)
#ENDIF (POLICY CMP0074)
#
## Include file check macros honor CMAKE_REQUIRED_LIBRARIES
#IF (POLICY CMP0075)
# CMAKE_POLICY (SET CMP0075 NEW)
#ENDIF ()
#
## Concerning link time flags for turning on or off Position Independent Executables (PIE)
#IF (POLICY CMP0083)
# CMAKE_POLICY (SET CMP0083 NEW)
#ENDIF ()
#
## MSVC runtime library flags are selected by an abstraction. Supported by CMake 3.15 and up
#IF (POLICY CMP0091)
# CMAKE_POLICY (SET CMP0091 NEW)
#ENDIF ()

PROJECT(Vega_Strike
VERSION
"${VEGASTRIKE_VERSION_MAJOR}.${VEGASTRIKE_VERSION_MINOR}.${VEGASTRIKE_VERSION_PATCH}" #.${VEGASTRIKE_VERSION_TWEAK} # CMake only allows numeric version components, unfortunately.
LANGUAGES
CXX C
)

MESSAGE("== Vega Strike Version: ${VEGASTRIKE_VERSION_LONG_STR}")

SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED TRUE)
SET(CMAKE_CXX_EXTENSIONS ON)
SET(CMAKE_C_STANDARD 11)
SET(CMAKE_C_STANDARD_REQUIRED TRUE)
SET(CMAKE_C_EXTENSIONS ON)

SET(VS_SUBDIRECTORIES "engine")
FOREACH(VS_SUBDIR IN LISTS VS_SUBDIRECTORIES)
ADD_SUBDIRECTORY(${VS_SUBDIR})
ENDFOREACH(VS_SUBDIR)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ If you encounter any issues while playing, please create an issue with the Vega

```bash
mkdir build & cd build
ccmake ../engine
ccmake ..
# (configure/edit options to taste in ccmake, press 'c' to save the selected options
# and press 'g' to update the build configuration files used by the make build tool)
cmake --build ./build -j $(getconf _NPROCESSORS_ONLN) # (where the getconf clause returns the number of available CPU threads/cores on the system)
Expand All @@ -269,7 +269,7 @@ If you encounter any issues while playing, please create an issue with the Vega

```bash
mkdir build & cd build
cmake ../engine
cmake ..
cmake --build ./build -j $(getconf _NPROCESSORS_ONLN) # (where the getconf clause returns the number of available CPU threads/cores on the system)
mkdir ../bin && cp vegastrike-engine ../bin/ && cp setup/vegasettings ../bin/ && cd ..
```
Expand All @@ -285,7 +285,7 @@ If you encounter any issues while playing, please create an issue with the Vega
To enable/disable compile-time options with cmake, use `cmake -D<option>=<value>`. Example:

```bash
cmake ../engine -DENABLE_PIE=ON -DUSE_PYTHON_3=ON -DCPU_SMP=2 -DCPUINTEL_native=ON -CMAKE_BUILD_TYPE=Debug
cmake .. -DENABLE_PIE=ON -DUSE_PYTHON_3=ON -DCPU_SMP=2 -DCPUINTEL_native=ON -CMAKE_BUILD_TYPE=Debug
```

__NOTE__:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR)
INCLUDE(GNUInstallDirs)
MESSAGE("Always using preferred method now to install doc files")
INSTALL(FILES AUTHORS TYPE DOC RENAME AUTHORS.SF)
INSTALL(FILES "${PROJECT_SOURCE_DIR}/../AUTHORS" TYPE DOC RENAME AUTHORS.GITHUB)
INSTALL(FILES "${PROJECT_SOURCE_DIR}/AUTHORS" TYPE DOC RENAME AUTHORS.GITHUB)
INSTALL(FILES ChangeLog TYPE DOC)

ADD_SUBDIRECTORY(man)
Expand Down
Loading
Loading