Skip to content

Commit 96a94fa

Browse files
Merge pull request #1 from kwryankrattiger/windows_fixes
Windows fixes
2 parents 9964ee5 + 15b3563 commit 96a94fa

14 files changed

+93
-46
lines changed

CMakeLists.txt

+54-20
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ else ()
99
endif ()
1010

1111
if (APPLE)
12-
set(CMAKE_POSITION_INDEPENDENT_CODE False)
12+
set(CMAKE_POSITION_INDEPENDENT_CODE FALSE)
1313
else ()
14-
set(CMAKE_POSITION_INDEPENDENT_CODE True)
14+
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
1515
endif ()
1616

1717
project(xmsinterp C CXX)
1818

1919
include(GNUInstallDirs)
20+
include(GenerateExportHeader)
2021

2122
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Enable/Disable building shared libraries")
2223
set(BUILD_TESTING NO CACHE BOOL "Enable/Disable testing")
2324
set(XMS_BUILD_MODE "CONAN" CACHE STRING "Target packing system to build for.")
2425
set_property(CACHE XMS_BUILD_MODE PROPERTY STRINGS "CONAN;CONDA;CMAKE")
25-
set(XMS_BUILD NO CACHE BOOL "Set this if you want to use this package with XMS.")
26+
set(XMS_BUILD ON CACHE BOOL "Set this if you want to use this package with XMS.")
2627
set(CONDA_PREFIX "" CACHE PATH "Path to the conda environment used to build.")
2728
set(ENABLE_PYTHON OFF CACHE BOOL "Set this if you want to build the python bindings.")
2829
set(PYTHON_TARGET_VERSION 3.6 CACHE STRING "Version of python to link to for python wrapping.")
@@ -31,26 +32,42 @@ set(XMS_VERSION "5.2.0" CACHE STRING "Library Version")
3132

