Skip to content

Commit 6c05e43

Browse files
committed
- added option to build as shared library
1 parent aba3da1 commit 6c05e43

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

CMakeLists.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ if(CUNSEARCH_USE_DOUBLE_PRECISION)
1818
add_compile_options(-DCUNSEARCH_USE_DOUBLE_PRECISION)
1919
endif(CUNSEARCH_USE_DOUBLE_PRECISION)
2020

21+
OPTION(BUILD_AS_SHARED_LIBS "Build all the libraries as shared" OFF)
22+
if (BUILD_AS_SHARED_LIBS)
23+
add_definitions( -DBUILD_AS_SHARED_LIBS)
24+
if(WIN32)
25+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON CACHE BOOL "Export all symbols")
26+
endif(WIN32)
27+
endif (BUILD_AS_SHARED_LIBS)
28+
2129
set(CMAKE_CXX_STANDARD 11)
2230
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2331
SET(CMAKE_DEBUG_POSTFIX "_d")
@@ -54,16 +62,31 @@ set (SOURCE_FILES
5462
Utils/IDFactory.cpp
5563
)
5664

57-
add_library(cuNSearch STATIC ${INCLUDE_HEADERS} ${HEADER_FILES} ${SOURCE_FILES})
65+
if(BUILD_AS_SHARED_LIBS)
66+
add_library(cuNSearch SHARED ${INCLUDE_HEADERS} ${HEADER_FILES} ${SOURCE_FILES})
67+
else()
68+
add_library(cuNSearch STATIC ${INCLUDE_HEADERS} ${HEADER_FILES} ${SOURCE_FILES})
69+
endif()
70+
71+
include(GenerateExportHeader)
72+
generate_export_header(cuNSearch
73+
BASE_NAME cuNSearch
74+
EXPORT_MACRO_NAME cuNSearch_EXPORT
75+
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/cuNSearch/cuNSearch_export.h
76+
)
5877

5978
target_include_directories(cuNSearch PUBLIC
6079
"include"
6180
"Utils"
6281
${CUDA_INCLUDE_DIRS}
82+
${CMAKE_BINARY_DIR}/cuNSearch
6383
)
6484
target_link_libraries(cuNSearch PUBLIC ${CUDA_LIBRARIES})
6585
target_compile_definitions(cuNSearch PUBLIC $<$<CONFIG:DEBUG>:DEBUG>)
6686

87+
list(APPEND INCLUDE_HEADERS
88+
${CMAKE_CURRENT_BINARY_DIR}/cuNSearch/cuNSearch_export.h)
89+
6790
install(FILES ${INCLUDE_HEADERS}
6891
DESTINATION include/)
6992

Utils/Timing.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <chrono>
1616
#include "IDFactory.h"
17+
#include "cuNSearch_export.h"
1718

1819
namespace cuNSearch
1920
{
@@ -33,11 +34,11 @@ namespace cuNSearch
3334
class Timing
3435
{
3536
public:
36-
static bool m_dontPrintTimes;
37-
static unsigned int m_startCounter;
38-
static unsigned int m_stopCounter;
39-
static std::stack<TimingHelper> m_timingStack;
40-
static std::unordered_map<int, AverageTime> m_averageTimes;
37+
static cuNSearch_EXPORT bool m_dontPrintTimes;
38+
static cuNSearch_EXPORT unsigned int m_startCounter;
39+
static cuNSearch_EXPORT unsigned int m_stopCounter;
40+
static cuNSearch_EXPORT std::stack<TimingHelper> m_timingStack;
41+
static cuNSearch_EXPORT std::unordered_map<int, AverageTime> m_averageTimes;
4142

4243
static void reset()
4344
{

0 commit comments

Comments
 (0)