Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for OS other than Windows (Linux tested) & cmake #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.22)

project(lfmf)

# when the BUILD_SHARED_LIBS is ON, CMake adds a "lfmf_EXPORTS" define automatically while compiling the library

option(BUILD_SHARED_LIBS "Set to ON (default) to build SHARED libraries" ON)

file(GLOB_RECURSE lfmf_source_files src/*.cpp)
file(GLOB_RECURSE lfmf_header_files include/*.h)

# lfmf will be a shared library (or not) depending on the BUILD_SHARED_LIBS variable

add_library(lfmf ${lfmf_source_files} ${lfmf_header_files})

# for static library, add a "_STATIC_LFMF" define while compiling

target_compile_definitions(lfmf PUBLIC $<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_STATIC_LFMF>)

install(FILES ${lfmf_header_files} DESTINATION include)
install(TARGETS lfmf RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
8 changes: 8 additions & 0 deletions include/LFMF.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
#include <complex>

// Export the DLL functions as "C" and not C++
#if defined(WIN32) && !defined(_STATIC_LFMF)
#ifdef lfmf_EXPORTS
#define DLLEXPORT extern "C" __declspec(dllexport)
#else
#define DLLEXPORT extern "C" __declspec(dllimport)
#endif
#else
#define DLLEXPORT extern "C"
#endif
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define DIM(x, y) (((x) > (y)) ? (x - y) : (0))
Expand Down
9 changes: 7 additions & 2 deletions src/Airy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#include "..\include\LFMF.h"
#include "../include/LFMF.h"

#ifndef WIN32
#define _copysign copysign
#define abs fabs
#endif

/*=============================================================================
|
Expand Down Expand Up @@ -815,4 +820,4 @@ complex<double> Airy(complex<double> Z, int kind, int scaling)

return Ai;

};
};
6 changes: 5 additions & 1 deletion src/FlatEarthCurveCorrection.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "..\include\LFMF.h"
#include "../include/LFMF.h"

#ifndef WIN32
#define abs fabs
#endif

/*=============================================================================
|
Expand Down
4 changes: 2 additions & 2 deletions src/LFMF.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\LFMF.h"
#include "../include/LFMF.h"

/*=============================================================================
|
Expand Down Expand Up @@ -102,4 +102,4 @@ int LFMF(double h_tx__meter, double h_rx__meter, double f__mhz, double P_tx__wat
result->P_rx__dbm = result->E_dBuVm + G_rx__dbi - 20.0*log10(f__hz) + 42.8;

return SUCCESS;
}
}
8 changes: 6 additions & 2 deletions src/ResidueSeries.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "..\include\LFMF.h"
#include "../include/LFMF.h"

#ifndef WIN32
#define abs fabs
#endif

/*=============================================================================
|
Expand Down Expand Up @@ -80,4 +84,4 @@ double ResidueSeries(double d__km, double k, double h_1__km, double h_2__km, dou

return E_gw;

};
};
4 changes: 2 additions & 2 deletions src/ValidateInputs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "..\include\LFMF.h"
#include "../include/LFMF.h"

/*=============================================================================
|
Expand Down Expand Up @@ -53,4 +53,4 @@ int ValidateInput(double h_tx__meter, double h_rx__meter, double f__mhz, double
return ERROR__POLARIZATION;

return SUCCESS;
}
}
8 changes: 6 additions & 2 deletions src/WiRoot.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "..\include\LFMF.h"
#include "../include/LFMF.h"

#ifndef WIN32
#define abs fabs
#endif

/*=============================================================================
|
Expand Down Expand Up @@ -238,4 +242,4 @@ complex<double> WiRoot(int i, complex<double> *DWi, complex<double> q, complex<d
};

return tw;
};
};
6 changes: 5 additions & 1 deletion src/wofz.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "..\include\LFMF.h"
#include "../include/LFMF.h"

#ifndef WIN32
#define abs fabs
#endif

complex<double> wofz(complex<double> z)
{
Expand Down