Skip to content

Commit

Permalink
Downgrade cmake files to v3.20
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alef authored and olanti-p committed Oct 17, 2023
1 parent c303368 commit ff14808
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 70 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.20)

project(CataclysmBN)

Expand Down Expand Up @@ -70,7 +70,7 @@ message(" --= Bright Nights =--")

message("\n * https://github.com/cataclysmbnteam/Cataclysm-BN\n")

message(STATUS "${PROJECT} build environment -- \n")
message(STATUS "${PROJECT_NAME} build environment -- \n")

message(
STATUS "Build realm is : ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
Expand Down Expand Up @@ -222,8 +222,7 @@ endif ()
# Set build types and display info
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(RELEASE 0)
message("\n")
message(STATUS "Build ${PROJECT} in development mode --\n")
message(STATUS "Build ${PROJECT_NAME} in development mode --")
message(STATUS "Binaries will be located in: " ${CMAKE_SOURCE_DIR})
set(CMAKE_VERBOSE_MAKEFILE ON)
# Since CataclysmDDA does not respect PREFIX for development builds
Expand Down Expand Up @@ -354,9 +353,9 @@ if (TILES)
if (NOT VCPKG_MANIFEST_MODE)
find_package(SDL2_ttf)
else()
find_package(sdl2-ttf)
find_package(SDL2_ttf)
endif()
if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2::SDL2_ttf-static))
if (NOT (SDL2_TTF_FOUND OR TARGET SDL2::SDL2_ttf OR TARGET SDL2_ttf::SDL2_ttf-static))
message(
FATAL_ERROR
"This project requires SDL2_ttf to be installed to be compiled in graphical mode. \
Expand All @@ -367,11 +366,11 @@ if (TILES)

message(STATUS "Searching for SDL2_image library --\n")
if(VCPKG_MANIFEST_MODE)
find_package(sdl2-image)
find_package(SDL2_image)
else()
find_package(SDL2_image)
endif()
if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2::SDL2_image))
if (NOT (SDL2_IMAGE_FOUND OR TARGET SDL2_image::SDL2_image-static))
message(
FATAL_ERROR
"This project requires SDL2_image to be installed to be compiled in graphical mode. \
Expand Down Expand Up @@ -413,8 +412,9 @@ if (SOUND)
# Sound requires SDL_mixer library
if(VCPKG_MANIFEST_MODE)
message(STATUS "Searching for sdl2-mixer library --")
find_package(sdl2-mixer)
if (NOT TARGET SDL2::SDL2_mixer)
find_package(Ogg REQUIRED)
find_package(SDL2_mixer)
if (NOT (TARGET SDL2_mixer::SDL2_mixer OR TARGET SDL2_mixer::SDL2_mixer-static))
message(FATAL_ERROR
"You need the sdl2-mixer development library \
to be able to compile with sound enabled. \
Expand Down
90 changes: 37 additions & 53 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,55 @@
{
"version": 3,
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "base",
"description": "Base Build Configuration",
"name": "windows-tiles-sounds-x64-msvc",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"hidden": true
},
{
"name": "windows",
"description": "Windows Build Configuration",
"condition": {
"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": "MSVC",
"inherits": [ "windows" ],
"description": "Visual C++ Configuration",
"toolchainFile": "${sourceDir}/build-scripts/MSVC.cmake",
"cacheVariables": {
"VCPKG_ROOT": "C:/vcpkg"
},
"hidden": true
},
{
"name": "x64-windows-static",
"inherits": [ "base", "MSVC" ],
"description": "Link Statically",
"displayName": "Windows Tiles Sounds x64 MSVC",
"description": "Target Windows (64-bit) with the Visual Studio development environment.",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"DYNAMIC_LINKING": "False"
},
"hidden": true
"VCPKG_ROOT": "C:/vcpkg",
"DYNAMIC_LINKING": "False",
"RELEASE": "True",
"CURSES": "False",
"LOCALIZE": "True",
"TILES": "True",
"SOUND": "True",
"TESTS": "False"
}
},
{
"name": "windows-tiles-sounds-x64-msvc",
"inherits": [ "x64-windows-static" ],
"displayName": "Windows Tiles Sounds x64 MSVC",
"description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)",
"name": "linux-tiles-sounds-x64",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"displayName": "Linux Tiles Sounds x64",
"description": "Target Linux (64-bit) with the GCC development environment.",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"VCPKG_TARGET_TRIPLET": "x64-linux",
"CMAKE_TOOLCHAIN_FILE": "/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_MANIFEST_DIR": "msvc-full-features/",
"DYNAMIC_LINKING": "False",
"RELEASE": "True",
"CURSES": "False",
"LOCALIZE": "True",
"TILES": "True",
"SOUND": "True",
"TESTS": "False"
"TESTS": "False"
}
}
],
"buildPresets": [
{
"name": "linux-tiles-sounds-x64",
"configurePreset": "linux-tiles-sounds-x64"
}
]
}
2 changes: 1 addition & 1 deletion build-scripts/CMakeUserPresets.json.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 3,
"version": 2,
"buildPresets": [
{
"name": "@BUILD_PRESET_NAME@",
Expand Down
10 changes: 4 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 3.21)

set(MAIN_CPP ${CMAKE_SOURCE_DIR}/src/main.cpp)
set(MESSAGES_CPP ${CMAKE_SOURCE_DIR}/src/messages.cpp)
set(RESOURCE_RC ${CMAKE_SOURCE_DIR}/src/resource.rc)
Expand Down Expand Up @@ -98,15 +96,15 @@ if (TILES)
if(TARGET SDL2::SDL2)
target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2
SDL2::SDL2main
SDL2::SDL2_image
SDL2::SDL2_ttf)
SDL2_image::SDL2_image-static
SDL2_ttf::SDL2_ttf-static)
endif()
if (SOUND)
if (VCPKG_MANIFEST_MODE)
find_package(Ogg REQUIRED)
find_package(Vorbis REQUIRED)
# SDL2_mixer::SDL2_mixer-static = TODO x64-mingw-static ?
target_link_libraries(cataclysm-tiles-common PUBLIC SDL2::SDL2_mixer
find_package(Vorbis REQUIRED)
target_link_libraries(cataclysm-tiles-common PUBLIC SDL2_mixer::SDL2_mixer-static
Ogg::ogg
Vorbis::vorbis)
endif()
Expand Down

0 comments on commit ff14808

Please sign in to comment.