Skip to content

Commit

Permalink
Fix shared library building failure on Windows with non MSVC
Browse files Browse the repository at this point in the history
For example, now we can built shared library on Window with MinGW.

This changes improve features added in #1467.
  • Loading branch information
podsvirov committed Jun 10, 2020
1 parent f593aad commit fe97a03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,15 @@ if(NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
list(APPEND SPDLOG_SRCS src/fmt.cpp)
endif()

if(WIN32 AND SPDLOG_BUILD_SHARED)
list(APPEND SPDLOG_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()

if(SPDLOG_BUILD_SHARED)
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
list(APPEND SPDLOG_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()
add_library(spdlog SHARED ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS})
target_compile_definitions(spdlog PUBLIC SPDLOG_SHARED_LIB)
if(WIN32)
if(MSVC)
target_compile_options(spdlog PUBLIC /wd4251 /wd4275)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
endif()
if(NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
target_compile_definitions(spdlog PRIVATE FMT_EXPORT PUBLIC FMT_SHARED)
Expand Down
2 changes: 1 addition & 1 deletion cmake/version.rc.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define APSTUDIO_READONLY_SYMBOLS
#include "winres.h"
#include <windows.h>
#undef APSTUDIO_READONLY_SYMBOLS

LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
Expand Down

0 comments on commit fe97a03

Please sign in to comment.