Skip to content

Commit 156b490

Browse files
authored
Merge pull request #104 from LLNL/fix-windows-shared
fix build and install of windows DLLs
2 parents 3c12c0c + a61dadd commit 156b490

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

CMakeLists.txt

+14-7
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ blt_add_library (
106106
SOURCES ./src/errors.cpp
107107
DEPENDS_ON ${camp_depends}
108108
)
109+
110+
if (COMPILER_FAMILY_IS_MSVC)
111+
if (NOT BUILD_SHARED_LIBS)
112+
target_compile_definitions(camp PUBLIC WIN_STATIC_BUILD)
113+
else (NOT BUILD_SHARED_LIBS)
114+
target_compile_definitions(camp PRIVATE CAMP_DLL_EXPORTS)
115+
endif (NOT BUILD_SHARED_LIBS)
116+
endif ()
117+
109118
target_include_directories (camp PUBLIC
110119
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
111120
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
@@ -123,14 +132,12 @@ write_basic_package_version_file(
123132
COMPATIBILITY AnyNewerVersion
124133
)
125134

126-
install(TARGETS camp
135+
install(TARGETS
136+
camp
127137
EXPORT campTargets
128-
LIBRARY DESTINATION lib COMPONENT Runtime
129-
ARCHIVE DESTINATION lib COMPONENT Development
130-
RUNTIME DESTINATION bin COMPONENT Runtime
131-
PUBLIC_HEADER DESTINATION include COMPONENT Development
132-
BUNDLE DESTINATION bin COMPONENT Runtime
133-
)
138+
RUNTIME DESTINATION lib
139+
LIBRARY DESTINATION lib
140+
ARCHIVE DESTINATION lib)
134141

135142
include(CMakePackageConfigHelpers)
136143
configure_package_config_file(

include/camp/config.in.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@
1414
#define CAMP_VERSION (CAMP_VERSION_MAJOR * 1000000) \
1515
+(CAMP_VERSION_MINOR * 1000) \
1616
+(CAMP_VERSION_PATCH)
17+
18+
#if (defined(_WIN32) || defined(_WIN64)) && !defined(CAMP_WIN_STATIC_BUILD)
19+
#ifdef CAMP_DLL_EXPORTS
20+
#define CAMP_DLL_EXPORT __declspec(dllexport)
21+
#else
22+
#define CAMP_DLL_EXPORT __declspec(dllimport)
23+
#endif
24+
#else
25+
#define CAMP_DLL_EXPORT
26+
#endif

include/camp/defines.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ using nullptr_t = decltype(nullptr);
177177
}
178178

179179
/// Throw a runtime_error, avoid including exception everywhere
180-
void throw_re(const char *s);
180+
CAMP_DLL_EXPORT void throw_re(const char *s);
181181

182182
#ifdef CAMP_ENABLE_CUDA
183183

184184
#define campCudaErrchk(ans) ::camp::cudaAssert((ans), #ans, __FILE__, __LINE__)
185185

186-
cudaError_t cudaAssert(cudaError_t code,
186+
CAMP_DLL_EXPORT cudaError_t cudaAssert(cudaError_t code,
187187
const char *call,
188188
const char *file,
189189
int line);
@@ -195,7 +195,7 @@ cudaError_t cudaAssert(cudaError_t code,
195195

196196
#define campHipErrchk(ans) ::camp::hipAssert((ans), #ans, __FILE__, __LINE__)
197197

198-
hipError_t hipAssert(hipError_t code,
198+
CAMP_DLL_EXPORT hipError_t hipAssert(hipError_t code,
199199
const char *call,
200200
const char *file,
201201
int line);

0 commit comments

Comments
 (0)