Skip to content

Commit

Permalink
Merge pull request #74057 from alef/pdcurses-msvc
Browse files Browse the repository at this point in the history
Add PDCurses to Windows
  • Loading branch information
Maleclypse authored Jul 6, 2024
2 parents c8cc550 + b3d40c3 commit 5cd2c01
Show file tree
Hide file tree
Showing 29 changed files with 382 additions and 103 deletions.
30 changes: 28 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,34 @@ if (CURSES)
message(STATUS "Searching for Curses library --")
set(CURSES_NEED_NCURSES TRUE)
set(CURSES_NEED_WIDE TRUE)
find_package(Curses)
if (NOT CURSES_FOUND)
if (WIN32 AND VCPKG_MANIFEST_MODE)
find_package(unofficial-pdcurses CONFIG)
if(TARGET unofficial::pdcurses::pdcurses)
set(USE_PDCURSES TRUE)
endif()
elseif(MSYS2)
if(True) # GNU NCURSES: mingw-w64-ucrt-x86_64-ncurses
add_library(pdcurses STATIC IMPORTED)
set_target_properties(pdcurses PROPERTIES
IMPORTED_LOCATION $ENV{MSYSTEM_PREFIX}/lib/libncursesw.a
INTERFACE_INCLUDE_DIRECTORIES $ENV{MSYSTEM_PREFIX}/include/ncursesw
)
set(USE_PDCURSES FALSE)
else() # PDCursesMOD: mingw-w64-ucrt-x86_64-pdcurses
add_library(pdcurses STATIC IMPORTED)
set_target_properties(pdcurses PROPERTIES
IMPORTED_LOCATION $ENV{MSYSTEM_PREFIX}/lib/libpdcurses_wingui.a
INTERFACE_INCLUDE_DIRECTORIES $ENV{MSYSTEM_PREFIX}/include/pdcurses
INTERFACE_COMPILE_DEFINITIONS
"PDC_WIDE;PDC_FORCE_UTF8;PDC_NCMOUSE;PDC_RGB;CHTYPE_32"
)
set(USE_PDCURSES TRUE)
endif()
set(CURSES_FOUND True)
else ()
find_package(Curses)
endif ()
if (NOT (CURSES_FOUND OR TARGET unofficial::pdcurses::pdcurses))
message(FATAL_ERROR
"This project requires ncurses to be installed to be compiled in text-only mode. \
Please install the ncurses development libraries, \
Expand Down
75 changes: 69 additions & 6 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,36 @@
"patch": 0
},
"configurePresets": [
{
"name": "windows-x64",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"displayName": "Windows x64 MSYS2 (MinGW)",
"description": "Target Windows (64-bit) with the MingGW Win64 development environment.",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"DYNAMIC_LINKING": "False",
"CURSES": "True", "LOCALIZE": "True", "TILES": "False", "SOUND": "False", "TESTS": "True",
"CMAKE_INSTALL_MESSAGE": "NEVER"
}
},
{
"name": "windows-x64-msvc",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"displayName": "Windows x64 MSVC",
"description": "Target Windows (64-bit) with the Visual Studio development environment.",
"generator": "Visual Studio 16 2019",
"environment": {
"VCPKG_ROOT": "C:/vcpkg"
},
"cacheVariables": {
"DYNAMIC_LINKING": "False",
"CURSES": "True", "LOCALIZE": "True", "TILES": "False", "SOUND": "False", "TESTS": "True",
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"CMAKE_INSTALL_MESSAGE": "NEVER"
}
},
{
"name": "windows-tiles-sounds-x64",
"binaryDir": "${sourceDir}/out/build/${presetName}",
Expand Down Expand Up @@ -51,6 +81,18 @@
"VCPKG_APPLOCAL_DEPS": "False"
}
},
{
"name": "linux-x64",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"displayName": "Linux x64",
"description": "Target Linux (64-bit) with the GCC development environment.",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"DYNAMIC_LINKING": "True",
"CURSES": "True", "LOCALIZE": "True", "TILES": "False", "SOUND": "False", "TESTS": "True",
"CMAKE_INSTALL_MESSAGE": "NEVER"
}
},
{
"name": "linux-tiles-sounds-x64",
"binaryDir": "${sourceDir}/out/build/${presetName}",
Expand Down Expand Up @@ -80,35 +122,56 @@
}
],
"buildPresets": [
{
"name": "windows-x64",
"configurePreset": "windows-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "windows-x64-msvc",
"configurePreset": "windows-x64-msvc",
"configuration": "RelWithDebInfo"
},
{
"name": "windows-tiles-sounds-x64",
"configurePreset": "windows-tiles-sounds-x64"
"configurePreset": "windows-tiles-sounds-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-x64",
"configurePreset": "linux-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-tiles-sounds-x64",
"configurePreset": "linux-tiles-sounds-x64"
"configurePreset": "linux-tiles-sounds-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-tiles-sounds-x64-vcpkg",
"configurePreset": "linux-tiles-sounds-x64-vcpkg"
},
{
"name": "windows-tiles-sounds-x64-msvc",
"configurePreset": "windows-tiles-sounds-x64-msvc"
"configurePreset": "windows-tiles-sounds-x64-msvc",
"configuration": "RelWithDebInfo"
},
{
"name": "windows-tiles-sounds-x64-llvm",
"configurePreset": "windows-tiles-sounds-x64-llvm"
"configurePreset": "windows-tiles-sounds-x64-llvm",
"configuration": "RelWithDebInfo"
}
],
"testPresets": [
{
"name": "windows-tiles-sounds-x64-msvc",
"configurePreset": "windows-tiles-sounds-x64-msvc"
"configurePreset": "windows-tiles-sounds-x64-msvc",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-tiles-sounds-x64",
"configurePreset": "linux-tiles-sounds-x64"
"configurePreset": "linux-tiles-sounds-x64",
"configuration": "RelWithDebInfo"
}
]
}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,9 @@ else
endif # OSXCROSS
endif # HAVE_NCURSES5CONFIG
endif # HAVE_PKGCONFIG
ifeq ($(MSYS),1)
CXXFLAGS += -DNCURSES_INTERNALS
endif
endif # TILES

