Skip to content

Commit

Permalink
Fix building static libs
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 22, 2021
1 parent 8ee2236 commit 12f3e54
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/spatialindex/capi/sidx_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#pragma once

#ifndef SIDX_C_DLL
#if defined(_MSC_VER)
#if defined(_MSC_VER) && defined(SIDX_DLL_EXPORT)
# define SIDX_C_DLL __declspec(dllexport)
# define SIDX_DLL __declspec(dllexport)
#else
Expand Down
2 changes: 1 addition & 1 deletion include/spatialindex/tools/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#ifdef SIDX_DLL_EXPORT
#define SIDX_DLL __declspec(dllexport)
#else
#define SIDX_DLL __declspec(dllimport)
#define SIDX_DLL
#endif

// Nuke this annoying warning. See http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html
Expand Down
21 changes: 13 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,13 @@ set(SIDX_SOURCES
${SIDX_HPP}
${SIDX_CPP})

add_library(spatialindex ${SIDX_SOURCES})

add_library(spatialindex_c ${SIDX_CAPI_CPP})
if(BUILD_SHARED_LIBS)
add_library(spatialindex SHARED ${SIDX_SOURCES})
add_library(spatialindex_c SHARED ${SIDX_CAPI_CPP})
else(BUILD_SHARED_LIBS)
add_library(spatialindex STATIC ${SIDX_SOURCES})
add_library(spatialindex_c STATIC ${SIDX_CAPI_CPP})
endif(BUILD_SHARED_LIBS)

target_link_libraries(spatialindex_c spatialindex)

Expand All @@ -204,11 +208,12 @@ if(MSVC)
target_compile_options(spatialindex PRIVATE /wd4068)
target_compile_options(spatialindex_c PRIVATE /wd4068)

target_compile_definitions(spatialindex_c PRIVATE -DSIDX_DLL_EXPORT=1)
target_compile_definitions(spatialindex PRIVATE -DSIDX_DLL_EXPORT=1)
if(NOT WITH_STATIC_SIDX)
target_compile_definitions(spatialindex PRIVATE -DSIDX_DLL_IMPORT=1)
target_compile_definitions(spatialindex_c PRIVATE -DSIDX_DLL_IMPORT=1)
if (BUILD_SHARED_LIBS)
target_compile_definitions(spatialindex PRIVATE -DSIDX_DLL_EXPORT=1)
target_compile_definitions(spatialindex_c PRIVATE -DSIDX_DLL_EXPORT=1)
else()
target_compile_definitions(spatialindex PRIVATE -DSIDX_DLL_IMPORT=1)
target_compile_definitions(spatialindex_c PRIVATE -DSIDX_DLL_IMPORT=1)
endif()
endif()

Expand Down

0 comments on commit 12f3e54

Please sign in to comment.