Skip to content

Commit 16643d3

Browse files
committed
Trye having CMake generate export header.
1 parent 160b5bd commit 16643d3

16 files changed

+228
-233
lines changed

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ set_target_properties( SpecUtils PROPERTIES PREFIX "lib" OUTPUT_NAME "SpecUtils"
283283
# Make so on Windows the functions/classes will be exported
284284
target_compile_definitions( SpecUtils PRIVATE SpecUtils_EXPORTS )
285285

286+
# Include the GenerateExportHeader module
287+
include(GenerateExportHeader)
288+
generate_export_header(SpecUtils
289+
BASE_NAME SpecUtils
290+
EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/SpecUtilsExport.h
291+
)
292+
293+
if( NOT SpecUtils_SHARED_LIB )
294+
target_compile_definitions( SpecUtils PRIVATE SPECUTILS_STATIC_DEFINE )
295+
endif()
296+
297+
286298
set( SpecUtils_USE_FAST_FLOAT OFF ) # Uses https://github.com/fastfloat/fast_float . If fast_float.h isnt found, will be fetched
287299
set( SpecUtils_USE_FROM_CHARS OFF ) # Supported by MSVC >= 2019, and gcc >= 12. Not supported by Apple clang. In MSVC, about 50% slower than boost::spirit
288300
set( SpecUtils_USE_BOOST_SPIRIT OFF ) # Uses boost::spirit, and fasted method (maybe a hair faster than fastfloat)
@@ -480,7 +492,7 @@ configure_file(
480492
)
481493
LIST(APPEND headers ${SpecUtils_config_OUT})
482494
# Install the headers
483-
install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SpecUtils)
495+
install(FILES ${headers} ${CMAKE_BINARY_DIR}/SpecUtilsExport.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SpecUtils)
484496

485497
# Create and install the CMake package configuration files
486498
include(CMakePackageConfigHelpers)

