Skip to content

Commit

Permalink
Don't try to link against libstdc++ library in try_compile on MSVC.
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
zrax committed Jul 5, 2016
1 parent ec48486 commit a96580f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ endif()
try_compile(ST_HAVE_CXX17_FILESYSTEM "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/cmake/check_filesystem.cpp")
if(NOT ST_HAVE_CXX17_FILESYSTEM)
if(CMAKE_COMPILER_IS_GNUCXX)
set(ST_CXXFS_LIBS stdc++fs)
endif()
try_compile(ST_HAVE_EXPERIMENTAL_FILESYSTEM "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/cmake/check_filesystem.cpp"
COMPILE_DEFINITIONS "-DTRY_EXPERIMENTAL_FILESYSTEM"
LINK_LIBRARIES stdc++fs)
LINK_LIBRARIES ${ST_CXXFS_LIBS})
endif()

include(CheckTypeSize)
Expand Down Expand Up @@ -182,8 +185,8 @@ if(WIN32)
set_target_properties(string_theory PROPERTIES DEBUG_POSTFIX "d")
endif()

if(ST_HAVE_EXPERIMENTAL_FILESYSTEM AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(string_theory stdc++fs)
if(ST_HAVE_EXPERIMENTAL_FILESYSTEM)
target_link_libraries(string_theory ${ST_CXXFS_LIBS})
endif()

# Note: Using <major>.0 so the library name doens't change between minor
Expand Down

0 comments on commit a96580f

Please sign in to comment.