Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Windows Release with CMake (part 2) #61880

Merged
merged 44 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6d3a377
Remove redundant modules from CMakeModules
alef May 27, 2022
97b6f98
Add documentation for CMake+VCPKG build
alef May 24, 2022
7766670
Use VCPKG triplets from build-scripts/
alef May 24, 2022
1223d3f
Optmize replacing ENV vars loop with find()
alef May 26, 2022
8fd1c9e
Force ninja.exe path in the INCLUDE_BEFORE file
alef May 26, 2022
d283462
Add varialbes to "name" and "configurePreset"
alef Jun 1, 2022
cbf2730
Rename presets to match release.yml names
alef Jun 1, 2022
9a8f346
Move VsDevCmd environment parsing to its dedicated script
alef Jul 8, 2022
1c74499
Fix checking for DevEnvDir
alef Aug 13, 2022
7b5917b
Fix parsing non variables output
alef Aug 6, 2022
443db84
Document and improve VsDevCmd.cmake
alef Aug 14, 2022
4e61984
Use vswhere.exe as suggested by @akrieger
alef Sep 9, 2022
cdb5639
Makes Ninja generators on Windows optional
alef Nov 2, 2022
7e293e9
Move hardcoded path into preset
alef Nov 4, 2022
880f7a3
Build a release
alef Nov 9, 2022
ec88111
Rewrite instructions addin VS procedure. Change displayed name
alef Nov 11, 2022
49a6898
Split translations_compile target into each .mo files
alef Nov 15, 2022
9bc5c0a
Add a missing target public interface
alef Nov 16, 2022
1069d41
Update doc/COMPILING/COMPILING-CMAKE-VCPKG.md
alef Nov 25, 2022
1d26dc5
Reverting SDL2 TTF library name resolution in VCPKG
alef Nov 25, 2022
b7436b6
Move VCPKG to Windows only builds
alef Nov 26, 2022
55f513e
Use SDL2_ttf when not using VCPKG
alef Nov 26, 2022
2086828
Disable the MSYS build preset
alef Nov 27, 2022
74f9378
Search for gettext in one place
alef Nov 27, 2022
2e74080
Make VCPKG_ROOT optional in MSVC too
alef Nov 27, 2022
e08b0e7
Allow to configure msgfmt and VCPKG paths
alef Nov 27, 2022
3dd0de4
Fix using cache var in find_program(). Remove extra find_package
alef Nov 27, 2022
d0e2442
Add "python" symlink to v3 when runnig clang-tidy
alef Nov 27, 2022
4019040
Use correct Git for Windows directory
alef Nov 27, 2022
88fa5a9
Test .mo file only if LOCALIZE is set
alef Nov 27, 2022
972e890
Make building tests optional. Use "TESTS" cache var
alef Nov 27, 2022
b9ebd54
Install more directories
alef Nov 27, 2022
2a96c40
Update doc/COMPILING/COMPILING-CMAKE-VCPKG.md
alef Nov 27, 2022
aebcd16
Satisfy cmake-lint
alef Nov 27, 2022
e58971f
Adding missing subirectories in data/
alef Nov 28, 2022
7bdd560
Move logic non belonging to data/ up
alef Nov 28, 2022
ff6f6ac
Add missing languages
alef Nov 28, 2022
9f0c5e2
Disable testing by default
alef Nov 28, 2022
8ccb212
Install VERSION.txt
alef Nov 28, 2022
9e689e7
Build tests by default.
alef Nov 29, 2022
8350b2a
Switch building tests from CMake to presets
alef Nov 30, 2022
0a951f4
Add shlwapi required by mpg123
alef Nov 30, 2022
c724007
Split SDL2 mixer package names
alef Nov 30, 2022
d643b90
Enable sound
alef Nov 30, 2022
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
74 changes: 65 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
alef marked this conversation as resolved.
Show resolved Hide resolved
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}")
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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, \
Expand Down Expand Up @@ -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 ()

Expand All @@ -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)
Expand All @@ -389,14 +425,34 @@ 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()
if (CATA_CLANG_TIDY_PLUGIN OR CATA_CLANG_TIDY_EXECUTABLE)
add_subdirectory(tools/clang-tidy-plugin)
endif()

install(DIRECTORY doc gfx
DESTINATION .
)
alef marked this conversation as resolved.
Show resolved Hide resolved

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"
Expand Down
160 changes: 0 additions & 160 deletions CMakeModules/CMakeParseArguments.cmake

This file was deleted.

Loading