Skip to content

Commit

Permalink
Merge pull request #819 from oyvindln/msvc_fixes
Browse files Browse the repository at this point in the history
fix build on windows
  • Loading branch information
happycube authored Dec 17, 2022
2 parents 1dfbd72 + 6b3e258 commit de48d66
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ option(USE_QWT
ON
)

# Needed for ezpwd as it uses alternative operators
if(MSVC)
add_compile_options(/permissive-)
endif()

set(USE_QT_VERSION "" CACHE STRING
"Version of Qt to use, 5 or 6 (Which is used by default can vary due to how cmake find functions work, but will often default to Qt6)"
)
Expand Down
70 changes: 70 additions & 0 deletions cmake_modules/FindGetopt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Based on FindALSA.cmake from cmake project
# CMake - Cross Platform Makefile Generator
# Copyright 2000-2022 Kitware, Inc. and Contributors
# All rights reserved.
# Distributed under the OSI-approved BSD 3-Clause License. See
# https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindGetopt
--------

Find Getopt (Getopt)

Find the Getopt librariy (``Getopt``)

IMPORTED Targets
^^^^^^^^^^^^^^^^

This module defines :prop_tgt:`IMPORTED` target ``Getopt::Getopt``, if
Getopt has been found.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``Getopt_FOUND``
True if Getopt_INCLUDE_DIR & Getopt_LIBRARY are found

``Getopt_LIBRARIES``
List of libraries when using Getopt.

``Getopt_INCLUDE_DIRS``
Where to find the Getopt headers.

Cache variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``Getopt_INCLUDE_DIR``
the Getopt include directory

``Getopt_LIBRARY``
the absolute path of the asound library
#]=======================================================================]

find_path(Getopt_INCLUDE_DIR NAMES getopt.h
DOC "The Getopt include directory"
)

find_library(Getopt_LIBRARY NAMES getopt
DOC "The Getopt library"
)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Getopt
REQUIRED_VARS Getopt_LIBRARY Getopt_INCLUDE_DIR)

if(Getopt_FOUND)
set( Getopt_LIBRARIES ${Getopt_LIBRARY} )
set( Getopt_INCLUDE_DIRS ${Getopt_INCLUDE_DIR} )
if(NOT TARGET Getopt::Getopt)
add_library(Getopt::Getopt UNKNOWN IMPORTED)
set_target_properties(Getopt::Getopt PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Getopt_INCLUDE_DIRS}")
set_property(TARGET Getopt::Getopt APPEND PROPERTY IMPORTED_LOCATION "${Getopt_LIBRARY}")
endif()
endif()

mark_as_advanced(Getopt_INCLUDE_DIR Getopt_LIBRARY)
1 change: 1 addition & 0 deletions tools/ld-analyse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if(WIN32)
NOMINMAX
QUSB_LIBRARY
)
set_property(TARGET ld-analyse PROPERTY WIN32_EXECUTABLE true)
endif()

install(
Expand Down
4 changes: 4 additions & 0 deletions tools/ld-process-ac3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
if(MSVC)
find_package(Getopt REQUIRED)
endif()

add_subdirectory(demodulate)
add_subdirectory(decode)
5 changes: 4 additions & 1 deletion tools/ld-process-ac3/decode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ add_executable(ld-ac3-decode
ac3_parsing.cpp
main.cpp
)

if(MSVC)
target_link_libraries(ld-ac3-decode PRIVATE ${Getopt_LIBRARIES})
target_include_directories(ld-ac3-decode PRIVATE ${Getopt_INCLUDE_DIRS})
endif()
target_include_directories(ld-ac3-decode PRIVATE . ../../ld-process-efm)

install(TARGETS ld-ac3-decode)
5 changes: 5 additions & 0 deletions tools/ld-process-ac3/demodulate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
add_executable(ld-ac3-demodulate
main.cpp
)
if(MSVC)
target_link_libraries(ld-ac3-demodulate PRIVATE ${Getopt_LIBRARIES})
target_include_directories(ld-ac3-demodulate PRIVATE ${Getopt_INCLUDE_DIRS})
endif()


install(TARGETS ld-ac3-demodulate)
2 changes: 0 additions & 2 deletions tools/ld-process-ac3/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
#include <iomanip>
#include <chrono>
#include <map>
#ifdef __APPLE__
#include <sstream>
#endif

enum LogLevel {
DEBU = 0,
Expand Down
18 changes: 9 additions & 9 deletions tools/ld-process-efm/ezpwd/rs_base
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,10 @@ namespace ezpwd {
&data )
const
{
if ( data.second < data.first or data.second - data.first <= ssize_t( NROOTS )) {
if ( data.second < data.first or data.second - data.first <= ptrdiff_t( NROOTS )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: supplied data too short for some payload + parity", -1 );
}
if ( data.second - data.first > ssize_t( SIZE )) {
if ( data.second - data.first > ptrdiff_t( SIZE )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: supplied data longer than max. payload + parity", -1 );
}
return encode( data.first, data.second - data.first - NROOTS, data.second - NROOTS );
Expand All @@ -799,7 +799,7 @@ namespace ezpwd {
if ( data.second < data.first ) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: data length invalid", -1 );
}
if ( parity.second - parity.first != ssize_t( NROOTS )) {
if ( parity.second - parity.first != ptrdiff_t( NROOTS )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: parity length incompatible with number of roots", -1 );
}
return encode( data.first, data.second - data.first, parity.first );
Expand All @@ -810,10 +810,10 @@ namespace ezpwd {
&data )
const
{
if ( data.second < data.first or data.second - data.first <= ssize_t( NROOTS )) {
if ( data.second < data.first or data.second - data.first <= ptrdiff_t( NROOTS )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: supplied data too short for some payload + parity", -1 );
}
if ( data.second - data.first > ssize_t( SIZE )) {
if ( data.second - data.first > ptrdiff_t( SIZE )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: supplied data longer than max. payload + parity", -1 );
}
return encode( data.first, data.second - data.first - NROOTS, data.second - NROOTS );
Expand All @@ -829,7 +829,7 @@ namespace ezpwd {
if ( data.second < data.first ) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: data length invalid", -1 );
}
if ( parity.second - parity.first != ssize_t (NROOTS )) {
if ( parity.second - parity.first != ptrdiff_t (NROOTS )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: parity length incompatible with number of roots", -1 );
}
return encode( data.first, data.second - data.first, parity.first );
Expand All @@ -840,10 +840,10 @@ namespace ezpwd {
&data )
const
{
if ( data.second < data.first or data.second - data.first <= ssize_t( NROOTS )) {
if ( data.second < data.first or data.second - data.first <= ptrdiff_t( NROOTS )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: supplied data too short for some payload + parity", -1 );
}
if ( data.second - data.first > ssize_t( SIZE )) {
if ( data.second - data.first > ptrdiff_t( SIZE )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: supplied data longer than max. payload + parity", -1 );
}
return encode( data.first, data.second - data.first - NROOTS, data.second - NROOTS );
Expand All @@ -859,7 +859,7 @@ namespace ezpwd {
if ( data.second < data.first ) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: data length invalid", -1 );
}
if ( parity.second - parity.first != ssize_t( NROOTS )) {
if ( parity.second - parity.first != ptrdiff_t( NROOTS )) {
EZPWD_RAISE_OR_RETURN( std::runtime_error, "reed-solomon: parity length incompatible with number of roots", -1 );
}
return encode( data.first, data.second - data.first, parity.first );
Expand Down

0 comments on commit de48d66

Please sign in to comment.