ifeq ($(BSD), 1)
Expand Down
24 changes: 11 additions & 13 deletions msvc-full-features/Cataclysm-common.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,29 @@
<AdditionalOptions>/bigobj /utf-8 %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)..\pch;$(MSBuildThisFileDirectory)..\src;$(MSBuildThisFileDirectory)..\src\third-party;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>Use</PrecompiledHeader>
<ForcedIncludeFiles>$(MSBuildThisFileDirectory)..\pch\main-pch.hpp</ForcedIncludeFiles>
<DisableSpecificWarnings>4661;4819;4146;26495;26444;26451;4068;6319;6237</DisableSpecificWarnings>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;LOCALIZE;USE_VCPKG;IMGUI_DISABLE_OBSOLETE_KEYIO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;LOCALIZE;USE_VCPKG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>$(MSBuildThisFileDirectory)..\pch\main-pch.hpp</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Condition="$(Configuration.StartsWith(Debug))">
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Condition="$(Configuration.StartsWith(Release))">
<PreprocessorDefinitions>RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Condition="!$(Configuration.Contains(NoTiles))">
<PreprocessorDefinitions>TILES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Condition="$(Configuration.Contains(NoTiles))">
<PreprocessorDefinitions>USE_PDCURSES;PDC_NCMOUSE;PDC_WIDE;IMTUI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Condition="$(_CDDA_BACKTRACE)">
<PreprocessorDefinitions>BACKTRACE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Condition="$(_CDDA_USE_CCACHE)">
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<ForcedIncludeFiles />
<ObjectFileName>$(IntDir)%(FileName).obj</ObjectFileName>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<Lib Condition="$(_CDDA_ENABLE_THIN_ARCHIVES)">
<AdditionalOptions>/llvmlibthin $(AdditionalOptions)</AdditionalOptions>
Expand Down Expand Up @@ -112,6 +117,7 @@
mpg123.lib;
ogg.lib;
out123.lib;
pdcurses.lib;
SDL2_image-static$(VcpkgLibSuffix).lib;
SDL2_mixer-static$(VcpkgLibSuffix).lib;
SDL2_ttf.lib;
Expand Down Expand Up @@ -145,12 +151,4 @@
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)..\pch\main-pch.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)stdafx.cpp">
<PrecompiledHeader Condition="!$(_CDDA_USE_CCACHE)">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
</Project>
6 changes: 2 additions & 4 deletions msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="Cataclysm-common.props" />
<Import Project="Cataclysm-pch.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
Expand Down Expand Up @@ -128,15 +129,13 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<PreprocessorDefinitions>_DEBUG;TILES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug-NoTiles'">
<ClCompile>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
Expand All @@ -146,7 +145,6 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<GenerateDebugInformation>DebugFastLink</GenerateDebugInformation>
<PreprocessorDefinitions>TILES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
Expand Down Expand Up @@ -189,4 +187,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
24 changes: 24 additions & 0 deletions msvc-full-features/Cataclysm-pch.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<ForcedIncludeFiles>$(MSBuildThisFileDirectory)..\pch\main-pch.hpp</ForcedIncludeFiles>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>$(MSBuildThisFileDirectory)..\pch\main-pch.hpp</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Condition="$(_CDDA_USE_CCACHE)">
<ForcedIncludeFiles />
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)..\pch\main-pch.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)stdafx.cpp">
<PrecompiledHeader Condition="!$(_CDDA_USE_CCACHE)">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="Cataclysm-common.props" />
<Import Project="Cataclysm-pch.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
Expand Down
24 changes: 12 additions & 12 deletions msvc-full-features/Cataclysm-vcpkg-static.sln
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,24 @@ Global
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug|x64.Build.0 = Debug|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug|x86.ActiveCfg = Debug|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug|x86.Build.0 = Debug|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|ARM64EC.ActiveCfg = Debug|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|ARM64EC.Build.0 = Debug|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|x64.ActiveCfg = Debug|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|x64.Build.0 = Debug|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|x86.ActiveCfg = Debug|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|x86.Build.0 = Debug|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|ARM64EC.ActiveCfg = Debug-NoTiles|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|ARM64EC.Build.0 = Debug-NoTiles|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|x64.ActiveCfg = Debug-NoTiles|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|x64.Build.0 = Debug-NoTiles|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|x86.ActiveCfg = Debug-NoTiles|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Debug-NoTiles|x86.Build.0 = Debug-NoTiles|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|ARM64EC.ActiveCfg = Release|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|ARM64EC.Build.0 = Release|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x64.ActiveCfg = Release|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x64.Build.0 = Release|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x86.ActiveCfg = Release|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x86.Build.0 = Release|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|ARM64EC.ActiveCfg = Release|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|ARM64EC.Build.0 = Release|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|x64.ActiveCfg = Release|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|x64.Build.0 = Release|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|x86.ActiveCfg = Release|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|x86.Build.0 = Release|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|ARM64EC.ActiveCfg = Release-NoTiles|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|ARM64EC.Build.0 = Release-NoTiles|ARM64EC
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|x64.ActiveCfg = Release-NoTiles|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|x64.Build.0 = Release-NoTiles|x64
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|x86.ActiveCfg = Release-NoTiles|Win32
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release-NoTiles|x86.Build.0 = Release-NoTiles|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
12 changes: 10 additions & 2 deletions msvc-full-features/Cataclysm-vcpkg-static.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="Cataclysm-common.props" />
<Import Project="Cataclysm-pch.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
Expand Down Expand Up @@ -156,13 +157,20 @@
<EmbedManifest>false</EmbedManifest>
<TargetName>cataclysm-tiles</TargetName>
</PropertyGroup>
<ItemDefinitionGroup>
<ItemDefinitionGroup Condition="!$(Configuration.Contains(NoTiles))">
<ClCompile>
<PreprocessorDefinitions>_WINDOWS;USE_WINMAIN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="$(Configuration.Contains(NoTiles))">
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<CustomBuildStep Condition="'$(CDDA_POST_BUILD_JSON_LINT)' != ''">
<Command>C:\windows\system32\windowspowershell\v1.0\powershell.exe -NonInteractive -ExecutionPolicy Unrestricted $(SolutionDir)\style-json.ps1 -FromMSBuild</Command>
<Message>Linting JSON</Message>
Expand Down Expand Up @@ -235,4 +243,4 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>
Loading

0 comments on commit 5cd2c01

Please sign in to comment.