Skip to content

Commit a19fe3d

Browse files
authored
Downgrade cmake files to v3.20 (CleverRaven#65376)
* Use CMake version 3.20 and presets version 2 * Flatten presets into one * Use presetName for the include file * Start using multi-config generators * Add a Linux release configuration and build preset * Display PROJECT_NAME during configuration * Fix all SDL2 related target names
1 parent c8c38c1 commit a19fe3d

File tree

4 files changed

+52
-69
lines changed

4 files changed

+52
-69
lines changed

CMakeLists.txt

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.21)
1+
cmake_minimum_required(VERSION 3.20)
22

33
project(CataclysmDDA)
44

@@ -39,7 +39,7 @@ if (TESTS)
3939
include(CTest)
4040
endif()
4141

42-
message(STATUS "${PROJECT} build environment --")
42+
message(STATUS "${PROJECT_NAME} build environment --")
4343
message(STATUS "Build realm is: ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
4444

4545
if (NOT CMAKE_BUILD_TYPE)
@@ -195,7 +195,7 @@ endif ()
195195
# Set build types and display info
196196
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
197197
set(RELEASE 0)
198-
message(STATUS "Build ${PROJECT} in development mode --")
198+
message(STATUS "Build ${PROJECT_NAME} in development mode --")
199199
message(STATUS "Binaries will be located in: " ${CMAKE_SOURCE_DIR})
200200
set(CMAKE_VERBOSE_MAKEFILE ON)
201201
# Since CataclysmDDA does not respect PREFIX for development builds
@@ -315,9 +315,9 @@ if (TILES)
315315
if (NOT VCPKG_MANIFEST_MODE)
316316
find_package(SDL2_ttf)
317317
else()
318-
find_package(sdl2-ttf)
318+
find_package(SDL2_ttf)
319319
endif()
320-
if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2::SDL2_ttf-static))
320+
if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2_ttf::SDL2_ttf-static))
321321
message(FATAL_ERROR
322322
"This project requires SDL2_ttf to be installed to compile in graphical mode. \
323323
Please install the SDL2_ttf development libraries, \
@@ -327,11 +327,11 @@ if (TILES)
327327

328328
message(STATUS "Searching for SDL2_image library --")
329329
if(VCPKG_MANIFEST_MODE)
330-
find_package(sdl2-image)
330+
find_package(SDL2_image)
331331
else()
332332
find_package(SDL2_image)
333333
endif()
334-
if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2::SDL2_image))
334+
if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2_image::SDL2_image-static))
335335
message(FATAL_ERROR
336336
"This project requires SDL2_image to be installed to compile in graphical mode. \
337337
Please install the SDL2_image development libraries, \
@@ -371,8 +371,9 @@ if (SOUND)
371371
# Sound requires SDL_mixer library
372372
if(VCPKG_MANIFEST_MODE)
373373
message(STATUS "Searching for sdl2-mixer library --")
374-
find_package(sdl2-mixer)
375-
if (NOT TARGET SDL2::SDL2_mixer)
374+
find_package(Ogg REQUIRED)
375+
find_package(SDL2_mixer)
376+
if (NOT (TARGET SDL2_mixer::SDL2_mixer OR TARGET SDL2_mixer::SDL2_mixer-static))
376377
message(FATAL_ERROR
377378
"You need the sdl2-mixer development library \
378379
to be able to compile with sound enabled. \

CMakePresets.json

+37-53
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,55 @@
11
{
2-
"version": 3,
2+
"version": 2,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 20,
6+
"patch": 0
7+
},
38
"configurePresets": [
49
{
5-
"name": "base",
6-
"description": "Base Build Configuration",
10+
"name": "windows-tiles-sounds-x64-msvc",
711
"binaryDir": "${sourceDir}/out/build/${presetName}",
8-
"installDir": "${sourceDir}/out/install/${presetName}",
9-
"hidden": true
10-
},
11-
{
12-
"name": "windows",
13-
"description": "Windows Build Configuration",
14-
"condition": {
15-
"type": "allOf",
16-
"conditions": [
17-
{
18-
"type": "equals",
19-
"lhs": "$env{MSYSTEM}",
20-
"rhs": ""
21-
},
22-
{
23-
"type": "equals",
24-
"lhs": "${hostSystemName}",
25-
"rhs": "Windows"
26-
}
27-
]
28-
},
29-
"cacheVariables": {
30-
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/build-scripts"
31-
},
32-
"hidden": true
33-
},
34-
{
35-
"name": "MSVC",
36-
"inherits": [ "windows" ],
37-
"description": "Visual C++ Configuration",
38-
"toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake",
39-
"cacheVariables": {
40-
"VCPKG_ROOT": "C:/vcpkg"
41-
},
42-
"hidden": true
43-
},
44-
{
45-
"name": "x64-windows-static",
46-
"inherits": [ "base", "MSVC" ],
47-
"description": "Link Statically",
12+
"displayName": "Windows Tiles Sounds x64 MSVC",
13+
"description": "Target Windows (64-bit) with the Visual Studio development environment.",
14+
"generator": "Ninja Multi-Config",
4815
"cacheVariables": {
16+
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake",
17+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake",
4918
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
50-
"DYNAMIC_LINKING": "False"
51-
},
52-
"hidden": true
19+
"VCPKG_ROOT": "C:/vcpkg",
20+
"DYNAMIC_LINKING": "False",
21+
"RELEASE": "True",
22+
"CURSES": "False",
23+
"LOCALIZE": "True",
24+
"TILES": "True",
25+
"SOUND": "True",
26+
"TESTS": "False"
27+
}
5328
},
5429
{
55-
"name": "windows-tiles-sounds-x64-msvc",
56-
"inherits": [ "x64-windows-static" ],
57-
"displayName": "Windows Tiles Sounds x64 MSVC",
58-
"description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)",
30+
"name": "linux-tiles-sounds-x64",
31+
"binaryDir": "${sourceDir}/out/build/${presetName}",
32+
"displayName": "Linux Tiles Sounds x64",
33+
"description": "Target Linux (64-bit) with the GCC development environment.",
34+
"generator": "Ninja Multi-Config",
5935
"cacheVariables": {
60-
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake",
61-
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
36+
"VCPKG_TARGET_TRIPLET": "x64-linux",
37+
"CMAKE_TOOLCHAIN_FILE": "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake",
38+
"VCPKG_MANIFEST_DIR": "msvc-full-features/",
39+
"DYNAMIC_LINKING": "False",
6240
"RELEASE": "True",
6341
"CURSES": "False",
6442
"LOCALIZE": "True",
6543
"TILES": "True",
6644
"SOUND": "True",
67-
"TESTS": "False"
45+
"TESTS": "False"
6846
}
6947
}
48+
],
49+
"buildPresets": [
50+
{
51+
"name": "linux-tiles-sounds-x64",
52+
"configurePreset": "linux-tiles-sounds-x64"
53+
}
7054
]
7155
}

