Skip to content

Commit

Permalink
Fixing build with VS
Browse files Browse the repository at this point in the history
Fixes #29 Missing FindSetEnv.cmake when building with VS 2019 command prompt
  • Loading branch information
flamewing committed Jul 4, 2024
1 parent 5689543 commit 94a843c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ project(mdcomp
LANGUAGES CXX ASM
)

# Joins arguments and places the results in ${result_var}.
function(join result_var)
set(result "")
foreach (arg ${ARGN})
set(result "${result}${arg}")
endforeach ()
set(${result_var} "${result}" PARENT_SCOPE)
endfunction()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/support/cmake")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." TRUE)
Expand Down Expand Up @@ -228,10 +239,10 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio")
endif()

# Set FrameworkPathOverride to get rid of MSB3644 warnings.
set(netfxpath "C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0")
join(netfxpath "C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0")
file(WRITE run-msbuild.bat "
${MSBUILD_SETUP}
${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"${netfxpath}\" %*")
${MSBUILD_SETUP}
${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"${netfxpath}\" %*")
endif()

set(COMMON_HEADERS
Expand Down
8 changes: 8 additions & 0 deletions include/mdcomp/bigendian_io.hh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
# define PURE_INLINE
#endif

#ifdef _MSC_VER
# ifndef __clang__
[[noreturn]] inline void __builtin_unreachable() {
__assume(false);
}
# endif
#endif

namespace detail {
// Meta-programming stuff.

Expand Down
14 changes: 3 additions & 11 deletions include/mdcomp/lzss.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
#include <variant>
#include <vector>

#ifdef _MSC_VER
# ifndef __clang__
[[noreturn]] inline void __builtin_unreachable() {
__assume(false);
}
# endif
#endif

/*
* Class representing an edge in the LZSS-compression graph. An edge (u, v)
* indicates that there is a sliding window match that covers all the characters
Expand Down Expand Up @@ -275,9 +267,9 @@ concept lzss_adaptor = requires {
requires !std::same_as<typename T::descriptor_t, bool>;
requires std::is_class_v<typename T::descriptor_endian_t>;
requires std::is_enum_v<typename T::edge_type>;
{ T::edge_type::invalid } -> std::same_as<typename T::edge_type>;
{ T::edge_type::terminator } -> std::same_as<typename T::edge_type>;
{ T::edge_type::symbolwise } -> std::same_as<typename T::edge_type>;
{ T::edge_type::invalid };
{ T::edge_type::terminator };
{ T::edge_type::symbolwise };
requires std::same_as<decltype(T::num_desc_bits), size_t const>;
requires std::same_as<decltype(T::need_early_descriptor), bool const>;
requires std::same_as<decltype(T::descriptor_bit_order), bit_endian const>;
Expand Down
7 changes: 7 additions & 0 deletions support/cmake/FindSetEnv.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# A CMake script to find SetEnv.cmd.

find_program(WINSDK_SETENV NAMES SetEnv.cmd
PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/bin")
if (WINSDK_SETENV AND PRINT_PATH)
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${WINSDK_SETENV}")
endif ()

0 comments on commit 94a843c

Please sign in to comment.