diff --git a/CMakeLists.txt b/CMakeLists.txt index 672c9cf8d9335..bd7b4a6c2bff0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,12 +27,16 @@ 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 checks as a plugin" "OFF") option(CATA_CLANG_TIDY_EXECUTABLE "Build Cata's custom clang-tidy checks as an executable" "OFF") +option(TESTS "Compile Cata's tests" "ON") 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(GETTEXT_MSGFMT_BINARY "" CACHE FILEPATH "msgfmt binary name or path.") +if (TESTS) include(CTest) +endif() message(STATUS "${PROJECT} build environment --") message(STATUS "Build realm is: ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}") @@ -51,6 +55,19 @@ if (NOT "${GIT_VERSION}" MATCHES "GIT-NOTFOUND") "// NOLINT(cata-header-guard)\n\#define VERSION \"${GIT_VERSION}\"\n") message(STATUS "${PROJECT_NAME} build version is: ${GIT_VERSION}") add_definitions(-DGIT_VERSION) + + # get_git_head_revision() does not work with worktrees in Windows + 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 "\ +build type: ${BUILD_PRESET_NAME}\n\ +build number: ${_timestamp}\n\ +commit sha: ${_sha1}\n\ +commit url: https://github.com/CleverRaven/Cataclysm-DDA/commit/${_sha1}" + ) endif () #OS Check Placeholders. Will be used for BINDIST @@ -143,7 +160,8 @@ message(STATUS "${PROJECT_NAME} build options --") # Preset variables if (NOT LANGUAGES) - set(LANGUAGES de es_AR es_ES fr it_IT ja ko pt_BR ru zh_CN zh_TW) + set(LANGUAGES ar cs da de el es_AR es_ES fil_PH fr ga_IE hu id is it_IT ja ko nb nl pl pt_BR ro + ru sr tr uk_UA zh_CN zh_TW) endif () if (GIT_BINARY) @@ -287,8 +305,12 @@ if (TILES) endif () message(STATUS "Searching for SDL2_TTF library --") - find_package(SDL2_ttf) - if (NOT (SDL2_TTF_FOUND OR TARGET SDL2_ttf::SDL2_ttf OR TARGET SDL2_ttf::SDL2_ttf-static)) + if (NOT VCPKG_MANIFEST_MODE) + find_package(SDL2_ttf) + else() + find_package(sdl2-ttf) + 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 compile in graphical mode. \ Please install the SDL2_ttf development libraries, \ @@ -340,22 +362,25 @@ if (SOUND) endif () # Sound requires SDL_mixer library - message(STATUS "Searching for SDL2_mixer library --") - find_package(SDL2_mixer) if(VCPKG_MANIFEST_MODE) - if (NOT TARGET SDL2_mixer::SDL2_mixer-static) # TODO x64-mingw-static + message(STATUS "Searching for sdl2-mixer library --") + find_package(sdl2-mixer) + if (NOT TARGET SDL2::SDL2_mixer) message(FATAL_ERROR - "You need the SDL2_mixer development library \ + "You need the sdl2-mixer development library \ to be able to compile with sound enabled. \ See doc/COMPILING/COMPILING-CMAKE.md for details and more info.") 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 "You need the SDL2_mixer development library \ to be able to compile with sound enabled. \ See doc/COMPILING/COMPILING-CMAKE.md for details and more info.") - endif () + endif() endif() endif () @@ -366,6 +391,17 @@ if (BACKTRACE) endif () endif () +if ((LOCALIZE OR BUILD_TESTING) AND "${GETTEXT_MSGFMT_BINARY}" STREQUAL "") + if(MSVC) + list(APPEND Gettext_ROOT C:\\msys64\\usr) + list(APPEND Gettext_ROOT C:\\Program\ Files\\Git\\usr) + endif(MSVC) + find_package(Gettext) +endif () +if (NOT GETTEXT_MSGFMT_EXECUTABLE ) + set(GETTEXT_MSGFMT_EXECUTABLE "${GETTEXT_MSGFMT_BINARY}") +endif() + # Ok. Now create build and install recipes if (LOCALIZE) add_subdirectory(lang) @@ -389,7 +425,11 @@ add_subdirectory(data) if (NOT MSVC) add_subdirectory(src/chkjson) endif() -add_subdirectory(tests) + +if(TESTS) + add_subdirectory(tests) +endif() + if (JSON_FORMAT) add_subdirectory(tools/format) endif() @@ -397,6 +437,22 @@ if (CATA_CLANG_TIDY_PLUGIN OR CATA_CLANG_TIDY_EXECUTABLE) add_subdirectory(tools/clang-tidy-plugin) endif() +install(DIRECTORY doc gfx + DESTINATION . +) + +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 .) + if (TILES) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION .) + endif() +endif() + configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" diff --git a/CMakeModules/CMakeParseArguments.cmake b/CMakeModules/CMakeParseArguments.cmake deleted file mode 100644 index 4248176ad6648..0000000000000 --- a/CMakeModules/CMakeParseArguments.cmake +++ /dev/null @@ -1,160 +0,0 @@ -#.rst: -# CMakeParseArguments -# ------------------- -# -# -# -# CMAKE_PARSE_ARGUMENTS( -# args...) -# -# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions -# for parsing the arguments given to that macro or function. It -# processes the arguments and defines a set of variables which hold the -# values of the respective options. -# -# The argument contains all options for the respective macro, -# i.e. keywords which can be used when calling the macro without any -# value following, like e.g. the OPTIONAL keyword of the install() -# command. -# -# The argument contains all keywords for this macro -# which are followed by one value, like e.g. DESTINATION keyword of the -# install() command. -# -# The argument contains all keywords for this -# macro which can be followed by more than one value, like e.g. the -# TARGETS or FILES keywords of the install() command. -# -# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the -# keywords listed in , and -# a variable composed of the given -# followed by "_" and the name of the respective keyword. These -# variables will then hold the respective value from the argument list. -# For the keywords this will be TRUE or FALSE. -# -# All remaining arguments are collected in a variable -# _UNPARSED_ARGUMENTS, this can be checked afterwards to see -# whether your macro was called with unrecognized parameters. -# -# As an example here a my_install() macro, which takes similar arguments -# as the real install() command: -# -# :: -# -# function(MY_INSTALL) -# set(options OPTIONAL FAST) -# set(oneValueArgs DESTINATION RENAME) -# set(multiValueArgs TARGETS CONFIGURATIONS) -# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) -# ... -# -# -# -# Assume my_install() has been called like this: -# -# :: -# -# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) -# -# -# -# After the cmake_parse_arguments() call the macro will have set the -# following variables: -# -# :: -# -# MY_INSTALL_OPTIONAL = TRUE -# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() -# MY_INSTALL_DESTINATION = "bin" -# MY_INSTALL_RENAME = "" (was not used) -# MY_INSTALL_TARGETS = "foo;bar" -# MY_INSTALL_CONFIGURATIONS = "" (was not used) -# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" -# -# -# -# You can then continue and process these variables. -# -# Keywords terminate lists of values, e.g. if directly after a -# one_value_keyword another recognized keyword follows, this is -# interpreted as the beginning of the new option. E.g. -# my_install(TARGETS foo DESTINATION OPTIONAL) would result in -# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION -# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. - -#============================================================================= -# Copyright 2010 Alexander Neundorf -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - - -if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) - return() -endif() -set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) - - -function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) - # first set all result variables to empty/FALSE - foreach(arg_name ${_singleArgNames} ${_multiArgNames}) - set(${prefix}_${arg_name}) - endforeach() - - foreach(option ${_optionNames}) - set(${prefix}_${option} FALSE) - endforeach() - - set(${prefix}_UNPARSED_ARGUMENTS) - - set(insideValues FALSE) - set(currentArgName) - - # now iterate over all arguments and fill the result variables - foreach(currentArg ${ARGN}) - list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword - list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword - - if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) - if(insideValues) - if("${insideValues}" STREQUAL "SINGLE") - set(${prefix}_${currentArgName} ${currentArg}) - set(insideValues FALSE) - elseif("${insideValues}" STREQUAL "MULTI") - list(APPEND ${prefix}_${currentArgName} ${currentArg}) - endif() - else() - list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) - endif() - else() - if(NOT ${optionIndex} EQUAL -1) - set(${prefix}_${currentArg} TRUE) - set(insideValues FALSE) - elseif(NOT ${singleArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "SINGLE") - elseif(NOT ${multiArgIndex} EQUAL -1) - set(currentArgName ${currentArg}) - set(${prefix}_${currentArgName}) - set(insideValues "MULTI") - endif() - endif() - - endforeach() - - # propagate the result variables to the caller: - foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) - set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) - endforeach() - set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) - -endfunction() diff --git a/CMakeModules/CMakePushCheckState.cmake b/CMakeModules/CMakePushCheckState.cmake deleted file mode 100644 index cc5a93e24c472..0000000000000 --- a/CMakeModules/CMakePushCheckState.cmake +++ /dev/null @@ -1,120 +0,0 @@ -#============================================================================= -# Copyright 2000-2022 Kitware, Inc. and Contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Kitware, Inc. nor the names of Contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#============================================================================= - -#[=======================================================================[.rst: -CMakePushCheckState -------------------- - - - -This module defines three macros: ``CMAKE_PUSH_CHECK_STATE()`` -``CMAKE_POP_CHECK_STATE()`` and ``CMAKE_RESET_CHECK_STATE()`` These macros can -be used to save, restore and reset (i.e., clear contents) the state of -the variables ``CMAKE_REQUIRED_FLAGS``, ``CMAKE_REQUIRED_DEFINITIONS``, -``CMAKE_REQUIRED_LINK_OPTIONS``, ``CMAKE_REQUIRED_LIBRARIES``, -``CMAKE_REQUIRED_INCLUDES`` and ``CMAKE_EXTRA_INCLUDE_FILES`` used by the -various Check-files coming with CMake, like e.g. ``check_function_exists()`` -etc. -The variable contents are pushed on a stack, pushing multiple times is -supported. This is useful e.g. when executing such tests in a Find-module, -where they have to be set, but after the Find-module has been executed they -should have the same value as they had before. - -``CMAKE_PUSH_CHECK_STATE()`` macro receives optional argument ``RESET``. -Whether it's specified, ``CMAKE_PUSH_CHECK_STATE()`` will set all -``CMAKE_REQUIRED_*`` variables to empty values, same as -``CMAKE_RESET_CHECK_STATE()`` call will do. - -Usage: - -.. code-block:: cmake - - cmake_push_check_state(RESET) - set(CMAKE_REQUIRED_DEFINITIONS -DSOME_MORE_DEF) - check_function_exists(...) - cmake_reset_check_state() - set(CMAKE_REQUIRED_DEFINITIONS -DANOTHER_DEF) - check_function_exists(...) - cmake_pop_check_state() -#]=======================================================================] - -macro(CMAKE_RESET_CHECK_STATE) - - set(CMAKE_EXTRA_INCLUDE_FILES) - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_DEFINITIONS) - set(CMAKE_REQUIRED_LINK_OPTIONS) - set(CMAKE_REQUIRED_LIBRARIES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_QUIET) - -endmacro() - -macro(CMAKE_PUSH_CHECK_STATE) - - if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) - set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) - endif() - - math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") - - set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES}) - set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) - set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) - set(_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LINK_OPTIONS}) - set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) - set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) - set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) - - if (${ARGC} GREATER 0 AND "${ARGV0}" STREQUAL "RESET") - cmake_reset_check_state() - endif() - -endmacro() - -macro(CMAKE_POP_CHECK_STATE) - -# don't pop more than we pushed - if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") - - set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_LINK_OPTIONS ${_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - - math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") - endif() - -endmacro() diff --git a/CMakeModules/CheckLibraryExists.cmake b/CMakeModules/CheckLibraryExists.cmake deleted file mode 100644 index 67d1b47dd2af8..0000000000000 --- a/CMakeModules/CheckLibraryExists.cmake +++ /dev/null @@ -1,78 +0,0 @@ -#.rst: -# CheckLibraryExists -# ------------------ -# -# Check if the function exists. -# -# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE) -# -# :: -# -# LIBRARY - the name of the library you are looking for -# FUNCTION - the name of the function -# LOCATION - location where the library should be found -# VARIABLE - variable to store the result -# -# -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# :: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -#============================================================================= -# Copyright 2002-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - - - -macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) - if(${VARIABLE} MATCHES "^${VARIABLE}$") - set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION - "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}") - set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY}) - if(CMAKE_REQUIRED_LIBRARIES) - set(CHECK_LIBRARY_EXISTS_LIBRARIES - ${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES}) - endif() - try_compile(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/CheckFunctionExists.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES} - CMAKE_FLAGS - -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION} - -DLINK_DIRECTORIES:STRING=${LOCATION} - OUTPUT_VARIABLE OUTPUT) - - if(${VARIABLE}) - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found") - set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " - "passed with the following output:\n" - "${OUTPUT}\n\n") - else() - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found") - set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " - "failed with the following output:\n" - "${OUTPUT}\n\n") - endif() - endif() -endmacro() diff --git a/CMakeModules/FindCurses.cmake b/CMakeModules/FindCurses.cmake deleted file mode 100644 index dbd252bba695f..0000000000000 --- a/CMakeModules/FindCurses.cmake +++ /dev/null @@ -1,305 +0,0 @@ -#============================================================================= -# Copyright 2000-2022 Kitware, Inc. and Contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Kitware, Inc. nor the names of Contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#============================================================================= - -#[=======================================================================[.rst: -FindCurses ----------- - -Find the curses or ncurses include file and library. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -``CURSES_FOUND`` - True if Curses is found. -``CURSES_INCLUDE_DIRS`` - The include directories needed to use Curses. -``CURSES_LIBRARIES`` - The libraries needed to use Curses. -``CURSES_CFLAGS`` - .. versionadded:: 3.16 - - Parameters which ought be given to C/C++ compilers when using Curses. -``CURSES_HAVE_CURSES_H`` - True if curses.h is available. -``CURSES_HAVE_NCURSES_H`` - True if ncurses.h is available. -``CURSES_HAVE_NCURSES_NCURSES_H`` - True if ``ncurses/ncurses.h`` is available. -``CURSES_HAVE_NCURSES_CURSES_H`` - True if ``ncurses/curses.h`` is available. - -Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the -``find_package(Curses)`` call if NCurses functionality is required. - -.. versionadded:: 3.10 - Set ``CURSES_NEED_WIDE`` to ``TRUE`` before the - ``find_package(Curses)`` call if unicode functionality is required. - -Backward Compatibility -^^^^^^^^^^^^^^^^^^^^^^ - -The following variable are provided for backward compatibility: - -``CURSES_INCLUDE_DIR`` - Path to Curses include. Use ``CURSES_INCLUDE_DIRS`` instead. -``CURSES_LIBRARY`` - Path to Curses library. Use ``CURSES_LIBRARIES`` instead. -#]=======================================================================] - -include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) - -# we don't know anything about cursesw, so only ncurses -# may be ncursesw -if(NOT CURSES_NEED_WIDE) - set(NCURSES_LIBRARY_NAME "ncurses") - set(CURSES_FORM_LIBRARY_NAME "form") -else() - set(NCURSES_LIBRARY_NAME "ncursesw") - set(CURSES_FORM_LIBRARY_NAME "formw") - # Also, if we are searching for wide curses - we are actually searching - # for ncurses, we don't know about any other unicode version. - set(CURSES_NEED_NCURSES TRUE) -endif() - -find_library(CURSES_CURSES_LIBRARY NAMES curses) - -find_library(CURSES_NCURSES_LIBRARY NAMES "${NCURSES_LIBRARY_NAME}" ) -set(CURSES_USE_NCURSES FALSE) - -if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES)) - set(CURSES_USE_NCURSES TRUE) -endif() -# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html -# cygwin ncurses stopped providing curses.h symlinks see above -# message. Cygwin is an ncurses package, so force ncurses on -# cygwin if the curses.h is missing -if(CURSES_NCURSES_LIBRARY AND CYGWIN) - if (CURSES_NEED_WIDE) - if(NOT EXISTS /usr/include/ncursesw/curses.h) - set(CURSES_USE_NCURSES TRUE) - endif() - else() - if(NOT EXISTS /usr/include/curses.h) - set(CURSES_USE_NCURSES TRUE) - endif() - endif() -endif() - - -# Not sure the logic is correct here. -# If NCurses is required, use the function wsyncup() to check if the library -# has NCurses functionality (at least this is where it breaks on NetBSD). -# If wsyncup is in curses, use this one. -# If not, try to find ncurses and check if this has the symbol. -# Once the ncurses library is found, search the ncurses.h header first, but -# some web pages also say that even with ncurses there is not always a ncurses.h: -# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html -# So at first try ncurses.h, if not found, try to find curses.h under the same -# prefix as the library was found, if still not found, try curses.h with the -# default search paths. -if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) - include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) - cmake_push_check_state() - set(CMAKE_REQUIRED_QUIET ${Curses_FIND_QUIETLY}) - CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}" - wsyncup "" CURSES_CURSES_HAS_WSYNCUP) - - if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP) - CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" - wsyncup "" CURSES_NCURSES_HAS_WSYNCUP) - if( CURSES_NCURSES_HAS_WSYNCUP) - set(CURSES_USE_NCURSES TRUE) - endif() - endif() - cmake_pop_check_state() - -endif() - -if(CURSES_USE_NCURSES) - get_filename_component(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH) - get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH) - - # Use CURSES_NCURSES_INCLUDE_PATH if set, for compatibility. - if(CURSES_NCURSES_INCLUDE_PATH) - if (CURSES_NEED_WIDE) - find_path(CURSES_INCLUDE_PATH - NAMES ncursesw/ncurses.h ncursesw/curses.h ncursesw.h cursesw.h - PATHS ${CURSES_NCURSES_INCLUDE_PATH} - NO_DEFAULT_PATH - ) - else() - find_path(CURSES_INCLUDE_PATH - NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h - PATHS ${CURSES_NCURSES_INCLUDE_PATH} - NO_DEFAULT_PATH - ) - endif() - endif() - - if (CURSES_NEED_WIDE) - set(CURSES_TINFO_LIBRARY_NAME tinfow) - find_path(CURSES_INCLUDE_PATH - NAMES ncursesw/ncurses.h ncursesw/curses.h ncursesw.h cursesw.h - HINTS "${_cursesParentDir}/include" - ) - else() - set(CURSES_TINFO_LIBRARY_NAME tinfo) - find_path(CURSES_INCLUDE_PATH - NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h - HINTS "${_cursesParentDir}/include" - ) - endif() - - # Previous versions of FindCurses provided these values. - if(NOT DEFINED CURSES_LIBRARY) - set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}") - endif() - - CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" - cbreak "" CURSES_NCURSES_HAS_CBREAK) - CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" - nodelay "" CURSES_NCURSES_HAS_NODELAY) - if(NOT CURSES_NCURSES_HAS_CBREAK OR NOT CURSES_NCURSES_HAS_NODELAY) - find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" HINTS "${_cursesLibDir}") - find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" ) - - mark_as_advanced( - CURSES_EXTRA_LIBRARY - ) - endif() -else() - get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH) - get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH) - - #We can't find anything with CURSES_NEED_WIDE because we know - #only about ncursesw unicode curses version - if(NOT CURSES_NEED_WIDE) - find_path(CURSES_INCLUDE_PATH - NAMES curses.h - HINTS "${_cursesParentDir}/include" - ) - endif() - - # Previous versions of FindCurses provided these values. - if(NOT DEFINED CURSES_CURSES_H_PATH) - set(CURSES_CURSES_H_PATH "${CURSES_INCLUDE_PATH}") - endif() - if(NOT DEFINED CURSES_LIBRARY) - set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}") - endif() -endif() - -# Report whether each possible header name exists in the include directory. -if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H) - if(CURSES_NEED_WIDE) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h") - set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h") - endif() - elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h") - set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h") - endif() - if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H) - set(CURSES_HAVE_NCURSES_NCURSES_H "CURSES_HAVE_NCURSES_NCURSES_H-NOTFOUND") - endif() -endif() -if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H) - if(CURSES_NEED_WIDE) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/curses.h") - set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/curses.h") - endif() - elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/curses.h") - set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncurses/curses.h") - endif() - if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H) - set(CURSES_HAVE_NCURSES_CURSES_H "CURSES_HAVE_NCURSES_CURSES_H-NOTFOUND") - endif() -endif() -if(NOT CURSES_NEED_WIDE) - #ncursesw can't be found for this paths - if(NOT DEFINED CURSES_HAVE_NCURSES_H) - if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h") - set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h") - else() - set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND") - endif() - endif() - if(NOT DEFINED CURSES_HAVE_CURSES_H) - if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h") - set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h") - else() - set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND") - endif() - endif() -endif() - -find_library(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" HINTS "${_cursesLibDir}") -find_library(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" ) - -# Previous versions of FindCurses provided these values. -if(NOT DEFINED FORM_LIBRARY) - set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}") -endif() - -# Need to provide the *_LIBRARIES -set(CURSES_LIBRARIES ${CURSES_LIBRARY}) - -if(CURSES_EXTRA_LIBRARY) - set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY}) -endif() - -if(CURSES_FORM_LIBRARY) - set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY}) -endif() - -# Provide the *_INCLUDE_DIRS and *_CFLAGS results. -set(CURSES_INCLUDE_DIRS ${CURSES_INCLUDE_PATH}) -set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # compatibility - -find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) - pkg_check_modules(NCURSES QUIET ${NCURSES_LIBRARY_NAME}) - set(CURSES_CFLAGS ${NCURSES_CFLAGS_OTHER}) -endif() - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG - CURSES_LIBRARY CURSES_INCLUDE_PATH) - -mark_as_advanced( - CURSES_INCLUDE_PATH - CURSES_CURSES_LIBRARY - CURSES_NCURSES_LIBRARY - CURSES_FORM_LIBRARY - ) diff --git a/CMakeModules/FindPackageHandleStandardArgs.cmake b/CMakeModules/FindPackageHandleStandardArgs.cmake deleted file mode 100644 index d03041852de88..0000000000000 --- a/CMakeModules/FindPackageHandleStandardArgs.cmake +++ /dev/null @@ -1,351 +0,0 @@ -#.rst: -# FindPackageHandleStandardArgs -# ----------------------------- -# -# -# -# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... ) -# -# This function is intended to be used in FindXXX.cmake modules files. -# It handles the REQUIRED, QUIET and version-related arguments to -# find_package(). It also sets the _FOUND variable. The -# package is considered found if all variables ... listed contain -# valid results, e.g. valid filepaths. -# -# There are two modes of this function. The first argument in both -# modes is the name of the Find-module where it is called (in original -# casing). -# -# The first simple mode looks like this: -# -# :: -# -# FIND_PACKAGE_HANDLE_STANDARD_ARGS( (DEFAULT_MSG|"Custom failure message") ... ) -# -# If the variables to are all valid, then -# _FOUND will be set to TRUE. If DEFAULT_MSG is given -# as second argument, then the function will generate itself useful -# success and error messages. You can also supply a custom error -# message for the failure case. This is not recommended. -# -# The second mode is more powerful and also supports version checking: -# -# :: -# -# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [FOUND_VAR ] -# [REQUIRED_VARS ...] -# [VERSION_VAR ] -# [HANDLE_COMPONENTS] -# [CONFIG_MODE] -# [FAIL_MESSAGE "Custom failure message"] ) -# -# -# -# In this mode, the name of the result-variable can be set either to -# either _FOUND or _FOUND using the -# FOUND_VAR option. Other names for the result-variable are not -# allowed. So for a Find-module named FindFooBar.cmake, the two -# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended -# to use the original case version. If the FOUND_VAR option is not -# used, the default is _FOUND. -# -# As in the simple mode, if through are all valid, -# _FOUND will be set to TRUE. After REQUIRED_VARS the -# variables which are required for this package are listed. Following -# VERSION_VAR the name of the variable can be specified which holds the -# version of the package which has been found. If this is done, this -# version will be checked against the (potentially) specified required -# version used in the find_package() call. The EXACT keyword is also -# handled. The default messages include information about the required -# version and the version which has been actually found, both if the -# version is ok or not. If the package supports components, use the -# HANDLE_COMPONENTS option to enable handling them. In this case, -# find_package_handle_standard_args() will report which components have -# been found and which are missing, and the _FOUND variable -# will be set to FALSE if any of the required components (i.e. not the -# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option -# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a -# find_package(... NO_MODULE) call. In this case VERSION_VAR will be -# set to _VERSION and the macro will automatically check whether -# the Config module was found. Via FAIL_MESSAGE a custom failure -# message can be specified, if this is not used, the default message -# will be displayed. -# -# Example for mode 1: -# -# :: -# -# find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) -# -# -# -# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and -# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to -# TRUE. If it is not found and REQUIRED was used, it fails with -# FATAL_ERROR, independent whether QUIET was used or not. If it is -# found, success will be reported, including the content of . On -# repeated Cmake runs, the same message won't be printed again. -# -# Example for mode 2: -# -# :: -# -# find_package_handle_standard_args(LibXslt FOUND_VAR LibXslt_FOUND -# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS -# VERSION_VAR LibXslt_VERSION_STRING) -# -# In this case, LibXslt is considered to be found if the variable(s) -# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and -# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in -# LibXslt_FOUND . Also the version of LibXslt will be checked by using -# the version contained in LibXslt_VERSION_STRING. Since no -# FAIL_MESSAGE is given, the default messages will be printed. -# -# Another example for mode 2: -# -# :: -# -# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) -# find_package_handle_standard_args(Automoc4 CONFIG_MODE) -# -# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4 -# NO_MODULE) and adds an additional search directory for automoc4. Here -# the result will be stored in AUTOMOC4_FOUND. The following -# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper -# success/error message. - -#============================================================================= -# Copyright 2007-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) - -# internal helper macro -macro(_FPHSA_FAILURE_MESSAGE _msg) - if (${_NAME}_FIND_REQUIRED) - message(FATAL_ERROR "${_msg}") - else () - if (NOT ${_NAME}_FIND_QUIETLY) - message(STATUS "${_msg}") - endif () - endif () -endmacro() - - -# internal helper macro to generate the failure message when used in CONFIG_MODE: -macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) - # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: - if(${_NAME}_CONFIG) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") - else() - # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. - # List them all in the error message: - if(${_NAME}_CONSIDERED_CONFIGS) - set(configsText "") - list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) - math(EXPR configsCount "${configsCount} - 1") - foreach(currentConfigIndex RANGE ${configsCount}) - list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) - list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) - set(configsText "${configsText} ${filename} (version ${version})\n") - endforeach() - if (${_NAME}_NOT_FOUND_MESSAGE) - set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") - endif() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") - - else() - # Simple case: No Config-file was found at all: - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") - endif() - endif() -endmacro() - - -function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) - -# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in -# new extended or in the "old" mode: - set(options CONFIG_MODE HANDLE_COMPONENTS) - set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) - set(multiValueArgs REQUIRED_VARS) - set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) - list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) - - if(${INDEX} EQUAL -1) - set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) - set(FPHSA_REQUIRED_VARS ${ARGN}) - set(FPHSA_VERSION_VAR) - else() - - CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) - - if(FPHSA_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") - endif() - - if(NOT FPHSA_FAIL_MESSAGE) - set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") - endif() - endif() - -# now that we collected all arguments, process them - - if("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") - set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") - endif() - - # In config-mode, we rely on the variable _CONFIG, which is set by find_package() - # when it successfully found the config-file, including version checking: - if(FPHSA_CONFIG_MODE) - list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) - list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) - set(FPHSA_VERSION_VAR ${_NAME}_VERSION) - endif() - - if(NOT FPHSA_REQUIRED_VARS) - message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") - endif() - - list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) - - string(TOUPPER ${_NAME} _NAME_UPPER) - string(TOLOWER ${_NAME} _NAME_LOWER) - - if(FPHSA_FOUND_VAR) - if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") - set(_FOUND_VAR ${FPHSA_FOUND_VAR}) - else() - message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") - endif() - else() - set(_FOUND_VAR ${_NAME_UPPER}_FOUND) - endif() - - # collect all variables which were not found, so they can be printed, so the - # user knows better what went wrong (#6375) - set(MISSING_VARS "") - set(DETAILS "") - # check if all passed variables are valid - unset(${_FOUND_VAR}) - foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) - if(NOT ${_CURRENT_VAR}) - set(${_FOUND_VAR} FALSE) - set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") - else() - set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") - endif() - endforeach() - if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE") - set(${_FOUND_VAR} TRUE) - endif() - - # component handling - unset(FOUND_COMPONENTS_MSG) - unset(MISSING_COMPONENTS_MSG) - - if(FPHSA_HANDLE_COMPONENTS) - foreach(comp ${${_NAME}_FIND_COMPONENTS}) - if(${_NAME}_${comp}_FOUND) - - if(NOT DEFINED FOUND_COMPONENTS_MSG) - set(FOUND_COMPONENTS_MSG "found components: ") - endif() - set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}") - - else() - - if(NOT DEFINED MISSING_COMPONENTS_MSG) - set(MISSING_COMPONENTS_MSG "missing components: ") - endif() - set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}") - - if(${_NAME}_FIND_REQUIRED_${comp}) - set(${_FOUND_VAR} FALSE) - set(MISSING_VARS "${MISSING_VARS} ${comp}") - endif() - - endif() - endforeach() - set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") - set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]") - endif() - - # version handling: - set(VERSION_MSG "") - set(VERSION_OK TRUE) - set(VERSION ${${FPHSA_VERSION_VAR}} ) - if (${_NAME}_FIND_VERSION) - - if(VERSION) - - if(${_NAME}_FIND_VERSION_EXACT) # exact version required - if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") - set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") - endif () - - else() # minimum version specified: - if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") - set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") - endif () - endif() - - else() - - # if the package was not found, but a version was given, add that to the output: - if(${_NAME}_FIND_VERSION_EXACT) - set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") - else() - set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") - endif() - - endif() - else () - if(VERSION) - set(VERSION_MSG "(found version \"${VERSION}\")") - endif() - endif () - - if(VERSION_OK) - set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") - else() - set(${_FOUND_VAR} FALSE) - endif() - - - # print the result: - if (${_FOUND_VAR}) - FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") - else () - - if(FPHSA_CONFIG_MODE) - _FPHSA_HANDLE_FAILURE_CONFIG_MODE() - else() - if(NOT VERSION_OK) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") - else() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") - endif() - endif() - - endif () - - set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE) - -endfunction() diff --git a/CMakeModules/FindPackageMessage.cmake b/CMakeModules/FindPackageMessage.cmake deleted file mode 100644 index b6a58e427d143..0000000000000 --- a/CMakeModules/FindPackageMessage.cmake +++ /dev/null @@ -1,57 +0,0 @@ -#.rst: -# FindPackageMessage -# ------------------ -# -# -# -# FIND_PACKAGE_MESSAGE( "message for user" "find result details") -# -# This macro is intended to be used in FindXXX.cmake modules files. It -# will print a message once for each unique find result. This is useful -# for telling the user where a package was found. The first argument -# specifies the name (XXX) of the package. The second argument -# specifies the message to display. The third argument lists details -# about the find result so that if they change the message will be -# displayed again. The macro also obeys the QUIET argument to the -# find_package command. -# -# Example: -# -# :: -# -# if(X11_FOUND) -# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" -# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") -# else() -# ... -# endif() - -#============================================================================= -# Copyright 2008-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -function(FIND_PACKAGE_MESSAGE pkg msg details) - # Avoid printing a message repeatedly for the same find result. - if(NOT ${pkg}_FIND_QUIETLY) - string(REGEX REPLACE "[\n]" "" details "${details}") - set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) - if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") - # The message has not yet been printed. - message(STATUS "${msg}") - - # Save the find details in the cache to avoid printing the same - # message again. - set("${DETAILS_VAR}" "${details}" - CACHE INTERNAL "Details about finding ${pkg}") - endif() - endif() -endfunction() diff --git a/CMakePresets.json b/CMakePresets.json index 123e2bf4e2b8c..43f17b9642aa3 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,23 +12,38 @@ "name": "windows", "description": "Windows Build Configuration", "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" + "type": "allOf", + "conditions": [ + { + "type": "equals", + "lhs": "$env{MSYSTEM}", + "rhs": "" + }, + { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + ] + }, + "cacheVariables": { + "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/build-scripts" }, "hidden": true }, { - "name": "visual-c++", + "name": "MSVC", "inherits": [ "windows" ], "description": "Visual C++ Configuration", "toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake", - "generator": "Ninja", + "cacheVariables": { + "VCPKG_ROOT": "C:/vcpkg" + }, "hidden": true }, { "name": "x64-windows-static", - "inherits": [ "base", "visual-c++" ], + "inherits": [ "base", "MSVC" ], "description": "Link Statically", "cacheVariables": { "VCPKG_TARGET_TRIPLET": "x64-windows-static", @@ -37,36 +52,20 @@ "hidden": true }, { - "name": "x64-release", + "name": "windows-tiles-sounds-x64-msvc", "inherits": [ "x64-windows-static" ], - "displayName": "x64 Release", + "displayName": "Windows Tiles Sounds x64 MSVC", "description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)", "cacheVariables": { - "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/x64-release.cmake", + "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake", "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "RELEASE": "True", "CURSES": "False", "LOCALIZE": "True", - "TILES": "True" - } - }, - { - "name": "x64-debug", - "inherits": [ "x64-windows-static" ], - "displayName": "x64 Debug", - "description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug)", - "cacheVariables": { - "CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/FindVCPKG.cmake", - "CMAKE_BUILD_TYPE": "Debug", - "CURSES": "False", - "LOCALIZE": "False", - "TILES": "True" + "TILES": "True", + "SOUND": "True", + "TESTS": "False" } } - ], - "buildPresets": [ - { - "name": "x64-debug", - "configurePreset": "x64-debug" - } ] } diff --git a/build-scripts/CMakeUserPresets.json.in b/build-scripts/CMakeUserPresets.json.in index eace3d9736e06..c94506d48a11a 100644 --- a/build-scripts/CMakeUserPresets.json.in +++ b/build-scripts/CMakeUserPresets.json.in @@ -2,11 +2,12 @@ "version": 3, "buildPresets": [ { - "name": "x64-release", - "configurePreset": "x64-release", + "name": "@BUILD_PRESET_NAME@", + "configurePreset": "@CONFIGURE_PRESET@", "environment": { @_MSVC_DEVENV@ }, + "configuration": "@CMAKE_BUILD_TYPE@", "verbose": true } ] diff --git a/build-scripts/MSVC.cmake b/build-scripts/MSVC.cmake index cd518b5a21024..b2d37ad0715ea 100644 --- a/build-scripts/MSVC.cmake +++ b/build-scripts/MSVC.cmake @@ -1,11 +1,53 @@ -if (NOT "$ENV{DevEnvDir}") - # Use Community Edition when not specified - set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") -endif() -if(CMAKE_GENERATOR MATCHES ^Ninja) - # Ninja is provided by Microsoft but not in the Path - set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") -endif() +#[=======================================================================[ + +MSVC +---- + +Toolchain file for Microsoft Visual C++. + +Used by CMakePresets.json -> "toolchainFile". + +C++ flags used by all builds: + +/MP cl.exe build with multiple processes +/utf-8 set source and execution character sets to UTF-8 +/bigobj increase # of sections in object files +/permissive- enforce more standards compliant behavior +/sdl- disable additional security checks +/FC full path in compiler messages +/Gd __cdecl +/GS- disable buffer security checks +/Gy Enable Function-Level Linking +/GF Eliminate Duplicate Strings +/wd4068 unknown pragma +/wd4146 negate unsigned +/wd4819 codepage? +/wd6237 short-circuit eval +/wd6319 a, b: unused a +/wd26444 unnamed objects +/wd26451 overflow +/wd26495 uninitialized member +/WX- (do not) Treat Warnings as Errors +/W1 Warning Level +/TP every file is a C++ file +/Zc:forScope Force Conformance in for Loop Scope +/Zc:inline Remove unreferenced COMDAT +/Zc:wchar_t wchar_t Is Native Type + +Additional C++ flags used by RelWithDebInfo builds: + +/Ob1 Inline Function Expansion (1 = only when marked as such) +/Oi Generate Intrinsic Functions + +Linker flags used by all builds: + +/OPT:REF remove unreferenced COMDATs +/OPT:ICF folds identical COMDATs +/DYNAMICBASE does this app really need ASLR ? +/NXCOMPAT same as above +No need to force /TLBID:1 because is default + +#]=======================================================================] # Path has changed, so this configure run will find cl.exe set(CMAKE_C_COMPILER cl.exe) @@ -15,35 +57,9 @@ set(CMAKE_CXX_FLAGS_INIT "\ /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \ /TP /Zc:forScope /Zc:inline /Zc:wchar_t" ) -# /MP # cl.exe build with multiple processes -# /utf-8 # set source and execution character sets to UTF-8 -# /bigobj # increase # of sections in object files -# /permissive- # to allow alternative operators ("and", "or", "not") -# /sdl- # disable additional security checks -# /FC # full path in compiler messages -# /Gd # __cdecl -# /GS- # disable buffer security checks -# /Gy # Enable Function-Level Linking -# /GF # Eliminate Duplicate Strings -# /wd4068 # unknown pragma -# /wd4146 # negate unsigned -# /wd4819 # codepage? -# /wd6237 # short-circuit eval -# /wd6319 # a, b: unused a -# /wd26444 # unnamed objects -# /wd26451 # overflow -# /wd26495 # uninitialized member -# /WX- # (do not) Treat Warnings as Errors -# /W1 # Warning Level -# /TP # every file is a C++ file -# /Zc:forScope # Force Conformance in for Loop Scope -# /Zc:inline # Remove unreferenced COMDAT -# /Zc:wchar_t # wchar_t Is Native Type set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/Oi" ) -# /Ob1 # Inline Function Expansion (1 = only when marked as such) -# /Oi # Generate Intrinsic Functions add_compile_definitions( _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS @@ -60,12 +76,15 @@ add_link_options( /DYNAMICBASE /NXCOMPAT ) -# /OPT:REF # remove unreferenced COMDATs -# /OPT:ICF # folds identical COMDATs -# /DYNAMICBASE # does this app really need ASLR ? -# /NXCOMPAT # same as above -# No need to force /TLBID:1 because is default set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") + +# Where is vcpkg.json ? set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features) -include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) + +set(VCPKG_ROOT "" CACHE PATH "Path to VCPKG installation") +if (NOT $ENV{VCPKG_ROOT} STREQUAL "") + include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) +elseif(NOT $CACHE{VCPKG_ROOT} STREQUAL "") + include($CACHE{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) +endif() diff --git a/build-scripts/VsDevCmd.cmake b/build-scripts/VsDevCmd.cmake new file mode 100644 index 0000000000000..efdefa3bdb3ab --- /dev/null +++ b/build-scripts/VsDevCmd.cmake @@ -0,0 +1,115 @@ +#[=======================================================================[ + +VsDevCmd.cmake +-------------- + +Run VsDevCmd.bat and extracts environment variables it changes. +Inject them into the global scope and _MSVC_DEVENV for +CMakeUserPreset.json at a later step. + +#]=======================================================================] + +if("$ENV{VSCMD_VER}" STREQUAL "") + # This cmake process is running under VsDevCmd.bat or VS IDE GUI + # Avoid to run VsDevCmd.bat twice + + if ("$ENV{DevEnvDir}" STREQUAL "") + # Use Community Edition when not specified + file(DOWNLOAD https://github.com/microsoft/vswhere/releases/download/3.0.3/vswhere.exe vswhere.exe + TLS_VERIFY ON + EXPECTED_HASH SHA1=8569081535767af53811f47c0e6abeabd695f8f4 + STATUS vswhere + ) + list(GET vswhere 0 vswhere) + if("0" EQUAL vswhere) + execute_process(COMMAND vswhere.exe -all -latest -property productPath + OUTPUT_VARIABLE DevEnvDir + OUTPUT_STRIP_TRAILING_WHITESPACE) + cmake_path(GET DevEnvDir PARENT_PATH DevEnvDir) + set(ENV{DevEnvDir} ${DevEnvDir}) + else() + set(ENV{DevEnvDir} "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/") + endif() + endif() + + # Run VsDevCmd.bat and set all environment variables it changes + set(DevEnvDir $ENV{DevEnvDir}) + cmake_path(APPEND DevEnvDir ../Tools/VsDevCmd.bat OUTPUT_VARIABLE VSDEVCMD_BAT) + cmake_path(NATIVE_PATH VSDEVCMD_BAT NORMALIZE VSDEVCMD_BAT) + cmake_path(NATIVE_PATH DevEnvDir NORMALIZE DevEnvDir) + set(ENV{DevEnvDir} ${DevEnvDir}) + set(ENV{VSDEVCMD_BAT} \"${VSDEVCMD_BAT}\") + # Use short DOS path names because of spaces in path names + # See https://gitlab.kitware.com/cmake/cmake/-/issues/16321 + execute_process(COMMAND cmd /c for %A in (%VSDEVCMD_BAT%) do @echo %~sA + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE VSDEVCMD_BAT) + # Run it + execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _ENV) + # This list the environment variables we need. + # It is essentially a revised result of: + # comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" + set(_replace + ExtensionSdkDir= + Framework40Version= + FrameworkDIR64= + FrameworkDir= + FrameworkVersion64= + FrameworkVersion= + INCLUDE= + LIB= + LIBPATH= + NETFXSDKDir= + Path= + UCRTVersion= + UniversalCRTSdkDir= + VCIDEInstallDir= + VCINSTALLDIR= + VCToolsInstallDir= + VCToolsRedistDir= + VCToolsVersion= + VS170COMNTOOLS= + VSCMD_ARG_HOST_ARCH= + VSCMD_ARG_TGT_ARCH= + VSCMD_ARG_app_plat= + VSCMD_VER= + VSINSTALLDIR= + VisualStudioVersion= + WindowsLibPath= + WindowsSDKLibVersion= + WindowsSDKVersion= + WindowsSDK_ExecutablePath_x64= + WindowsSDK_ExecutablePath_x86= + WindowsSdkBinPath= + WindowsSdkDir= + WindowsSdkVerBinPath= + ) + string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") + string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") + foreach(_env IN LISTS _ENV) + string(REGEX MATCH ^[^=]+ _key "${_env}") + string(REGEX MATCH =[^\n]+\n _value "${_env}") + # We may get some spurious output. Skip the line + if(NOT _value MATCHES ^=) + continue() + endif() + string(SUBSTRING "${_value}" 1 -1 _value) # Removes the = at begin + string(STRIP "${_value}" _value) # Remove the \r + list(FIND _replace ${_key}= _idx) + if(-1 EQUAL _idx) + continue() + endif() + list(REMOVE_AT _replace ${_idx}) + set(ENV{${_key}} "${_value}") + string(REPLACE \\ \\\\ _value "${_value}") + set(_json_entry "\"${_key}\": \"${_value}\"") + if("${_MSVC_DEVENV}" STREQUAL "") + string(APPEND _MSVC_DEVENV "${_json_entry}") + continue() + endif() + string(APPEND _MSVC_DEVENV ",\n${_json_entry}") + endforeach() # _ENV +endif() # VSCMD_VER + diff --git a/build-scripts/clang-tidy.sh b/build-scripts/clang-tidy.sh index 5e5f50be50424..482679814eb57 100755 --- a/build-scripts/clang-tidy.sh +++ b/build-scripts/clang-tidy.sh @@ -59,6 +59,10 @@ then echo "Missing FileCheck" exit 1 fi + if ! which python && which python3 + then + ln -s `which python3` $PWD/tools/clang-tidy-plugin/clang-tidy-plugin-support/bin/python + fi CATA_CLANG_TIDY=clang-tidy lit -v tools/clang-tidy-plugin/test fi diff --git a/build-scripts/windows-tiles-sounds-x64-msvc.cmake b/build-scripts/windows-tiles-sounds-x64-msvc.cmake new file mode 100644 index 0000000000000..6bb7d17cd9d7b --- /dev/null +++ b/build-scripts/windows-tiles-sounds-x64-msvc.cmake @@ -0,0 +1,38 @@ +#[=======================================================================[ + +windows-tiles-sounds-x64-msvc +----------------------------- + +Pre-load script for Microsoft Visual Studio builds. + +Used by CMakePresets.json -> "cacheVariables" -> "CMAKE_PROJECT_INCLUDE_BEFORE". + +When CMake does not run under VS environment, it sources the VsDevCmd.bat on it own. +It then writes CMakeUserPresets.json -> "buildPresets" -> "environment" + +#]=======================================================================] + +# Ref https://github.com/actions/virtual-environments/blob/win19/20220515.1/images/win/Windows2019-Readme.md#environment-variables +if (NOT $ENV{VCPKG_INSTALLATION_ROOT} STREQUAL "") + set(ENV{VCPKG_ROOT} $ENV{VCPKG_INSTALLATION_ROOT}) +endif() +# Ref https://vcpkg.io/en/docs/users/config-environment.html#vcpkg_root +if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) + set(ENV{VCPKG_ROOT} $CACHE{VCPKG_ROOT}) +endif() + +include(${CMAKE_SOURCE_DIR}/build-scripts/VsDevCmd.cmake) + +# It's fine to keep @_MSVC_DEVENV@ undefined +set(BUILD_PRESET_NAME "windows-tiles-sounds-x64-msvc") +set(CONFIGURE_PRESET "windows-tiles-sounds-x64-msvc") +configure_file( + ${CMAKE_SOURCE_DIR}/build-scripts/CMakeUserPresets.json.in + ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json + @ONLY +) + +# Ninja is provided by Microsoft but not in the Path +if (CMAKE_GENERATOR MATCHES "^Ninja") + set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}\\CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") +endif() diff --git a/build-scripts/x64-release.cmake b/build-scripts/x64-release.cmake deleted file mode 100644 index 0cf9d957be5b7..0000000000000 --- a/build-scripts/x64-release.cmake +++ /dev/null @@ -1,86 +0,0 @@ -if (NOT $ENV{VCPKG_INSTALLATION_ROOT} STREQUAL "") - set(ENV{VCPKG_ROOT} $ENV{VCPKG_INSTALLATION_ROOT}) -endif() -if ("$ENV{VCPKG_ROOT}" STREQUAL "" AND WIN32) - set(ENV{VCPKG_ROOT} C:/vcpkg) -endif() - -if("$ENV{VSCMD_VER}" STREQUAL "") - # This cmake process is running under VsDevCmd.bat or VS IDE GUI - # Avoid to run VsDevCmd.bat twice - - if (NOT "$ENV{DevEnvDir}") - # Use Community Edition when not specified - set(ENV{DevEnvDir} "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\") - endif() - # Ninja is provided by Microsoft but not in the Path - set(CMAKE_MAKE_PROGRAM $ENV{DevEnvDir}CommonExtensions\\Microsoft\\CMake\\Ninja\\ninja.exe CACHE PATH "") - - # Run VsDevCmd.bat and set all environment variables it changes - set(VSDEVCMD_BAT "$ENV{DevEnvDir}\\..\\Tools\\VsDevCmd.bat") - cmake_path(NATIVE_PATH VSDEVCMD_BAT VSDEVCMD_BAT) - execute_process(COMMAND cmd /c ${VSDEVCMD_BAT} -no_logo -arch=amd64 && set - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE _ENV) - string(REGEX REPLACE ";" "\\\\;" _ENV "${_ENV}") - string(REGEX MATCHALL "[^\n]+\n" _ENV "${_ENV}") - foreach(_env IN LISTS _ENV) - string(REGEX MATCH ^[^=]+ _key "${_env}") - string(REGEX MATCH =[^\n]+\n _value "${_env}") - message(XX${_value}XX) - string(SUBSTRING "${_value}" 1 -1 _value) # Remove = at begin - string(STRIP "${_value}" _value) # Remove \r - # This list is essentially a revised result of :comm -1 -3 <(sort before.txt) <(sort after.txt) |egrep -o '^[^=]+='" - foreach(_replace - ExtensionSdkDir= - Framework40Version= - FrameworkDIR64= - FrameworkDir= - FrameworkVersion64= - FrameworkVersion= - INCLUDE= - LIB= - LIBPATH= - NETFXSDKDir= - Path= - UCRTVersion= - UniversalCRTSdkDir= - VCIDEInstallDir= - VCINSTALLDIR= - VCToolsInstallDir= - VCToolsRedistDir= - VCToolsVersion= - VS170COMNTOOLS= - VSCMD_ARG_HOST_ARCH= - VSCMD_ARG_TGT_ARCH= - VSCMD_ARG_app_plat= - VSCMD_VER= - VSINSTALLDIR= - VisualStudioVersion= - WindowsLibPath= - WindowsSDKLibVersion= - WindowsSDKVersion= - WindowsSDK_ExecutablePath_x64= - WindowsSDK_ExecutablePath_x86= - WindowsSdkBinPath= - WindowsSdkDir= - WindowsSdkVerBinPath= - ) - if("${_key}=" STREQUAL "${_replace}") - set(ENV{${_key}} "${_value}") - string(REPLACE \\ \\\\ _value "${_value}") - set(_json_entry "\"${_key}\": \"${_value}\"") - if("${_MSVC_DEVENV}" STREQUAL "") - string(APPEND _MSVC_DEVENV "${_json_entry}") - else() - string(APPEND _MSVC_DEVENV ",\n${_json_entry}") - endif() - endif() - endforeach() - endforeach() -endif() # VSCMD_VER -configure_file( - ${CMAKE_SOURCE_DIR}/build-scripts/CMakeUserPresets.json.in - ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json - @ONLY -) diff --git a/build-scripts/x64-windows-static.cmake b/build-scripts/x64-windows-static.cmake new file mode 100644 index 0000000000000..66655f1877714 --- /dev/null +++ b/build-scripts/x64-windows-static.cmake @@ -0,0 +1,5 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_BUILD_TYPE release) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 07e3e8dba73c6..4b6dfd6262f40 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -10,6 +10,8 @@ set(CATACLYSM_DATA_DIRS ${CMAKE_SOURCE_DIR}/data/credits ${CMAKE_SOURCE_DIR}/data/title ${CMAKE_SOURCE_DIR}/data/core + ${CMAKE_SOURCE_DIR}/data/screenshots + ${CMAKE_SOURCE_DIR}/data/xdg ${CMAKE_SOURCE_DIR}/data/help) if (SOUND) @@ -26,13 +28,4 @@ set(CATACLYSM_DATA_FILES if (RELEASE) install(DIRECTORY ${CATACLYSM_DATA_DIRS} DESTINATION ${DATA_PREFIX}) install(FILES ${CATACLYSM_DATA_FILES} DESTINATION ${DATA_PREFIX}) - install(FILES - ${CMAKE_SOURCE_DIR}/README.md - ${CMAKE_SOURCE_DIR}/LICENSE.txt - ${CMAKE_SOURCE_DIR}/LICENSE-OFL-Terminus-Font.txt - DESTINATION ${CMAKE_INSTALL_PREFIX}) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc DESTINATION ${CMAKE_INSTALL_PREFIX}) - if (TILES) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/gfx DESTINATION ${CMAKE_INSTALL_PREFIX}) - endif() endif () diff --git a/doc/COMPILING/COMPILING-CMAKE-VCPKG.md b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md new file mode 100644 index 0000000000000..d34eb77b0ff83 --- /dev/null +++ b/doc/COMPILING/COMPILING-CMAKE-VCPKG.md @@ -0,0 +1,84 @@ +# Disclaimer + +**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) + +# Contents + +1. Prerequisites +2. Configure +3. Build +4. Install +5. Run + +# 1 Prerequisites + +`cmake` >= 3.20.0
+`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.
+They will all build the code into the directory `out/build//`. + +## 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 + +## Visual Studio +The Standard toolbar shows the presets in the _Configuration_ drop-down box.
+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`
+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 ` + + 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 -DLOCALIZE=OFF` + +# 3 Build + +## Visual Studio +From the Standard toolbar's _Build Preset_ drop-down menu select the build preset.
+From the main menu, select _Build -> Build All_ + +## Terminal +Run the command + * `cmake --build --preset ` + +# 4 Install + +## Visual Studio +From the main menu, select _Build -> Install CataclysmDDA_ + +## Terminal +Run the command + * `cmake --install out/build// --config RelWithDebInfo` + +# 5 Run + + ## Visual Studio +From the Standard toolbar's _Select Startup Item..._ drop-down menu select `cataclysm-tiles.exe (Install)`
+The _Project Configuration_ drop-down menu will show `RelWithDebInfo`.
+You can now _Start Without Debugging_ (default Ctrl+F5) or _Debug -> Start Debugging_ (default F5). + + ## Terminal + Run the commands + * `cd out/install//` + * `cataclysm` or `cataclysm-tiles.exe` diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index 80a419f49a3e4..2fcd3b5c98008 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -2,25 +2,12 @@ cmake_minimum_required(VERSION 3.1.4) message(STATUS "Process LANGUAGES variable --") -find_package(Gettext) - -if (NOT GETTEXT_FOUND) - if (MSVC) - unset(GETTEXT_MSGFMT_EXECUTABLE) - find_program(GETTEXT_MSGFMT_EXECUTABLE - msgfmt.exe - HINTS - C:\\msys64\\usr\\bin - C:\\Program\ Files\\Git\\mingw64\\bin - ) - endif(MSVC) - if(NOT GETTEXT_MSGFMT_EXECUTABLE) - message(FATAL_ERROR - "Gettext not found. Install gettext package or disable \ - localization with \"-DLOCALIZE=OFF\". \ - See doc/COMPILING/COMPILING-CMAKE.md for details and more info.") - endif() -endif () +if(NOT GETTEXT_MSGFMT_EXECUTABLE) + message(FATAL_ERROR + "Gettext not found. Install gettext package or disable \ + localization with \"-DLOCALIZE=OFF\". \ + See doc/COMPILING/COMPILING-CMAKE.md for details and more info.") +endif() foreach (LANG ${LANGUAGES}) message(STATUS "Add translation for ${LANG}: ${LANG}.po") @@ -63,20 +50,6 @@ add_custom_target( translations_prepare WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -# Auto-Compile translation on release builds only -if (RELEASE) - add_custom_target( - translations_compile - ALL - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - DEPENDS translations_prepare) -else () - add_custom_target( - translations_compile - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - DEPENDS translations_prepare) -endif () - set(DIRS "${LANGUAGES}") list(TRANSFORM DIRS REPLACE "\(.+\)" lang/mo/\\1/LC_MESSAGES) add_custom_command( @@ -87,12 +60,15 @@ add_custom_command( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) foreach (LANG ${LANGUAGES}) + set(_PO ${CMAKE_SOURCE_DIR}/lang/po/${LANG}.po) + set(_MO ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES/cataclysm-dda.mo) add_custom_command( - TARGET translations_compile - PRE_BUILD - COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -f ${CMAKE_SOURCE_DIR}/lang/po/${LANG}.po - -o ${CMAKE_SOURCE_DIR}/lang/mo/${LANG}/LC_MESSAGES/cataclysm-dda.mo - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + OUTPUT ${_MO} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -f ${_PO} -o ${_MO} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS ${_PO} translations_prepare + ) + list(APPEND _MO_FILES ${_MO}) if (RELEASE) if ("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") install(DIRECTORY ${CMAKE_SOURCE_DIR}/lang/mo/${LANG} DESTINATION ${LOCALE_DIR}/mo) @@ -101,3 +77,10 @@ foreach (LANG ${LANGUAGES}) endif () endif () endforeach() + +# Auto-Compile translation on release builds only +if (RELEASE) + add_custom_target(locale ALL DEPENDS ${_MO_FILES}) +else() + add_custom_target(locale DEPENDS ${_MO_FILES}) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9a6479cf4076..214d54afc1356 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,13 +112,14 @@ if (TILES) target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2 SDL2::SDL2main SDL2::SDL2_image - $,SDL2_ttf::SDL2_ttf,SDL2_ttf::SDL2_ttf-static>) + SDL2::SDL2_ttf) endif() if (SOUND) if (VCPKG_MANIFEST_MODE) find_package(Ogg REQUIRED) find_package(Vorbis REQUIRED) - target_link_libraries(cataclysm-tiles-common PUBLIC SDL2_mixer::SDL2_mixer-static + # SDL2_mixer::SDL2_mixer-static = TODO x64-mingw-static ? + target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2_mixer Ogg::ogg Vorbis::vorbis) endif() @@ -140,6 +141,9 @@ if (TILES) target_link_libraries(cataclysm-tiles-common PUBLIC oleaut32.lib) target_link_libraries(cataclysm-tiles-common PUBLIC version.lib) target_link_libraries(cataclysm-tiles-common PUBLIC setupapi.lib) + if (SOUND) + target_link_libraries(cataclysm-tiles-common PUBLIC shlwapi.lib) + endif() if (BACKTRACE) target_link_libraries(cataclysm-tiles-common PUBLIC dbghelp.lib) if (LIBBACKTRACE) @@ -149,7 +153,7 @@ if (TILES) endif () if (LIBBACKTRACE) - target_link_libraries(cataclysm-tiles-common backtrace) + target_link_libraries(cataclysm-tiles-common PUBLIC backtrace) endif () if (RELEASE) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b1fd57a01c13d..8d1b43e19cde0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,32 +7,25 @@ if (BUILD_TESTING) # Enabling benchmarks add_definitions(-DCATCH_CONFIG_ENABLE_BENCHMARKING) - # Need to build the test .mo file for the tests to pass. - # Unfortunately we currently need to put this in the source dir, not the - # build dir - set(TEST_LANG ${CMAKE_SOURCE_DIR}/data/mods/TEST_DATA/lang) - set(TEST_MO ${TEST_LANG}/mo/ru/LC_MESSAGES/TEST_DATA.mo) - if(MSVC) - find_program(GETTEXT_MSGFMT_EXECUTABLE - msgfmt.exe - HINTS - C:\\msys64\\usr\\bin - C:\\Prorogram\ Files\\Git\\mingw64\\bin - REQUIRED - ) - else() - set(GETTEXT_MSGFMT_EXECUTABLE msgfmt) - endif() - add_custom_command( - OUTPUT ${TEST_MO} - MAIN_DEPENDENCY ${TEST_LANG}/po/ru.po - COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -f -o ${TEST_MO} ${TEST_LANG}/po/ru.po) + if(LOCALIZE) + # Need to build the test .mo file for the tests to pass. + # Unfortunately we currently need to put this in the source dir, not the + # build dir + set(TEST_LANG ${CMAKE_SOURCE_DIR}/data/mods/TEST_DATA/lang) + set(TEST_MO ${TEST_LANG}/mo/ru/LC_MESSAGES/TEST_DATA.mo) + add_custom_command( + OUTPUT ${TEST_MO} + MAIN_DEPENDENCY ${TEST_LANG}/po/ru.po + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -f -o ${TEST_MO} ${TEST_LANG}/po/ru.po) - add_custom_target(test_mo DEPENDS ${TEST_MO}) + add_custom_target(test_mo DEPENDS ${TEST_MO}) + endif() if (TILES) add_executable(cata_test-tiles ${CATACLYSM_DDA_TEST_SOURCES}) - add_dependencies(cata_test-tiles test_mo) + if (LOCALIZE) + add_dependencies(cata_test-tiles test_mo) + endif() target_link_libraries(cata_test-tiles cataclysm-tiles-common) add_test(NAME test-tiles COMMAND sh -c @@ -42,7 +35,9 @@ if (BUILD_TESTING) if (CURSES) add_executable(cata_test ${CATACLYSM_DDA_TEST_SOURCES}) - add_dependencies(cata_test test_mo) + if (LOCALIZE) + add_dependencies(cata_test test_mo) + endif() target_link_libraries(cata_test cataclysm-common) add_test(NAME test COMMAND sh -c