Skip to content

Commit

Permalink
style(autofix.ci): automated formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Oct 17, 2023
1 parent e7286d7 commit 612a047
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 133 deletions.
110 changes: 54 additions & 56 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ cmake_minimum_required(VERSION 3.21)

project(CataclysmBN)

list(APPEND CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/CMakeModules)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)
if (NOT VCPKG_MANIFEST_MODE)
list(APPEND CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/CMakeModules/Find)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules/Find)
endif ()

include(AstyleFormatSource)

Expand Down Expand Up @@ -47,11 +45,13 @@ set(GIT_BINARY
set(LINKER
""
CACHE STRING "Custom Linker to use")
set(GETTEXT_MSGFMT_BINARY "" CACHE FILEPATH "msgfmt binary name or path.")
set(GETTEXT_MSGFMT_BINARY
""
CACHE FILEPATH "msgfmt binary name or path.")

if (TESTS)
include(CTest)
endif()
include(CTest)
endif ()

include(GetGitRevisionDescription)
git_describe(GIT_VERSION --tags --always --match "[0-9A-Z]*.[0-9A-Z]*")
Expand Down Expand Up @@ -92,17 +92,19 @@ if (NOT "${GIT_VERSION}" MATCHES "GIT-NOTFOUND")
add_definitions(-DGIT_VERSION)

# get_git_head_revision() does not work with worktrees in Windows
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE _sha1
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(TIMESTAMP _timestamp %Y-%m-%d-%H%M)
file(WRITE VERSION.txt "\
file(
WRITE VERSION.txt
"\
build type: ${BUILD_PRESET_NAME}\n\
build number: ${_timestamp}\n\
commit sha: ${_sha1}\n\
commit url: https://github.com/CleverRaven/Cataclysm-DDA/commit/${_sha1}"
)
commit url: https://github.com/CleverRaven/Cataclysm-DDA/commit/${_sha1}")
endif ()

#OS Check Placeholders. Will be used for BINDIST
Expand Down Expand Up @@ -132,9 +134,9 @@ include(CheckCXXCompilerFlag)
#SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m32")

if (NOT DYNAMIC_LINKING)
if(NOT MSVC)
if (NOT MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a")
endif()
endif ()
set(BUILD_SHARED_LIBRARIES OFF)
check_cxx_compiler_flag(-static HAVE_STATIC_FLAG)
if (HAVE_STATIC_FLAG)
Expand Down Expand Up @@ -242,10 +244,8 @@ else ()
AND NOT WIN32
AND USE_PREFIX_DATA_DIR)
add_definitions(-DPREFIX=${CMAKE_INSTALL_PREFIX})
configure_file(
"${CMAKE_SOURCE_DIR}/src/prefix.h.in"
"${CMAKE_SOURCE_DIR}/src/prefix.h"
@ONLY)
configure_file("${CMAKE_SOURCE_DIR}/src/prefix.h.in" "${CMAKE_SOURCE_DIR}/src/prefix.h"
@ONLY)
add_definitions(-DDATA_DIR_PREFIX)
endif ()
endif ()
Expand Down Expand Up @@ -286,11 +286,11 @@ if (NOT MSVC)
-Wunused-macros \
-Wzero-as-null-pointer-constant \
-Wno-range-loop-analysis")
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning-option")
else()
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning-option")
else ()
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning")
endif ()
if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
set(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls")
endif ()
Expand Down Expand Up @@ -346,10 +346,13 @@ if (TILES)
message(STATUS "Searching for SDL2_TTF library --")
if (NOT VCPKG_MANIFEST_MODE)
find_package(SDL2_ttf)
else()
else ()
find_package(sdl2-ttf)
endif()
if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2::SDL2_ttf-static))
endif ()
if (NOT
(SDL2_TTF_FOUND
OR TARGET SDL2::SDL2_ttf
OR TARGET SDL2::SDL2_ttf-static))
message(
FATAL_ERROR
"This project requires SDL2_ttf to be installed to be compiled in graphical mode. \
Expand All @@ -359,11 +362,11 @@ if (TILES)
endif ()

message(STATUS "Searching for SDL2_image library --\n")
if(VCPKG_MANIFEST_MODE)
if (VCPKG_MANIFEST_MODE)
find_package(sdl2-image)
else()
else ()
find_package(SDL2_image)
endif()
endif ()
if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2::SDL2_image))
message(
FATAL_ERROR
Expand Down Expand Up @@ -404,26 +407,28 @@ if (SOUND)
endif ()

# Sound requires SDL_mixer library
if(VCPKG_MANIFEST_MODE)
if (VCPKG_MANIFEST_MODE)
message(STATUS "Searching for sdl2-mixer library --")
find_package(sdl2-mixer)
if (NOT TARGET SDL2::SDL2_mixer)
message(FATAL_ERROR
message(
FATAL_ERROR
"You need the sdl2-mixer development library \
to be able to compile with sound enabled. \
See CMake compiling guide for details and more info.")
endif()
else()
endif ()
else ()
message(STATUS "Searching for SDL2_mixer library --")
find_package(SDL2_mixer)
# if (NOT TARGET SDL2_mixer::SDL2_mixer-static) # TODO x64-mingw-static ?
if (NOT SDL2_MIXER_FOUND)
message(FATAL_ERROR
message(
FATAL_ERROR
"You need the SDL2_mixer development library \
to be able to compile with sound enabled. \
See CMake compiling guide for details and more info.")
endif ()
endif()
endif ()
endif ()

if (BACKTRACE)
Expand All @@ -434,15 +439,15 @@ if (BACKTRACE)
endif ()

if ((LOCALIZE OR BUILD_TESTING) AND "${GETTEXT_MSGFMT_BINARY}" STREQUAL "")
if(MSVC)
if (MSVC)
list(APPEND Gettext_ROOT C:\\msys64\\usr)
list(APPEND Gettext_ROOT C:\\Program\ Files\\Git\\usr)
endif(MSVC)
endif (MSVC)
find_package(Gettext)
endif ()
if (NOT GETTEXT_MSGFMT_EXECUTABLE )
if (NOT GETTEXT_MSGFMT_EXECUTABLE)
set(GETTEXT_MSGFMT_EXECUTABLE "${GETTEXT_MSGFMT_BINARY}")
endif()
endif ()

# Ok. Now create build and install recipes
if (USE_HOME_DIR)
Expand All @@ -461,36 +466,29 @@ add_subdirectory(src)
add_subdirectory(data)
add_subdirectory(lang)

if(TESTS)
if (TESTS)
add_subdirectory(tests)
endif()
endif ()
if (JSON_FORMAT)
add_subdirectory(tools/format)
endif ()
if (CATA_CLANG_TIDY_PLUGIN)
add_subdirectory(tools/clang-tidy-plugin)
endif ()

install(DIRECTORY doc gfx
DESTINATION ${DATA_PREFIX}
)
install(DIRECTORY doc gfx DESTINATION ${DATA_PREFIX})

if (RELEASE)
install(FILES
${CMAKE_SOURCE_DIR}/README.md
${CMAKE_SOURCE_DIR}/LICENSE.txt
${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt
${CMAKE_SOURCE_DIR}/VERSION.txt
DESTINATION ${README_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/README.md ${CMAKE_SOURCE_DIR}/LICENSE.txt
${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt ${CMAKE_SOURCE_DIR}/VERSION.txt
DESTINATION ${README_DIR})
if (TILES)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION ${DATA_PREFIX})
endif()
endif()
endif ()
endif ()

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)

add_custom_target(uninstall "${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
Expand Down
5 changes: 2 additions & 3 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ if (SOUND)
set(CATACLYSM_DATA_DIRS ${CATACLYSM_DATA_DIRS} ${CMAKE_SOURCE_DIR}/data/sound)
endif ()

set(CATACLYSM_DATA_FILES
${CMAKE_SOURCE_DIR}/data/changelog.txt
${CMAKE_SOURCE_DIR}/data/cataicon.ico)
set(CATACLYSM_DATA_FILES ${CMAKE_SOURCE_DIR}/data/changelog.txt
${CMAKE_SOURCE_DIR}/data/cataicon.ico)

if (RELEASE)
install(DIRECTORY ${CATACLYSM_DATA_DIRS} DESTINATION ${DATA_PREFIX})
Expand Down
96 changes: 59 additions & 37 deletions doc/COMPILING/COMPILING-CMAKE-VCPKG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Disclaimer

**WARNING**: CMake build is **NOT** officially supported and should be used for *dev purposes ONLY*.
**WARNING**: CMake build is **NOT** officially supported and should be used for _dev purposes ONLY_.

For the official way to build CataclysmDDA, see:
* [COMPILING.md](COMPILING.md)

- [COMPILING.md](COMPILING.md)

# Contents

Expand All @@ -15,70 +16,91 @@ For the official way to build CataclysmDDA, see:

# 1 Prerequisites

`cmake` >= 3.20.0<br/>
`vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html)
`msgfmt` (optional) as part of Git Bash or msys2 in the default install paths.
`cmake` >= 3.20.0<br/> `vcpkg` from [vcpkg.io](https://vcpkg.io/en/getting-started.html) `msgfmt`
(optional) as part of Git Bash or msys2 in the default install paths.

# 2 Configure

## Presets
The file `CMakePresets.json` contains all the presets.<br/>
They will all build the code into the directory `out/build/<preset>/`.

The file `CMakePresets.json` contains all the presets.<br/> They will all build the code into the
directory `out/build/<preset>/`.

## vcpkg

If vcpkg is checked out in a location different from `C:\vcpkg`, eg. `C:\dev\vcpkg`, you must do one of the following:
* append `-DVCPKG_ROOT=C:\dev\vcpkg` (or whatever the path is) to any cmake configure commands
* set the environment variable `VCPKG_ROOT` to the path to the vcpkg checkout.
* edit the `VCPKG_ROOT` cache variable in `CMakePresets.json` to the appropriate path
If vcpkg is checked out in a location different from `C:\vcpkg`, eg. `C:\dev\vcpkg`, you must do one
of the following:

- append `-DVCPKG_ROOT=C:\dev\vcpkg` (or whatever the path is) to any cmake configure commands
- set the environment variable `VCPKG_ROOT` to the path to the vcpkg checkout.
- edit the `VCPKG_ROOT` cache variable in `CMakePresets.json` to the appropriate path

## Visual Studio
The Standard toolbar shows the presets in the _Configuration_ drop-down box.<br/>
From the main menu, select _Project -> Configure Cache_

If you do not have `msgfmt` available, or do not want to include translations with the build, you need to additionally set `DLOCALIZE=OFF`. To do this, go to _Project -> CMake Settings_, scroll to the bottom where `"windows-tiles-sounds-x64-msvc"` is defined, and under `"cacheVariables"` change the value from `"LOCALIZE": "True"` to `"LOCALIZE": "OFF"`.
* Note: doing this will change the `CMakePresets.json` file which is tracked by source control. Do not commit this change.
The Standard toolbar shows the presets in the _Configuration_ drop-down box.<br/> From the main
menu, select _Project -> Configure Cache_

If you do not have `msgfmt` available, or do not want to include translations with the build, you
need to additionally set `DLOCALIZE=OFF`. To do this, go to _Project -> CMake Settings_, scroll to
the bottom where `"windows-tiles-sounds-x64-msvc"` is defined, and under `"cacheVariables"` change
the value from `"LOCALIZE": "True"` to `"LOCALIZE": "OFF"`.

- Note: doing this will change the `CMakePresets.json` file which is tracked by source control. Do
not commit this change.

## Terminal

Run the command
* `cmake --list-presets`<br/>
It will show the presets available to you.
The list changes based on the environment you are in.
If empty, the environment is not supported.

- `cmake --list-presets`<br/> It will show the presets available to you. The list changes based on
the environment you are in. If empty, the environment is not supported.

Run the command
* `cmake --preset <preset>`

If you do not have `msgfmt` available, or do not want to include translations with the build, you need to additionally pass `-DLOCALIZE=OFF`.

* `cmake --preset <preset> -DLOCALIZE=OFF`


- `cmake --preset <preset>`

If you do not have `msgfmt` available, or do not want to include translations with the build, you
need to additionally pass `-DLOCALIZE=OFF`.

- `cmake --preset <preset> -DLOCALIZE=OFF`

# 3 Build

## Visual Studio
From the Standard toolbar's _Build Preset_ drop-down menu select the build preset.<br/>
From the main menu, select _Build -> Build All_

From the Standard toolbar's _Build Preset_ drop-down menu select the build preset.<br/> From the
main menu, select _Build -> Build All_

## Terminal

Run the command
* `cmake --build --preset <preset>`

- `cmake --build --preset <preset>`

# 4 Install

## Visual Studio

From the main menu, select _Build -> Install CataclysmDDA_

## Terminal

Run the command
* `cmake --install out/build/<preset>/ --config RelWithDebInfo`

- `cmake --install out/build/<preset>/ --config RelWithDebInfo`

# 5 Run

## Visual Studio
From the Standard toolbar's _Select Startup Item..._ drop-down menu select `cataclysm-tiles.exe (Install)` <br/>
The _Project Configuration_ drop-down menu will show `RelWithDebInfo`.<br/>
You can now _Start Without Debugging_ (default Ctrl+F5) or _Debug -> Start Debugging_ (default F5).
## Visual Studio

From the Standard toolbar's _Select Startup Item..._ drop-down menu select
`cataclysm-tiles.exe (Install)` <br/> The _Project Configuration_ drop-down menu will show
`RelWithDebInfo`.<br/> You can now _Start Without Debugging_ (default Ctrl+F5) or _Debug -> Start
Debugging_ (default F5).

## Terminal

Run the commands

## Terminal
Run the commands
* `cd out/install/<preset>/`
* `cataclysm` or `cataclysm-tiles.exe`
- `cd out/install/<preset>/`
- `cataclysm` or `cataclysm-tiles.exe`
Loading

0 comments on commit 612a047

Please sign in to comment.