build-scripts/CMakeUserPresets.json.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": 3,
2+
"version": 2,
33
"buildPresets": [
44
{
55
"name": "@BUILD_PRESET_NAME@",

src/CMakeLists.txt

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
cmake_minimum_required(VERSION 3.21)
2-
31
add_subdirectory(${CMAKE_SOURCE_DIR}/src/third-party)
42

53
set(MAIN_CPP ${CMAKE_SOURCE_DIR}/src/main.cpp)
@@ -111,15 +109,15 @@ if (TILES)
111109
if(TARGET SDL2::SDL2)
112110
target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2
113111
SDL2::SDL2main
114-
SDL2::SDL2_image
115-
SDL2::SDL2_ttf)
112+
SDL2_image::SDL2_image-static
113+
SDL2_ttf::SDL2_ttf-static)
116114
endif()
117115
if (SOUND)
118116
if (VCPKG_MANIFEST_MODE)
119117
find_package(Ogg REQUIRED)
120-
find_package(Vorbis REQUIRED)
121118
# SDL2_mixer::SDL2_mixer-static = TODO x64-mingw-static ?
122-
target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2_mixer
119+
find_package(Vorbis REQUIRED)
120+
target_link_libraries(cataclysm-tiles-common PUBLIC SDL2_mixer::SDL2_mixer-static
123121
Ogg::ogg
124122
Vorbis::vorbis)
125123
endif()

0 commit comments

Comments
 (0)