3233
add_definitions(-DXMS_VERSION=\"${XMS_VERSION}\")
3334

35+
# Do this because it doesn't work otherwise...
36+
if (BUILD_SHARED_LIBS AND WIN32)
37+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
38+
endif ()
39+
3440
if (ENABLE_PYTHON AND BUILD_TESTING)
3541
message(FATAL_ERROR "Cannot build python module when testing is enabled")
3642
endif ()
3743

3844
if (XMS_BUILD_MODE STREQUAL "CONDA")
3945
include(${CMAKE_CURRENT_LIST_DIR}/condabuildinfo.cmake)
4046
elseif (XMS_BUILD_MODE STREQUAL "CMAKE")
47+
if (PYTHON_TARGET_VERSION VERSION_LESS 3)
48+
message(FATAL_ERROR "XMS requires Python >= 3.0")
49+
endif ()
4150
if (BUILD_SHARED_LIBS)
4251
set(Boost_USE_STATIC_LIBS OFF)
4352
else ()
4453
set(Boost_USE_STATIC_LIBS ON)
4554
endif ()
55+
find_package(ZLIB QUIET REQUIRED)
4656
find_package(Boost QUIET REQUIRED log_setup log system filesystem serialization timer)
4757
find_package(XMSCore QUIET REQUIRED
4858
NAMES xms xmscore)
4959
find_package(XMSGrid QUIET REQUIRED
5060
NAMES xms xmsgrid)
51-
list(APPEND EXT_INCLUDE_DIRS ${XMSCore_INCLUDE_DIRS};${XMSGrid_INCLUDE_DIRS};${Boost_INCLUDE_DIRS})
61+
list(APPEND EXT_INCLUDE_DIRS ${XMSCore_INCLUDE_DIRS};${XMSGrid_INCLUDE_DIRS};${Boost_INCLUDE_DIRS};${ZLIB_INCLUDE_DIRS})
5262
list(APPEND EXT_LIB_DIRS ${XMSCore_LIBRARY_DIRS};${XMSGrid_LIBRARY_DIRS};${Boost_LIBRARY_DIRS})
53-
list(APPEND EXT_LIBS ${XMSCore_LIBRARIES};${XMSGrid_LIBRARIES};${Boost_LIBRARIES};z)
63+
list(APPEND EXT_LIBS ${XMSCore_LIBRARIES};${XMSGrid_LIBRARIES};${Boost_LIBRARIES};${ZLIB_LIBRARIES})
64+
if (WIN32)
65+
if (XMS_BUILD)
66+
add_definitions(/Zc:wchar_t) # Treat wchar_t as built-in type
67+
add_definitions(/D _WIN32_WINNT=0x0501) # Windows XP and higher
68+
endif ()
69+
add_definitions(/D BOOST_ALL_NO_LIB)
70+
endif ()
5471
else () # If we are not using conda, we are using conan
5572
# Conan setup
5673
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
@@ -60,7 +77,7 @@ else () # If we are not using conda, we are using conan
6077
list(APPEND EXT_LIBS ${CONAN_LIBS})
6178
endif ()
6279

63-
if (WIN32)
80+
if (WIN32 AND XMS_BUILD_MODE STREQUAL "CONAN")
6481
string(COMPARE EQUAL "${CONAN_SETTINGS_COMPILER_RUNTIME}" "MT" USES_MT)
6582
if (NOT USES_MT)
6683
string(COMPARE EQUAL "${CONAN_SETTINGS_COMPILER_RUNTIME}" "MTd" USES_MT)
@@ -100,23 +117,22 @@ if (ENABLE_PYTHON)
100117
endif ()
101118

102119
find_package(PythonLibsNew ${PYTHON_TARGET_VERSION} EXACT REQUIRED)
120+
list(APPEND EXT_INCLUDE_DIRS
121+
${pybind11_INCLUDE_DIR}
122+
)
123+
124+
message("PYTHON_INCLUDE: ${PYTHON_INCLUDE_DIRS}")
125+
message("PYTHON_LIBS: ${PYTHON_LIBRARIES}")
126+
127+
list(APPEND EXT_INCLUDE_DIRS
128+
${PYTHON_INCLUDE_DIRS}
129+
)
103130
else ()
104131
# New method does not require PythonLibsNew
105-
find_package(Python REQUIRED COMPONENTS Interpreter)
106-
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
132+
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
107133
find_package(pybind11 CONFIG REQUIRED)
134+
list(APPEND EXT_LIBS pybind11::pybind11 Python3::Python)
108135
endif ()
109-
110-
list(APPEND EXT_INCLUDE_DIRS
111-
${pybind11_INCLUDE_DIR}
112-
)
113-
114-
message("PYTHON_INCLUDE: ${PYTHON_INCLUDE_DIRS}")
115-
message("PYTHON_LIBS: ${PYTHON_LIBRARIES}")
116-
117-
list(APPEND EXT_INCLUDE_DIRS
118-
${PYTHON_INCLUDE_DIRS}
119-
)
120136
endif ()
121137

122138
include_directories(${CMAKE_CURRENT_LIST_DIR})
@@ -223,14 +239,22 @@ target_link_libraries(${PROJECT_NAME}
223239
if (UNIX AND NOT APPLE)
224240
target_link_libraries(${PROJECT_NAME} rt)
225241
endif ()
242+
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME xmsinterp/xmsinterp_export.h)
243+
target_include_directories(xmsinterp
244+
PUBLIC
245+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
246+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
247+
install(FILES ${PROJECT_BINARY_DIR}/xmsinterp/xmsinterp_export.h
248+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xmsinterp
249+
)
226250

227251
if (ENABLE_PYTHON)
228252
pybind11_add_module(_xmsinterp
229253
${xmsinterp_py} ${xmsinterp_py_headers}
230254
)
231255
target_include_directories(_xmsinterp
232256
PRIVATE
233-
${EXT_LIBS}
257+
${EXT_LIBS}
234258
${PYTHON_INCLUDE_DIRS}
235259
)
236260
target_link_libraries(_xmsinterp
@@ -241,6 +265,16 @@ if (ENABLE_PYTHON)
241265
set_target_properties(_xmsinterp PROPERTIES
242266
LINKER_LANGUAGE CXX
243267
)
268+
generate_export_header(_xmsinterp
269+
BASE_NAME xmsinterppy
270+
EXPORT_FILE_NAME xmsinterp/python/xmsinterppy_export.h)
271+
target_include_directories(_xmsinterp
272+
PUBLIC
273+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
274+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
275+
install(FILES ${PROJECT_BINARY_DIR}/xmsinterp/python/xmsinterppy_export.h
276+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}xmsinterp/python
277+
)
244278

245279
if (XMS_BUILD_MODE STREQUAL "CMAKE")
246280
# Using a standard installation heirarchy for python packages

xmsinterp/interpolate/InterpAnisotropic.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//------------------------------------------------------------------------------
88

99
//----- Included files ---------------------------------------------------------
10+
#include <xmsinterp/xmsinterp_export.h>
1011
#include <xmscore/misc/base_macros.h>
1112
#include <xmscore/points/ptsfwd.h>
1213
#include <xmscore/stl/vector.h>
@@ -28,7 +29,7 @@ class Observer;
2829
/// using inverse distance weighted interpolation after scaling the
2930
/// transformed x-values.
3031
/// \see InterpAnisotropicImpl and AnisotropicInterpolator.
31-
class InterpAnisotropic
32+
class XMSINTERP_EXPORT InterpAnisotropic
3233
{
3334
public:
3435
static BSHP<InterpAnisotropic> New();

xmsinterp/interpolate/InterpBase.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//------------------------------------------------------------------------------
88

99
//----- Included files ---------------------------------------------------------
10+
#include <xmsinterp/xmsinterp_export.h>
1011
#include <xmscore/misc/base_macros.h>
1112
#include <xmscore/misc/boost_defines.h>
1213
#include <xmscore/misc/DynBitset.h>
@@ -25,7 +26,7 @@ namespace xms
2526
////////////////////////////////////////////////////////////////////////////////
2627
/// \class InterpBase
2728
/// \brief Base class for interpolation methods.
28-
class InterpBase
29+
class XMSINTERP_EXPORT InterpBase
2930
{
3031
public:
3132
/// \cond These are all documented in the implementations
@@ -56,4 +57,4 @@ class InterpBase
5657
/// \endcond
5758
};
5859
//----- Function prototypes ----------------------------------------------------
59-
}
60+
}

xmsinterp/interpolate/InterpIdw.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
//----- Included files ---------------------------------------------------------
1010
#include <xmscore/misc/base_macros.h>
11+
#include <xmsinterp/xmsinterp_export.h>
1112
#include <xmsinterp/interpolate/InterpBase.h>
1213
#include <xmscore/points/ptsfwd.h>
1314
#include <xmscore/stl/vector.h>
@@ -25,7 +26,7 @@ class Observer;
2526
//----- Structs / Classes ------------------------------------------------------
2627
/// \brief Class that performs inverse distance weighted interpolation
2728
/// \see InterpIdwImpl
28-
class InterpIdw : public InterpBase
29+
class XMSINTERP_EXPORT InterpIdw : public InterpBase
2930
{
3031
public:
3132
static BSHP<InterpIdw> New();

xmsinterp/interpolate/InterpLinear.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// 4. External Library Headers
1414

1515
// 5. Shared Headers
16+
#include <xmsinterp/xmsinterp_export.h>
1617
#include <xmscore/points/ptsfwd.h>
1718
#include <xmscore/stl/vector.h>
1819
#include <xmsinterp/interpolate/InterpBase.h>
@@ -34,7 +35,7 @@ class Observer;
3435
////////////////////////////////////////////////////////////////////////////////
3536
/// \brief Class that performs linear interpolation
3637
/// \see InterpLinearImpl
37-
class InterpLinear : public InterpBase
38+
class XMSINTERP_EXPORT InterpLinear : public InterpBase
3839
{
3940
public:
4041
static BSHP<InterpLinear> New();

xmsinterp/interpolate/InterpSignals.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//------------------------------------------------------------------------------
1010

1111
//----- Included files ---------------------------------------------------------
12+
#include <xmsinterp/xmsinterp_export.h>
1213
#include <boost/signals2.hpp>
1314

1415
//----- Forward declarations ---------------------------------------------------
@@ -21,16 +22,16 @@ namespace xms
2122
//----- Structs / Classes ------------------------------------------------------
2223

2324
//----- Function prototypes ----------------------------------------------------
24-
void inSetDataIndex(int val);
25-
void inFillWtArray(int id, double wt);
25+
XMSINTERP_EXPORT void inSetDataIndex(int val);
26+
XMSINTERP_EXPORT void inFillWtArray(int id, double wt);
2627

2728
namespace interp
2829
{
2930
namespace connectSet
3031
{
31-
boost::signals2::connection SetDataIndex(
32+
XMSINTERP_EXPORT boost::signals2::connection SetDataIndex(
3233
const boost::signals2::signal<void(int)>::slot_type& a_slot);
33-
boost::signals2::connection FillWtArray(
34+
XMSINTERP_EXPORT boost::signals2::connection FillWtArray(
3435
const boost::signals2::signal<void(int, double)>::slot_type& a_slot);
3536
}
3637
}

xmsinterp/interpolate/InterpUtil.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// 4. External library headers
1515

1616
// 5. Shared code headers
17+
#include <xmsinterp/xmsinterp_export.h>
1718
#include <xmscore/points/pt.h> // for Pt3d
1819
#include <xmscore/points/ptsfwd.h> // for Pt3d
1920
#include <xmscore/misc/DynBitset.h>
@@ -31,7 +32,7 @@ namespace xms
3132

3233
//----- Structs / Classes ------------------------------------------------------
3334
/// \brief Convenience struct used in interpolation utility functions
34-
struct InterpPtInfo
35+
struct XMSINTERP_EXPORT InterpPtInfo
3536
{
3637
public:
3738
Pt3d m_loc; ///< location of interest
@@ -40,28 +41,28 @@ struct InterpPtInfo
4041
};
4142

4243
//----- Function prototypes ----------------------------------------------------
43-
void inNodalFuncSetUpMatrixAndVector(double xk,
44+
XMSINTERP_EXPORT void inNodalFuncSetUpMatrixAndVector(double xk,
4445
double yk,
4546
double fk,
4647
const std::vector<InterpPtInfo>& closest,
4748
double** M,
4849
double* VV);
49-
void inNodalFuncSetUpMatrixAndVector3d(double xk,
50+
XMSINTERP_EXPORT void inNodalFuncSetUpMatrixAndVector3d(double xk,
5051
double yk,
5152
double zk,
5253
double fk,
5354
const std::vector<InterpPtInfo>& closest,
5455
double** M,
5556
double* VV);
56-
void inDistanceSquared(const Pt3d& a_pt,
57+
XMSINTERP_EXPORT void inDistanceSquared(const Pt3d& a_pt,
5758
const std::vector<int>& a_ptIdxs,
5859
const std::vector<Pt3d>& a_ptLoc,
5960
bool a_2d,
6061
std::vector<double>& a_d2);
61-
void inIdwWeights(const std::vector<double>& a_d2,
62+
XMSINTERP_EXPORT void inIdwWeights(const std::vector<double>& a_d2,
6263
double a_power,
6364
bool a_modifiedShepardWeights,
6465
std::vector<double>& a_w);
65-
bool inAllScalarsEqual(const std::vector<float>& a_scalar, const DynBitset& a_act);
66+
XMSINTERP_EXPORT bool inAllScalarsEqual(const std::vector<float>& a_scalar, const DynBitset& a_act);
6667

6768
} // namespace xms

xmsinterp/interpolate/detail/AnisotropicInterpolator.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//------------------------------------------------------------------------------
88

99
//----- Included files ---------------------------------------------------------
10+
#include <xmsinterp/xmsinterp_export.h>
1011
#include <xmscore/misc/base_macros.h>
1112
#include <xmscore/misc/boost_defines.h>
1213
#include <xmscore/points/ptsfwd.h>
@@ -25,7 +26,7 @@ namespace xms
2526

2627
////////////////////////////////////////////////////////////////////////////////
2728
/// \brief Hold data of transforming from xyz to station,normal space
28-
struct SNResult
29+
struct XMSINTERP_EXPORT SNResult
2930
{
3031
/// \brief Construct a station normal result
3132
/// \param[in] a_index The index of the centerline segment contain the station
@@ -51,7 +52,7 @@ struct SNResult
5152

5253
////////////////////////////////////////////////////////////////////////////////
5354
/// \brief 2D Line definition. If vertical m_slope is Nan.
54-
struct LineParameters
55+
struct XMSINTERP_EXPORT LineParameters
5556
{
5657
/// \brief Constructor from slope and intercept
5758
/// \param[in] a_slope The slope. Use kVERTICAL for vertical lines.
@@ -88,7 +89,7 @@ typedef std::vector<SNResult> VecSNResult;
8889
/// weighting (raised to a power) from the interpolation points will be used to
8990
/// compute the interpolated z value. This is an internal implementation class
9091
/// used by InterpAnisotropic.
91-
class AnisotropicInterpolator
92+
class XMSINTERP_EXPORT AnisotropicInterpolator
9293
{
9394
public:
9495
AnisotropicInterpolator();

xmsinterp/interpolate/detail/InterpCt.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
//----- Included files ---------------------------------------------------------
1010
#include <vector>
11+
#include <xmsinterp/xmsinterp_export.h>
1112
#include <xmscore/points/ptsfwd.h>
1213
#include <xmscore/misc/base_macros.h>
1314
#include <xmscore/misc/boost_defines.h>
@@ -22,7 +23,7 @@ class NodalFunc;
2223
//----- Constants / Enumerations -----------------------------------------------
2324

2425
//----- Structs / Classes ------------------------------------------------------
25-
class InterpCt
26+
class XMSINTERP_EXPORT InterpCt
2627
{
2728
public:
2829
/// Triangle region enumeration
@@ -52,4 +53,4 @@ class InterpCt
5253
/// \endcond
5354
};
5455
//----- Function prototypes ----------------------------------------------------
55-
}
56+
}

xmsinterp/interpolate/detail/InterpNatNeigh.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
//----- Included files ---------------------------------------------------------
1010
#include <vector>
11+
#include <xmsinterp/xmsinterp_export.h>
1112
#include <xmscore/misc/base_macros.h>
1213
#include <xmscore/misc/boost_defines.h>
1314
#include <xmscore/points/ptsfwd.h>
@@ -25,7 +26,7 @@ class GmTriSearch;
2526
//----- Structs / Classes ------------------------------------------------------
2627
/// \brief Class that performs natural neighbor interpolation
2728
/// \see InterpNatNeighImpl
28-
class InterpNatNeigh
29+
class XMSINTERP_EXPORT InterpNatNeigh
2930
{
3031
public:
3132
static boost::shared_ptr<InterpNatNeigh> New(const std::vector<Pt3d>& a_pts,
@@ -50,4 +51,4 @@ class InterpNatNeigh
5051
InterpNatNeigh();
5152
};
5253
//----- Function prototypes ----------------------------------------------------
53-
}
54+
}

0 commit comments

Comments
 (0)