Skip to content

Commit

Permalink
Allow statically linked windows build in CMake.
Browse files Browse the repository at this point in the history
  • Loading branch information
ekpyron committed Sep 16, 2020
1 parent 79201f8 commit 860226e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmake/EthDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ set(ETH_SCRIPTS_DIR ${ETH_CMAKE_DIR}/scripts)
## use multithreaded boost libraries, with -mt suffix
set(Boost_USE_MULTITHREADED ON)
option(Boost_USE_STATIC_LIBS "Link Boost statically" ON)
if(WIN32)
option(Boost_USE_STATIC_RUNTIME "Link Boost against static C++ runtime libraries" ON)
endif()

set(BOOST_COMPONENTS "filesystem;unit_test_framework;program_options;system")

Expand Down
6 changes: 5 additions & 1 deletion cmake/EthPolicy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ macro (eth_policy)
# do not interpret if() arguments as variables!
cmake_policy(SET CMP0054 NEW)
endif()
endmacro()

if (POLICY CMP0091)
# Allow selecting MSVC runtime library using CMAKE_MSVC_RUNTIME_LIBRARY.
cmake_policy(SET CMP0091 NEW)
endif()
endmacro()
7 changes: 7 additions & 0 deletions cmake/jsoncpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ if(CMAKE_VERSION VERSION_GREATER 3.1)
set(byproducts BUILD_BYPRODUCTS "${JSONCPP_LIBRARY}")
endif()

# Propagate CMAKE_MSVC_RUNTIME_LIBRARY on Windows builds, if set.
if (WIN32 AND POLICY CMP0091 AND CMAKE_MSVC_RUNTIME_LIBRARY)
list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW")
list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}")
endif()

ExternalProject_Add(jsoncpp-project
PREFIX "${prefix}"
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads"
Expand All @@ -51,6 +57,7 @@ ExternalProject_Add(jsoncpp-project
-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF
-DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${JSONCPP_CMAKE_ARGS}
${byproducts}
)

Expand Down

0 comments on commit 860226e

Please sign in to comment.