Skip to content

Commit 1cb600f

Browse files
committed
build: set up export header
1 parent 0080efb commit 1cb600f

38 files changed

+476
-60
lines changed

cmake/functions/target_options.cmake

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
# - This does not propagate to other targets
33
function(target_pedantic_warnings TARGET_NAME)
44
# Set warning levels to about the same level for MSVC, GCC, and Clang
5-
if (MSVC)
6-
target_compile_options(${TARGET_NAME} PRIVATE /W4 /WX)
7-
else ()
8-
target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic -Werror)
9-
endif ()
5+
if (BUILD_SHARED_LIBS AND WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|MSVC|MinGW")
6+
# STL classes don't need to have dll-interface to be used by clients of Matplot++ classes
7+
target_compile_options(${TARGET_NAME} PRIVATE /wd4251)
8+
target_compile_options(${TARGET_NAME} PRIVATE /wd2220)
9+
else()
10+
if (MSVC)
11+
target_compile_options(${TARGET_NAME} PRIVATE /W4 /WX)
12+
else ()
13+
target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic -Werror)
14+
endif ()
15+
endif()
1016
endfunction()
1117

1218
# @brief Maybe enable pedantic warnings for a target

source/matplot/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ target_include_directories(matplot
9797
PUBLIC $<BUILD_INTERFACE:${MATPLOT_ROOT_DIR}/source>
9898
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
9999

100+
set_target_properties(matplot PROPERTIES VERSION ${PROJECT_VERSION})
101+
102+
# Shared library symbol export
103+
include(GenerateExportHeader)
104+
generate_export_header(matplot
105+
BASE_NAME matplot
106+
EXPORT_MACRO_NAME MATPLOT_EXPORTS
107+
EXPORT_FILE_NAME matplot/detail/exports.h
108+
STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)
109+
target_include_directories(matplot
110+
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
111+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matplot/detail/exports.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/matplot/detail)
112+
100113
# Dependencies
101114
target_link_libraries_system(matplot PRIVATE cimg nodesoup)
102115

source/matplot/axes_objects/bars.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef MATPLOTPLUSPLUS_BARS_H
66
#define MATPLOTPLUSPLUS_BARS_H
77

8+
#include <matplot/detail/config.h>
9+
810
#include <array>
911
#include <cmath>
1012
#include <map>
@@ -18,7 +20,7 @@
1820

1921
namespace matplot {
2022
class axes_type;
21-
class bars : public axes_object {
23+
class MATPLOT_EXPORTS bars : public axes_object {
2224
public:
2325
explicit bars(class axes_type *parent);
2426
bars(class axes_type *parent, const std::vector<double> &y);

source/matplot/axes_objects/box_chart.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef MATPLOTPLUSPLUS_BOX_CHART_H
66
#define MATPLOTPLUSPLUS_BOX_CHART_H
77

8+
#include <matplot/detail/config.h>
9+
810
#include <array>
911
#include <cmath>
1012
#include <map>
@@ -18,7 +20,7 @@
1820

1921
namespace matplot {
2022
class axes_type;
21-
class box_chart : public axes_object {
23+
class MATPLOT_EXPORTS box_chart : public axes_object {
2224
public:
2325
enum class box_style_option {
2426
outline, // unfilled / dashed whiskers

source/matplot/axes_objects/circles.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef MATPLOTPLUSPLUS_CIRCLES_H
66
#define MATPLOTPLUSPLUS_CIRCLES_H
77

8+
#include <matplot/detail/config.h>
9+
810
#include <matplot/core/figure_type.h>
911

1012
#include <matplot/core/axes_object.h>
@@ -15,7 +17,7 @@
1517

1618
namespace matplot {
1719
class axes_type;
18-
class circles : public axes_object {
20+
class MATPLOT_EXPORTS circles : public axes_object {
1921
public:
2022
explicit circles(class axes_type *parent);
2123
circles(class axes_type *parent, const std::vector<double> &x,

source/matplot/axes_objects/contours.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef MATPLOTPLUSPLUS_CONTOURS_H
66
#define MATPLOTPLUSPLUS_CONTOURS_H
77

8+
#include <matplot/detail/config.h>
9+
810
#include <array>
911
#include <matplot/util/common.h>
1012
#include <matplot/util/concepts.h>
@@ -32,7 +34,7 @@ namespace matplot {
3234
/// way to have full control of how the contour lines will look
3335
/// like is to calculate the contour lines outside gnuplot,
3436
/// even if our algorithm is not perfect.
35-
class contours : public axes_object {
37+
class MATPLOT_EXPORTS contours : public axes_object {
3638
public:
3739
/// X, Y grids and their Z values
3840
/// Every X column has the same value for all rows.

source/matplot/axes_objects/error_bar.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
#ifndef MATPLOTPLUSPLUS_ERROR_BAR_H
66
#define MATPLOTPLUSPLUS_ERROR_BAR_H
77

8+
#include <matplot/detail/config.h>
89
#include <matplot/axes_objects/line.h>
910

1011
namespace matplot {
1112
class axes_type;
1213

13-
class error_bar : public line {
14+
class MATPLOT_EXPORTS error_bar : public line {
1415
public:
1516
enum class type { vertical, horizontal, both };
1617

source/matplot/axes_objects/filled_area.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
#ifndef MATPLOTPLUSPLUS_FILLED_AREA_H
66
#define MATPLOTPLUSPLUS_FILLED_AREA_H
77

8+
#include <matplot/detail/config.h>
89
#include <matplot/axes_objects/line.h>
910

1011
namespace matplot {
1112
class axes_type;
1213

13-
class filled_area : public line {
14+
class MATPLOT_EXPORTS filled_area : public line {
1415
public:
1516
enum class type { vertical, horizontal, both };
1617

source/matplot/axes_objects/function_line.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
#ifndef MATPLOTPLUSPLUS_FUNCTION_LINE_H
66
#define MATPLOTPLUSPLUS_FUNCTION_LINE_H
77

8+
#include <matplot/detail/config.h>
89
#include <matplot/axes_objects/line.h>
910
#include <matplot/core/line_spec.h>
1011
#include <matplot/util/handle_types.h>
1112
#include <string>
1213

1314
namespace matplot {
14-
class function_line : public line {
15+
class MATPLOT_EXPORTS function_line : public line {
1516
public:
1617
using function_type = std::function<double(double)>;
1718

source/matplot/axes_objects/histogram.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
#ifndef MATPLOTPLUSPLUS_HISTOGRAM_H
66
#define MATPLOTPLUSPLUS_HISTOGRAM_H
77

8-
#include <array>
9-
#include <cmath>
10-
#include <map>
8+
#include <matplot/detail/config.h>
119
#include <matplot/core/axes_object.h>
1210
#include <matplot/core/figure_type.h>
1311
#include <matplot/core/line_spec.h>
1412
#include <matplot/util/common.h>
1513
#include <matplot/util/concepts.h>
1614
#include <matplot/util/handle_types.h>
15+
#include <array>
16+
#include <cmath>
17+
#include <map>
1718

1819
namespace matplot {
1920
class axes_type;
20-
class histogram : public axes_object {
21+
class MATPLOT_EXPORTS histogram : public axes_object {
2122
public:
2223
// source code in 'edit histcount'
2324
enum class binning_algorithm {

0 commit comments

Comments
 (0)