From 73973d2448fd0965b3aa988d18397e9dce6d949d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 17 May 2018 14:42:22 +0200 Subject: [PATCH 1/5] CMake: Fix libdir for jsoncpp external project in special case When building on Debian/Ubuntu with install prefix /usr (e.g. in PPA builds) the CMAKE_INSTALL_LIBDIR is resolved to lib/x86_64-linux-gnu. For jsoncpp external project this is never the case because the install prefix is not /usr. Remove multiarch part from libdir if there. --- cmake/jsoncpp.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index 3d6b37edf..cc2da7e7e 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -7,8 +7,14 @@ else() endif() include(GNUInstallDirs) +set(libdir ${CMAKE_INSTALL_LIBDIR}) +if(CMAKE_LIBRARY_ARCHITECTURE) + # Do not use Debian multiarch library dir. + string(REPLACE "/${CMAKE_LIBRARY_ARCHITECTURE}" "" libdir ${libdir}) +endif() + set(prefix "${CMAKE_BINARY_DIR}/deps") -set(JSONCPP_LIBRARY "${prefix}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") +set(JSONCPP_LIBRARY "${prefix}/${libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") set(JSONCPP_INCLUDE_DIR "${prefix}/include") if(NOT MSVC) From 1a5f90954a203db2dab53a569e9e6912457cee96 Mon Sep 17 00:00:00 2001 From: mingchuan Date: Wed, 6 Jun 2018 14:03:07 +0800 Subject: [PATCH 2/5] Fix cmake when custom CMAKE_INSTALL_LIBDIR is given According to cmake documents, we cannot assume CMAKE_INSTALL_LIBDIR is a relative path. This commit fixes the "no rule to make libjsoncpp.a" error by passing -DCMAKE_INSTALL_LIBDIR=lib to jsoncpp external project. --- cmake/jsoncpp.cmake | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index cc2da7e7e..0c110b532 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -6,15 +6,8 @@ else() set(JSONCPP_CMAKE_COMMAND ${CMAKE_COMMAND}) endif() -include(GNUInstallDirs) -set(libdir ${CMAKE_INSTALL_LIBDIR}) -if(CMAKE_LIBRARY_ARCHITECTURE) - # Do not use Debian multiarch library dir. - string(REPLACE "/${CMAKE_LIBRARY_ARCHITECTURE}" "" libdir ${libdir}) -endif() - set(prefix "${CMAKE_BINARY_DIR}/deps") -set(JSONCPP_LIBRARY "${prefix}/${libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") +set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") set(JSONCPP_INCLUDE_DIR "${prefix}/include") if(NOT MSVC) @@ -36,6 +29,7 @@ ExternalProject_Add(jsoncpp-project CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_INSTALL_LIBDIR=lib # Build static lib but suitable to be included in a shared lib. -DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS} -DJSONCPP_WITH_TESTS=OFF From 72b9ad6837b6d080e1646dbbd58219630fbf0021 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Tue, 10 Jul 2018 15:12:32 +0200 Subject: [PATCH 3/5] Visual Studio 2017 build-time (linking) fix and improvements --- .gitignore | 3 +++ cmake/EthCompilerSettings.cmake | 11 ----------- cmake/jsoncpp.cmake | 4 +--- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 14c227d05..87a3e5933 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ build/ docs/_build docs/utils/__pycache__ docs/utils/*.pyc +/deps/downloads/ # vim stuff *.swp @@ -43,3 +44,5 @@ docs/utils/*.pyc .idea browse.VC.db CMakeLists.txt.user +/CMakeSettings.json +/.vs diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 683d1d2e6..3ae5bf2ab 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -132,17 +132,6 @@ elseif (DEFINED MSVC) add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions - # Always use Release variant of C++ runtime. - # We don't want to provide Debug variants of all dependencies. Some default - # flags set by CMake must be tweaked. - string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/MDd" "/MD" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REPLACE "/D_DEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS OFF) - # disable empty object file warning set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") # warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index 0c110b532..e886c6092 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -35,9 +35,7 @@ ExternalProject_Add(jsoncpp-project -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF -DCMAKE_CXX_FLAGS=${JSONCPP_EXTRA_FLAGS} - # Overwrite build and install commands to force Release build on MSVC. - BUILD_COMMAND cmake --build --config Release - INSTALL_COMMAND cmake --build --config Release --target install + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${byproducts} ) From d2d9162bb95c2d3eb2ae57422b24ca5c3b69a935 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Thu, 19 Jul 2018 00:05:45 +0200 Subject: [PATCH 4/5] Propagate original CMAKE_CXX_FLAGS to jsoncpp compilation --- cmake/jsoncpp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index e886c6092..a6ca0e7fa 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -34,7 +34,7 @@ ExternalProject_Add(jsoncpp-project -DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS} -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF - -DCMAKE_CXX_FLAGS=${JSONCPP_EXTRA_FLAGS} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} ${JSONCPP_EXTRA_FLAGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${byproducts} ) From 84d92450767480dcd0748c781e3cbda8e4a82ebd Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 3 Aug 2018 16:50:08 +0200 Subject: [PATCH 5/5] Rename JSONCPP_EXTRA_FLAGS to JSONCPP_CXX_FLAGS, add EMSCRIPTEN workaround and remove obsolete MSVC workaround. --- cmake/jsoncpp.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index a6ca0e7fa..ea3218efc 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -10,8 +10,16 @@ set(prefix "${CMAKE_BINARY_DIR}/deps") set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") set(JSONCPP_INCLUDE_DIR "${prefix}/include") -if(NOT MSVC) - set(JSONCPP_EXTRA_FLAGS "-std=c++11") +# TODO: Investigate why this breaks some emscripten builds and +# check whether this can be removed after updating the emscripten +# versions used in the CI runs. +if(EMSCRIPTEN) + # Do not include all flags in CMAKE_CXX_FLAGS for emscripten, + # but only use -std=c++11. Using all flags causes build failures + # at the moment. + set(JSONCPP_CXX_FLAGS -std=c++11) +else() + set(JSONCPP_CXX_FLAGS ${CMAKE_CXX_FLAGS}) endif() set(byproducts "") @@ -34,7 +42,7 @@ ExternalProject_Add(jsoncpp-project -DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS} -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF - -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} ${JSONCPP_EXTRA_FLAGS} + -DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${byproducts} )