Skip to content

minimal required fix to fully compile'n'link on Visual Studio 2017 #4467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

christianparpart
Copy link
Member

Hi,

this is the minimal version of my fix to properly compile and link on Visual Studio 2017 (latest version).

I am not sure how on earth other people can properly link without that change, except, that my VS2017 is maybe to new and the fact, that I am using the native Visual Studio's support for CMake files (that is: I am not using generated .sln files).

I will however provide a second PR (linking this one) with some more changes I'd like to see on top, closely related to building Solidity on Windows via Visual Studio.

Copy link
Contributor

@chriseth chriseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chfast could you please take a quick look here?

@@ -35,6 +35,7 @@ ExternalProject_Add(jsoncpp-project
-DJSONCPP_WITH_TESTS=OFF
-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF
-DCMAKE_CXX_FLAGS=${JSONCPP_EXTRA_FLAGS}
-DCMAKE_BUILD_TYPE=Release
# Overwrite build and install commands to force Release build on MSVC.
BUILD_COMMAND cmake --build <BINARY_DIR> --config Release
INSTALL_COMMAND cmake --build <BINARY_DIR> --config Release --target install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this --config Release override the args above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axic, nope, the --config part is for stage 2 (build) and stage 3 (install), but not for stage 1 (bootstrap). That is exactly why it took me so long to catch. :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So CMake ignores CMAKE_BUILD_TYPE variable when generating for Visual Studio because it's multi-configuration generator and the config is requested with --config Release (or via dropdown menu in VS).

I expect the jsoncpp's CMake script incorrectly checks CMAKE_BUILD_TYPE on Windows and that's why this fix works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to leave a comment in there explaining this? Also anybody feels like checking jsoncpp's cmake file and fixing it? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chfast so I checked the build files of jsoncpp, and it's not reading the CMAKE_BUILD_TYPE var when compiling on Windows platform. So I am inclined to believe that VS2017 (at least) is interpreting this value when using the native builtin cmake support (FYI: I do not generate .sln files with cmake but open the CMakeLists.txt as solution file instead.)

I'll close this ticket however, because the other PR makes this PR redundant. Thanks anyways. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants