Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions .cmake-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# options affecting formatting
format:
# how wide to allow formatted cmake files
line_width: 100
# how many spaces to tab for indent
tab_size: 4
# if true, separate flow control names from their parentheses
separate_ctrl_name_with_space: true # currently ignored by cmake-lint
# if true, separate function names from parentheses with a
separate_fn_name_with_space: false # currently ignored by cmake-lint
# if a statement is wrapped to more than one line, than dangle
# the closing parenthesis on its own line.
dangle_parens: false # currently ignored by cmake-lint
# Format command names consistently as 'lower' or 'upper' case
# 'canonical': like in official documentation
command_case: 'canonical' # currently ignored by cmake-lint
# Format keywords consistently as 'lower' or 'upper' case
keyword_case: 'upper' # currently ignored by cmake-lint
# options affecting comment reflow and formatting
markup:
# enable comment markup parsing and reflow
enable_markup: false
# options affecting linter
lint:
# list of lint codes to disable
# C0113: Missing COMMENT in statement which allows it
disabled_codes: ['C0113']
# regular expression pattern describing valid function names
function_pattern: '[a-z_]+'
# regular expression pattern describing valid names for private variables
# WEIRD: strangely named "directory variable name" in lint output
private_var_pattern: '_[0-9A-Z_]+'
# regular expression pattern describing valid names for public variables (strangely named "directories"?)
# WEIRD: strangely named "directory variable name" in lint output
public_var_pattern: '[0-9A-Z]+'
# regular expression pattern describing valid macro names
macro_pattern: '[a-z_]+'
# regular expression pattern describing valid names for function/macro
# arguments and loop variables
argument_var_pattern: '[A-Z][A-Z0-9_]+'
# require no more than this many newlines between statements
max_statement_spacing: 2

31 changes: 31 additions & 0 deletions .github/workflows/cmake-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: cmake-format linting

on:
push:
branches:
- master
paths:
- '**/CMakeLists.txt'
- '**.cmake'
- '**.cmake.in'
pull_request:
branches:
- master
paths:
- '**/CMakeLists.txt'
- '**.cmake'
- '**.cmake.in'

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install cmakelang
run: python3 -m pip install -U cmakelang
- name: run cmake-lint
run: python3 -m cmakelang.lint CMakeLists.txt src/CMakeLists.txt data/CMakeLists.txt lang/CMakeLists.txt src/chkjson/CMakeLists.txt tools/format/CMakeLists.txt tools/clang-tidy-plugin/CMakeLists.txt cmake_uninstall.cmake.in -c .cmake-format.yml

46 changes: 29 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ option(LIBBACKTRACE "Print backtrace with libbacktrace." "OFF")
option(USE_HOME_DIR "Use user's home directory for save files." "ON")
option(LOCALIZE "Support for language localizations. Also enable UTF support." "ON")
option(LANGUAGES "Compile localization files for specified languages." "")
option(DYNAMIC_LINKING "Use dynamic linking. Or use static to remove MinGW dependency instead." "ON")
option(DYNAMIC_LINKING
"Use dynamic linking. Or use static to remove MinGW dependency instead." "ON")
option(JSON_FORMAT "Build JSON formatter" "OFF")
option(CATA_CCACHE "Try to find and build with ccache" "ON")
option(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy plugin" "OFF")
set(CATA_CLANG_TIDY_INCLUDE_DIR "" CACHE STRING "Path to internal clang-tidy headers required for plugin (e.g. ClangTidy.h)")
set(CATA_CLANG_TIDY_INCLUDE_DIR "" CACHE STRING
"Path to internal clang-tidy headers required for plugin (e.g. ClangTidy.h)")
set(CATA_CHECK_CLANG_TIDY "" CACHE STRING "Path to check_clang_tidy.py for plugin tests")
set(GIT_BINARY "" CACHE STRING "Git binary name or path.")
set(PREFIX "" CACHE STRING "Location of Data & GFX directories")
Expand Down Expand Up @@ -166,7 +168,8 @@ if (CMAKE_BUILD_TYPE STREQUAL Debug)
# Since CataclysmDDA does not respect PREFIX for development builds
# and has funny path handlers, we should create resulting Binaries
# in the source directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} CACHE PATH "Single Directory for all Executables.")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} CACHE PATH
"Single Directory for all Executables.")
set(BIN_PREFIX ${CMAKE_SOURCE_DIR})
else ()
message(STATUS "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}")
Expand Down Expand Up @@ -234,8 +237,8 @@ set(CMAKE_CXX_STANDARD 14)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
"This project requires an out of source build. \
Remove the file 'CMakeCache.txt' found in this directory before continuing, create a separate \
build directory and run 'cmake [options] <srcs>' from there. \
Remove the file 'CMakeCache.txt' found in this directory before continuing, \
create a separate build directory and run 'cmake [options] <srcs>' from there. \
See INSTALL file for details and more info.")
endif ()

