Skip to content

Commit

Permalink
Fix build with cmake under windows.
Browse files Browse the repository at this point in the history
Fix build with MSVC, let cmake manage boost selection settings.
  • Loading branch information
correa committed Dec 2, 2015
1 parent f7b84bf commit 358803e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,30 +244,31 @@ else()
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
set(Boost_USE_MULTITHREADED ON)

set(Boost_USE_STATIC_RUNTIME ON)
endif()
set(Boost_USE_STATIC_LIBS ON)
add_library(torrent-rasterbar STATIC ${sources2})
endif()

# Boost
if(NOT DEFINED Boost_INCLUDE_DIR OR NOT DEFINED Boost_LIBRARIES)
FIND_PACKAGE(Boost REQUIRED COMPONENTS system chrono random)
endif()
include_directories(${Boost_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(torrent-rasterbar ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

# this works around a bug in asio in boost-1.39
#add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -D__USE_W32_SOCKETS -DWIN32_LEAN_AND_MEAN )

if(NOT static_runtime)
add_definitions(-DBOOST_SYSTEM_DYN_LINK -DBOOST_CHRONO_DYN_LINK -DBOOST_RANDOM_DYN_LINK)
endif()

if (WIN32)
target_link_libraries(torrent-rasterbar wsock32 ws2_32)
target_link_libraries(torrent-rasterbar wsock32 ws2_32 Iphlpapi)
add_definitions(-D_WIN32_WINNT=0x0600)
# prevent winsock1 to be included
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DWIN32_LEAN_AND_MEAN -DTORRENT_EXPORT_EXTRA)
if (MSVC)
add_definitions(-DBOOST_ALL_NO_LIB)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # multicore compilation
endif()
endif()
Expand Down

0 comments on commit 358803e

Please sign in to comment.