Skip to content

Commit

Permalink
more warning by default and windows fix
Browse files Browse the repository at this point in the history
  • Loading branch information
noah1510 committed Dec 14, 2023
1 parent e86cdff commit c57c65b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
44 changes: 22 additions & 22 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ project(
default_options : [
'cpp_std=c++17',
'c_std=c17',
'warning_level=3',
],
version : '2.0.0',
meson_version : '>= 1.1'

)

# find the c and c++ compiler to check for working headers.
Expand All @@ -18,21 +18,21 @@ cxx = meson.get_compiler('cpp')
# define the correct export macro on windows
if target_machine.system() == 'windows'
if get_option('buildtype') != 'static'
add_project_arguments('-DRS232_EXPORT_MACRO=__declspec(dllexport)', language: 'cpp')
add_project_arguments('-DRS232_EXPORT_MACRO=__declspec(dllexport)', language : 'cpp')
else
add_project_arguments('-DRS232_EXPORT_MACRO=__declspec(dllimport)', language: 'cpp')
add_project_arguments('-DRS232_EXPORT_MACRO=__declspec(dllimport)', language : 'cpp')
endif

if target_machine.cpu_family() == 'x86_64'
add_project_arguments('-D_AMD64_', language: 'cpp')
add_project_arguments('-D_AMD64_', language : 'cpp')
elif target_machine.cpu_family() == 'x86'
add_project_arguments('-D_X86_', language: 'cpp')
add_project_arguments('-D_X86_', language : 'cpp')
elif target_machine.cpu_family() == 'ia64'
add_project_arguments('-D_IA64_', language: 'cpp')
add_project_arguments('-D_IA64_', language : 'cpp')
elif target_machine.cpu_family() == 'arm'
add_project_arguments('-D_ARM_', language: 'cpp')
add_project_arguments('-D_ARM_', language : 'cpp')
elif target_machine.cpu_family() == 'aarch64'
add_project_arguments('-D_ARM64_', language: 'cpp')
add_project_arguments('-D_ARM64_', language : 'cpp')
else
if meson.is_cross_build()
error('Unsupported cross compile cpu family:' + target_machine.cpu_family())
Expand Down Expand Up @@ -79,7 +79,7 @@ sources = [

# check if the c++ headers exist and work
foreach header_name : cpp_headers
cxx.check_header(header_name, required: true)
cxx.check_header(header_name, required : true)
endforeach

#extra linker args
Expand All @@ -91,15 +91,15 @@ if host_machine.system() == 'windows'
sources += 'src/rs232_native_win.cpp'

foreach header_name : windows_c_headers
cc.check_header(header_name, required: true)
cc.check_header(header_name, required : true)
endforeach

else
# add the unix source and check if the headers work
sources += 'src/rs232_native_linux.cpp'

foreach header_name : unix_c_headers
cc.check_header(header_name, required: true)
cc.check_header(header_name, required : true)
endforeach
endif

Expand All @@ -108,24 +108,24 @@ incdir = include_directories('include')

# this defines the library that should be compiled and all its dependencies
rs232 = library(
'rs232',
sources,
version : meson.project_version(),
'rs232',
sources,
version : meson.project_version(),
soversion : '0',
include_directories : incdir,
link_args: extra_linker_args,
link_args : extra_linker_args,
install : true,
)

# this defines the compiled library as a dependency that can be used by other meson projects
rs232_dep = declare_dependency(
include_directories : incdir,
link_with : rs232,
version: meson.project_version(),
version : meson.project_version(),
)


build_sample = get_option('build_sample').enable_auto_if(not meson.is_subproject() ).enabled()
build_sample = get_option('build_sample').enable_auto_if(not meson.is_subproject()).enabled()

if build_sample
message('Building sample programs')
Expand All @@ -138,12 +138,12 @@ if build_sample
foreach sample_program : sample_src

exe = executable(
sample_program,
sample_program,
'samples/' + sample_program + '.cpp',
link_args: extra_linker_args,
dependencies: rs232_dep
link_args : extra_linker_args,
dependencies : rs232_dep
)

endforeach

endif
Expand Down
2 changes: 1 addition & 1 deletion src/rs232_native_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inline DCB& getDCB(void* DCBHandle) noexcept {
return *static_cast<DCB*>(DCBHandle);
}

std::vector<std::string> sakurajin::getMatchingPorts(std::regex pattern) noexcept {
std::vector<std::string> sakurajin::getMatchingPorts(const std::regex& pattern) noexcept {
std::vector<std::string> allPorts;
wchar_t lpTargetPath[5000];

Expand Down

0 comments on commit c57c65b

Please sign in to comment.