Expand All @@ -250,8 +253,9 @@ if (TILES)
find_package(SDL2)
if (NOT SDL2_FOUND)
message(FATAL_ERROR
"This project requires SDL2 to be installed to be compiled in graphical mode. \
Please install the SDL2 development libraries, or try compiling without the -DTILES=1 for a text only compilation. \
"This project requires SDL2 to be installed to compile in graphical mode. \
Please install the SDL2 development libraries, \
or try compiling without the -DTILES=1 for a text only compilation. \
See INSTALL file for details and more info.")
endif ()

Expand All @@ -269,16 +273,18 @@ if (TILES)
find_package(SDL2_ttf)
if (NOT SDL2_TTF_FOUND)
message(FATAL_ERROR
"This project requires SDL2_ttf to be installed to be compiled in graphical mode. \
Please install the SDL2_ttf development libraries, or try compiling without the -DTILES=1 for a text only compilation. \
"This project requires SDL2_ttf to be installed to compile in graphical mode. \
Please install the SDL2_ttf development libraries, \
or try compiling without the -DTILES=1 for a text only compilation. \
See INSTALL file for details and more info.")
endif ()

message(STATUS "Searching for SDL2_image library --")
find_package(SDL2_image)
if (NOT SDL2_IMAGE_FOUND)
message(FATAL_ERROR
"This project requires SDL2_image to be installed to be compiled in graphical mode. Please install the SDL2_image development libraries, \
"This project requires SDL2_image to be installed to compile in graphical mode. \
Please install the SDL2_image development libraries, \
or try compiling without the -DTILES=1 for a text only compilation. \
See INSTALL file for details and more info.")
endif ()
Expand All @@ -293,7 +299,8 @@ if (CURSES)
find_package(Curses)
if (NOT CURSES_FOUND)
message(FATAL_ERROR
"This project requires ncurses to be installed to be compiled in text only mode. Please install the ncurses development libraries, \
"This project requires ncurses to be installed to be compiled in text only mode. \
Please install the ncurses development libraries, \
or try compiling with the -DTILES=1 for a graphical compilation. \
See INSTALL file for details and more info")
endif ()
Expand All @@ -303,7 +310,8 @@ if (SOUND)
# You need TILES to be able to use SOUND
if (NOT TILES)
message(FATAL_ERROR
"You must enable graphical support with -DTILES=1 to be able to enable sound support. \
"You must enable graphical support with -DTILES=1 \
to be able to enable sound support. \
See INSTALL file for details and more info.")
endif ()

Expand All @@ -312,7 +320,8 @@ if (SOUND)
find_package(SDL2_mixer)
if (NOT SDL2_MIXER_FOUND)
message(FATAL_ERROR
"You need the SDL2_mixer development library to be able to compile with sound enabled. \
"You need the SDL2_mixer development library \
to be able to compile with sound enabled. \
See INSTALL file for details and more info.")
endif ()
endif ()
Expand All @@ -330,14 +339,16 @@ if (LOCALIZE)
find_package(Libintl)
if (NOT LIBINTL_FOUND)
message(FATAL_ERROR
"You need the libintl development library to be able to compile with Localize support. \
"You need the libintl development library \
to be able to compile with Localize support. \
See INSTALL file for details and more info.")
endif ()
find_package(Iconv)
if (NOT ICONV_FOUND)
message(FATAL_ERROr
"You need the iconv development library to be able to compile with Localize support. \
See INSTALL file for details and more info.")
message(FATAL_ERROR
"You need the iconv development library \
to be able to compile with Localize support. \
See INSTALL file for details and more info.")
endif ()
endif ()
add_subdirectory(lang)
Expand Down Expand Up @@ -375,3 +386,4 @@ if (CCACHE_FOUND AND CATA_CCACHE)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif ()

43 changes: 22 additions & 21 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR
"Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif ()

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" FILE_LIST)
string(REGEX REPLACE "\n" ";" FILE_LIST "${FILE_LIST}")
foreach (FILE_NAME ${FILE_LIST})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${FILE_NAME}\"")
if (EXISTS "$ENV{DESTDIR}${FILE_NAME}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${FILE_NAME}\""
OUTPUT_VARIABLE RM_OUT
RETURN_VALUE RM_RETVAL)
if ("${RM_RETVAL}" STREQUAL 0)
else ()
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${FILE_NAME}\"")
endif ()
else ()
message(STATUS "File \"$ENV{DESTDIR}${FILE_NAME}\" does not exist.")
endif ()
endforeach ()

FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
IF(EXISTS "$ENV{DESTDIR}${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF("${rm_retval}" STREQUAL 0)
ELSE("${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF("${rm_retval}" STREQUAL 0)
ELSE(EXISTS "$ENV{DESTDIR}${file}")
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
ENDFOREACH(file)
6 changes: 4 additions & 2 deletions lang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ foreach (LANG ${LANGUAGES})
add_custom_command(
TARGET translations_prepare
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES
COMMAND ${CMAKE_COMMAND} -E
make_directory ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
if (${LANG} STREQUAL en)
# English is special: we do not actually need translation for English, but
Expand All @@ -71,7 +72,8 @@ foreach (LANG ${LANGUAGES})
TARGET translations_prepare
PRE_BUILD
COMMAND lang/update_pot.sh
COMMAND msgen ${CMAKE_SOURCE_DIR}/lang/po/cataclysm-dda.pot --output-file=${CMAKE_SOURCE_DIR}/lang/po/en.po
COMMAND msgen ${CMAKE_SOURCE_DIR}/lang/po/cataclysm-dda.pot
--output-file=${CMAKE_SOURCE_DIR}/lang/po/en.po
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif ()
add_custom_command(
Expand Down
4 changes: 2 additions & 2 deletions src/chkjson/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/chkjson)

# Add the actual executable
if (WIN32)
add_executable(chkjson WIN32 EXCLUDE_FROM_ALL ${CHKJSON_SOURCES} ${CHKJSON_HEADERS})
add_executable(chkjson WIN32 EXCLUDE_FROM_ALL ${CHKJSON_SOURCES} ${CHKJSON_HEADERS})
else ()
add_executable(chkjson EXCLUDE_FROM_ALL ${CHKJSON_SOURCES} ${CHKJSON_HEADERS})
add_executable(chkjson EXCLUDE_FROM_ALL ${CHKJSON_SOURCES} ${CHKJSON_HEADERS})
endif ()
8 changes: 4 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ cmake_minimum_required(VERSION 3.1.4)

if (BUILD_TESTING)
file(GLOB CATACLYSM_DDA_TEST_SOURCES
${CMAKE_SOURCE_DIR}/tests/*.cpp)
${CMAKE_SOURCE_DIR}/tests/*.cpp)

# Enabling benchmarks
add_definitions(-DCATCH_CONFIG_ENABLE_BENCHMARKING)

if (TILES)
add_executable(cata_test-tiles ${CATACLYSM_DDA_TEST_SOURCES})
target_link_libraries(cata_test-tiles cataclysm-tiles-common)
add_test(NAME test-tiles
add_executable(cata_test-tiles ${CATACLYSM_DDA_TEST_SOURCES})
target_link_libraries(cata_test-tiles cataclysm-tiles-common)
add_test(NAME test-tiles
COMMAND sh -c
"$<TARGET_FILE:cata_test-tiles> -r cata --rng-seed `shuf -i 0-1000000000 -n 1`"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
Expand Down
Loading