Skip to content

Commit

Permalink
Fix linking problem for building DLL with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminghuang committed Apr 19, 2017
1 parent a94a3cd commit 7515fa3
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .travis/setenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ if [[ "$COMPILER" == "Emscripten" ]]; then
-w /mfast/build \
-t thewtex/cross-compiler-browser-asmjs "
else
export CONFIG_ARGS="-DCMAKE_CXX_COMPILER=$COMPILER"
fi
export CONFIG_ARGS="-DCMAKE_CXX_COMPILER=$COMPILER -DBUILD_SHARED_LIBS=ON"
fi
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ before_build:
- cmd: cd C:\projects\mfast
- cmd: md build
- cmd: cd build
- cmd: if "%platform%"=="Win32" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%configuration% -DBOOST_ROOT="%BOOST_ROOT%" ..
- cmd: if "%platform%"=="x64" cmake -G "%GENERATOR% Win64" -DCMAKE_BUILD_TYPE=%configuration% -DBOOST_ROOT="%BOOST_ROOT%" ..
- cmd: if "%platform%"=="Win32" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%configuration% -DBUILD_SHARED_LIB=ON -DBOOST_ROOT="%BOOST_ROOT%" ..
- cmd: if "%platform%"=="x64" cmake -G "%GENERATOR% Win64" -DCMAKE_BUILD_TYPE=%configuration% -DBUILD_SHARED_LIB=ON -DBOOST_ROOT="%BOOST_ROOT%" ..

build:
project: C:\projects\mfast\build\mfast.sln
Expand Down
13 changes: 11 additions & 2 deletions src/mfast/coder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@

file (GLOB_RECURSE headers "*.h") ## retrieve all header files in current directory
file (GLOB_RECURSE sources "*.cpp") ## retrieve all source files in current directory

set(sources common/dictionary_builder.cpp
decoder/decoder_field_operator.cpp
decoder/decoder_presence_map.cpp
decoder/fast_decoder.cpp
decoder/fast_istream.cpp
encoder/encoder_field_operator.cpp
encoder/fast_encoder.cpp
encoder/fast_ostreambuf.cpp
encoder_v2/fast_encoder_core.cpp
)


SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
Expand All @@ -26,7 +35,7 @@ set(MFAST_STATIC_COMPONENTS ${MFAST_STATIC_COMPONENTS} coder_static CACHE INTERN


if (BUILD_SHARED_LIBS)
add_library(mfast_coder SHARED ${mfast_coder_SRCS})
add_library(mfast_coder SHARED ${mfast_coder_SRCS} decoder_v2/fast_decoder_core.cpp)

if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.12")
target_compile_definitions(mfast_coder INTERFACE "-DMFAST_DYN_LINK")
Expand Down
2 changes: 2 additions & 0 deletions src/mfast/coder/decoder_v2/fast_decoder_core.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// required for MSVC when building DLL
#include "fast_decoder_core.h"
2 changes: 1 addition & 1 deletion src/mfast/coder/mfast_coder_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
#else
/* We are either using or building static libs */
#define MFAST_CODER_EXPORT
#define MAST_CODER_NO_SHARED_LIBS
#define MFAST_CODER_NO_SHARED_LIBS
#endif
#endif
2 changes: 1 addition & 1 deletion src/mfast/decimal_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#if defined __GNUC__
#pragma GCC diagnostic pop
#endif
#if defined(MAST_NO_SHARED_LIBS) && !defined(BOOST_NO_CXX11_EXTERN_TEMPLATE)
#if defined(MFAST_NO_SHARED_LIBS) && !defined(BOOST_NO_CXX11_EXTERN_TEMPLATE)
namespace boost {
namespace multiprecision {
namespace backends {
Expand Down
2 changes: 1 addition & 1 deletion src/mfast/json/mfast_json_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
#else
/* We are either using or building static libs */
#define MFAST_JSON_EXPORT
#define MAST_JSON_NO_SHARED_LIBS
#define MFAST_JSON_NO_SHARED_LIBS
#endif
#endif
2 changes: 1 addition & 1 deletion src/mfast/mfast_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/* We are either using or building static libs */
#define MFAST_EXPORT
#define MAST_NO_SHARED_LIBS
#define MFAST_NO_SHARED_LIBS
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/mfast/sqlite3/mfast_sqlite3_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#else
/* We are either using or building static libs */
#define MFAST_SQLITE3_EXPORT
#define MAST_SQLITE3_NO_SHARED_LIBS
#define MFAST_SQLITE3_NO_SHARED_LIBS
#endif
#endif

2 changes: 1 addition & 1 deletion src/mfast/xml_parser/mfast_xml_parser_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
#else
/* We are either using or building static libs */
#define MFAST_XML_PARSER_EXPORT
#define MAST_XML_PARSER_NO_SHARED_LIBS
#define MFAST_XML_PARSER_NO_SHARED_LIBS
#endif
#endif

0 comments on commit 7515fa3

Please sign in to comment.