SpecUtils/CubicSpline.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace SpecUtils
4949
5050
Where x_i and y_i are #CubicSplineNode::x and #CubicSplineNode::y respectively.
5151
*/
52-
struct SpecUtils_DLLEXPORT CubicSplineNode
52+
struct SPECUTILS_EXPORT CubicSplineNode
5353
{
5454
/** The starting x-value of the interval. */
5555
double x;
@@ -72,7 +72,7 @@ namespace SpecUtils
7272
7373
Will throw exception on error.
7474
*/
75-
SpecUtils_DLLEXPORT
75+
SPECUTILS_EXPORT
7676
std::vector<CubicSplineNode>
7777
create_cubic_spline( const std::vector<std::pair<float,float>> &data,
7878
const DerivativeType left_bc_type,
@@ -87,7 +87,7 @@ namespace SpecUtils
8787
respectively (this is non-standard behavior for cubic splines, but how
8888
non-linear deviation pairs are defined).
8989
*/
90-
SpecUtils_DLLEXPORT
90+
SPECUTILS_EXPORT
9191
double eval_cubic_spline( const double x,
9292
const std::vector<CubicSplineNode> &nodes );
9393

@@ -97,7 +97,7 @@ namespace SpecUtils
9797
no duplicate x values (if there are duplicates, the one with the smallest
9898
y-value is used).
9999
*/
100-
SpecUtils_DLLEXPORT
100+
SPECUTILS_EXPORT
101101
std::vector<CubicSplineNode>
102102
create_cubic_spline_for_dev_pairs( const std::vector<std::pair<float,float>> &dps );
103103

@@ -113,7 +113,7 @@ namespace SpecUtils
113113
See #correction_due_to_dev_pairs for a functioned guaranteed to get you within
114114
0.0001 keV of the correct answer.
115115
*/
116-
SpecUtils_DLLEXPORT
116+
SPECUTILS_EXPORT
117117
std::vector<CubicSplineNode>
118118
create_inverse_dev_pairs_cubic_spline( const std::vector<std::pair<float,float>> &dps );
119119

SpecUtils/D3SpectrumExport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace D3SpectrumExport
124124

125125
/** Specifies the options for a single spectrum displayed on the chart
126126
*/
127-
struct SpecUtils_DLLEXPORT D3SpectrumOptions
127+
struct SPECUTILS_EXPORT D3SpectrumOptions
128128
{
129129
D3SpectrumOptions(); //black line, no peaks, scale factor 1.0
130130

@@ -175,7 +175,7 @@ namespace D3SpectrumExport
175175
of those state values.
176176
177177
*/
178-
struct SpecUtils_DLLEXPORT D3SpectrumChartOptions
178+
struct SPECUTILS_EXPORT D3SpectrumChartOptions
179179
{
180180
D3SpectrumChartOptions();
181181
D3SpectrumChartOptions( std::string title,

SpecUtils/DateTime.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace SpecUtils
3838
3939
This is in analogy with boost::posix_time::ptime, that we upgraded the code from.
4040
*/
41-
SpecUtils_DLLEXPORT
41+
SPECUTILS_EXPORT
4242
bool is_special( const time_point_t &t );
4343

4444
//to_iso_string(...) and to_extended_iso_string(...) are implemented here
@@ -47,28 +47,28 @@ namespace SpecUtils
4747
/** Converts the input time to an iso formatted string.
4848
Ex. "20140414T141201.621543"
4949
*/
50-
SpecUtils_DLLEXPORT
50+
SPECUTILS_EXPORT
5151
std::string to_iso_string( const time_point_t &t );
5252

5353
/** Converts the input time to an extended iso formatted string.
5454
Ex. "2014-04-14T14:12:01.621543"
5555
*/
56-
SpecUtils_DLLEXPORT
56+
SPECUTILS_EXPORT
5757
std::string to_extended_iso_string( const time_point_t &t );
5858

5959
/** Converts the input to string in format d-mmm-YYYY HH:MM:SS AM,
6060
where mmm is 3 char month name; d is day number with no leading zeros.
6161
Returns "not-a-date-time" if input is not valid.
6262
Ex. 24hr format: "9-Sep-2014 15:02:15", AM/PM: "9-Sep-2014 03:02:15 PM"
6363
*/
64-
SpecUtils_DLLEXPORT
64+
SPECUTILS_EXPORT
6565
std::string to_common_string( const time_point_t &t, const bool twenty_four_hour );
6666

6767
/** Converts input to the 23 character VAX format "DD-MMM-YYYY HH:MM:SS.SS".
6868
Returns empty string if input is not valid.
6969
Ex. "19-Sep-2014 14:12:01.62"
7070
*/
71-
SpecUtils_DLLEXPORT
71+
SPECUTILS_EXPORT
7272
std::string to_vax_string( time_point_t t );
7373

7474
/** \brief Describes how to attempt to parse date/times when it is ambigous,
@@ -114,7 +114,7 @@ namespace SpecUtils
114114
115115
Does not throw.
116116
*/
117-
SpecUtils_DLLEXPORT
117+
SPECUTILS_EXPORT
118118
time_point_t time_from_string( std::string time_string,
119119
const DateParseEndianType endian = DateParseEndianType::MiddleEndianFirst );
120120

@@ -133,13 +133,13 @@ namespace SpecUtils
133133
more complete implementation, but hasnt been tested against parsing spectrum
134134
files.
135135
*/
136-
SpecUtils_DLLEXPORT
136+
SPECUTILS_EXPORT
137137
float time_duration_string_to_seconds( const char *duration_str, const size_t length );
138138

139139
/** Convenience function for getting time duration from a ISO 8601 like
140140
std::string.
141141
*/
142-
SpecUtils_DLLEXPORT
142+
SPECUTILS_EXPORT
143143
float time_duration_string_to_seconds( const std::string &duration );
144144

145145
/** Converts a string formatted like "[-]h[h][:mm][:ss][.fff]", (ex. "02:15:01.332") to number of
@@ -159,7 +159,7 @@ namespace SpecUtils
159159
160160
Throws exception if input is invalid.
161161
*/
162-
SpecUtils_DLLEXPORT
162+
SPECUTILS_EXPORT
163163
double delimited_duration_string_to_seconds( const std::string &duration );
164164

165165
/** \brief Gives the CPU time in seconds.
@@ -169,7 +169,7 @@ namespace SpecUtils
169169
170170
\returns The CPU time in seconds, or on error -DBL_MAX.
171171
*/
172-
SpecUtils_DLLEXPORT
172+
SPECUTILS_EXPORT
173173
double get_cpu_time();
174174

175175

@@ -182,7 +182,7 @@ namespace SpecUtils
182182
Note May have an occasional jump of a few seconds on Windows due to a
183183
hardware issue (fixed on newer windows/hardware?)
184184
*/
185-
SpecUtils_DLLEXPORT
185+
SPECUTILS_EXPORT
186186
double get_wall_time();
187187

188188
}//namespace SpecUtils

SpecUtils/EnergyCalibration.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ namespace SpecUtils
9999
\TODO: move find_gamma_channel, gamma_energy_min/max, gamma_channel_width,
100100
gamma_channel_lower/upper/center, etc from #SpecUtils::Measurement to #EnergyCalibration
101101
*/
102-
struct SpecUtils_DLLEXPORT EnergyCalibration
102+
struct SPECUTILS_EXPORT EnergyCalibration
103103
{
104104
/** @returns the energy calibration type. */
105105
EnergyCalType type() const;
@@ -320,7 +320,7 @@ namespace SpecUtils
320320
321321
Throws exception if channels to combine is 0.
322322
*/
323-
SpecUtils_DLLEXPORT
323+
SPECUTILS_EXPORT
324324
std::shared_ptr<EnergyCalibration> energy_cal_combine_channels( const EnergyCalibration &orig_cal,
325325
const size_t num_channel_combine );
326326

@@ -341,7 +341,7 @@ namespace SpecUtils
341341
342342
Throws exception if an invalid energy calibration (i.e., channel energies not increasing)
343343
*/
344-
SpecUtils_DLLEXPORT
344+
SPECUTILS_EXPORT
345345
std::shared_ptr< const std::vector<float> >
346346
polynomial_binning( const std::vector<float> &coeffs,
347347
const size_t nchannel,
@@ -366,7 +366,7 @@ namespace SpecUtils
366366
367367
Throws exception if an invalid energy calibration (i.e., channel energies not increasing)
368368
*/
369-
SpecUtils_DLLEXPORT
369+
SPECUTILS_EXPORT
370370
std::shared_ptr< const std::vector<float> >
371371
fullrangefraction_binning( const std::vector<float> &coeffs,
372372
const size_t nchannel,
@@ -388,7 +388,7 @@ namespace SpecUtils
388388
Doesnt perform a check that the coefficients or deviation pairs are actually valid.
389389
Throws exception if deviation pairs are not sorted.
390390
*/
391-
SpecUtils_DLLEXPORT
391+
SPECUTILS_EXPORT
392392
double fullrangefraction_energy( const double channel_number,
393393
const std::vector<float> &coeffs,
394394
const size_t nchannel,
@@ -410,7 +410,7 @@ namespace SpecUtils
410410
411411
Throws exception if deviation pairs are not sorted.
412412
*/
413-
SpecUtils_DLLEXPORT
413+
SPECUTILS_EXPORT
414414
double polynomial_energy( const double channel_number,
415415
const std::vector<float> &coeffs,
416416
const std::vector<std::pair<float,float>> &deviation_pairs );
@@ -447,7 +447,7 @@ namespace SpecUtils
447447
be set at 1460 keV
448448
- Deviation pairs set to zero would be defined for 239 keV and 2614 keV
449449
*/
450-
SpecUtils_DLLEXPORT
450+
SPECUTILS_EXPORT
451451
double deviation_pair_correction( const double polynomial_energy,
452452
const std::vector<std::pair<float,float>> &dev_pairs );
453453

@@ -467,7 +467,7 @@ namespace SpecUtils
467467
future this should be able to be made exactly accuate (within numerical
468468
limits anyway).
469469
*/
470-
SpecUtils_DLLEXPORT
470+
SPECUTILS_EXPORT
471471
double correction_due_to_dev_pairs( const double true_energy,
472472
const std::vector<std::pair<float,float>> &dev_pairs );
473473

@@ -487,7 +487,7 @@ namespace SpecUtils
487487
Throws exception if resulting energy calibration wont be strictly increasing after applying
488488
deviation pair.
489489
*/
490-
SpecUtils_DLLEXPORT
490+
SPECUTILS_EXPORT
491491
std::shared_ptr<const std::vector<float>>
492492
apply_deviation_pair( const std::vector<float> &binning,
493493
const std::vector<std::pair<float,float>> &dev_pairs );
@@ -519,7 +519,7 @@ namespace SpecUtils
519519
@returns the polynomial coefficients. If input coefficients is empty or
520520
number of channels is zero, will return empty vector.
521521
*/
522-
SpecUtils_DLLEXPORT
522+
SPECUTILS_EXPORT
523523
std::vector<float>
524524
fullrangefraction_coef_to_polynomial( const std::vector<float> &coeffs,
525525
const size_t nchannel );
@@ -529,7 +529,7 @@ namespace SpecUtils
529529
the energy given by the equation is the middle of the channel (which is
530530
non-standard) to standard full range fraction equation coefficients.
531531
*/
532-
SpecUtils_DLLEXPORT
532+
SPECUTILS_EXPORT
533533
std::vector<float>
534534
mid_channel_polynomial_to_fullrangeFraction( const std::vector<float> &coeffs,
535535
const size_t nchannel );
@@ -541,7 +541,7 @@ namespace SpecUtils
541541
// right. LowerChannelEdge type is check that each bin is increasing over
542542
// previous, and that it has at least as many bins as nbin.
543543
// InvalidEquationType always returns false.
544-
SpecUtils_DLLEXPORT
544+
SPECUTILS_EXPORT
545545
bool calibration_is_valid( const EnergyCalType type,
546546
const std::vector<float> &eqn,
547547
const std::vector< std::pair<float,float> > &devpairs,
@@ -564,7 +564,7 @@ namespace SpecUtils
564564
Changes the polynomial calibration coefficients
565565
Would probably work for adding channels, but untested.
566566
*/
567-
SpecUtils_DLLEXPORT
567+
SPECUTILS_EXPORT
568568
std::vector<float>
569569
polynomial_cal_remove_first_channels( const int num_channels_remove,
570570
const std::vector<float> &orig_coefs );
@@ -594,7 +594,7 @@ namespace SpecUtils
594594
\TODO: Use #correction_due_to_dev_pairs to make it so algabraic approach can
595595
always be used.
596596
*/
597-
SpecUtils_DLLEXPORT
597+
SPECUTILS_EXPORT
598598
double find_fullrangefraction_channel( const double energy,
599599
const std::vector<float> &coeffs,
600600
const size_t nchannel,
@@ -624,7 +624,7 @@ namespace SpecUtils
624624
Note: that #correction_due_to_dev_pairs is used to correct for deviation pairs when using the,
625625
algebraic approach, and currently (20200820) may be correct to only 0.01 keV.
626626
*/
627-
SpecUtils_DLLEXPORT
627+
SPECUTILS_EXPORT
628628
double find_polynomial_channel( const double energy,
629629
const std::vector<float> &coeffs,
630630
const size_t nchannel,
@@ -653,7 +653,7 @@ namespace SpecUtils
653653
654654
Throw exception if any input has less than four channels.
655655
*/
656-
SpecUtils_DLLEXPORT
656+
SPECUTILS_EXPORT
657657
void rebin_by_lower_edge( const std::vector<float> &original_energies,
658658
const std::vector<float> &original_counts,
659659
const std::vector<float> &new_energies,
@@ -690,7 +690,7 @@ namespace SpecUtils
690690
#END
691691
\endverbatim
692692
*/
693-
SpecUtils_DLLEXPORT
693+
SPECUTILS_EXPORT
694694
std::shared_ptr<EnergyCalibration> energy_cal_from_CALp_file( std::istream &input,
695695
const size_t num_channels,
696696
std::string &det_name );
@@ -711,7 +711,7 @@ namespace SpecUtils
711711
the original FRF coefficients will be written out after the other content - this is a InterSpec/SpecUtils specific extension of CALp file
712712
format.
713713
*/
714-
SpecUtils_DLLEXPORT
714+
SPECUTILS_EXPORT
715715
bool write_CALp_file( std::ostream &output,
716716
const std::shared_ptr<const EnergyCalibration> &cal,
717717
const std::string &detector_name );

0 commit comments

Comments
 (0)