Skip to content
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

Cmake build for msvc #41

Merged
merged 1 commit into from Feb 14, 2019
Merged

Cmake build for msvc #41

merged 1 commit into from Feb 14, 2019

Conversation

phlptp
Copy link
Contributor

@phlptp phlptp commented Feb 13, 2019

If merged this PR will resolve a conflict in parser_complex_test in MSVC
It also adds folders to the CMAKE build and a few other items to make it easier to work with on Visual Studio and other IDE builds.

Fix builder_test::build_parse_string_01 which was failing on Visual studio, something with UTF strings, basically made the string literal u8 instead of a regular string literal in the build function.


using namespace std;

#elif defined(_WIN32)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am actually not entirely certain what this is doing since it seems to work just fine If I comment it out the #define or leave it in. Not sure if it is a MSC_VER issue so it is needed in older versions. What I know if both the `#define timegm and using toml::timegm are active it doesn't compile.

Copy link
Owner

Choose a reason for hiding this comment

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

IIRC, code around here is for cygwin environment.

function(add_toml_test target)
add_executable(${target}_test ${target}_test.cc)
add_executable(${target}_test ${target}_test.cc ../include/toml/toml.h)
Copy link
Owner

Choose a reason for hiding this comment

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

Adding .h seems weird to me. Here, adding toml.h as an input src. It will work, though...

Copy link
Owner

Choose a reason for hiding this comment

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

maybe you just want to add toml.h as a dependency, right?
Then what we need is target_include_directories (or include_directories).
https://stackoverflow.com/questions/13703647/how-to-properly-add-include-directories-with-cmake

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue is not about code dependencies, I think that was working correctly as it was. It was about actually seeing the project in visual studio. And the basic issue was toml.h wasn't showing up anywhere in the project hierarchy, so the project was kind of a pain to work with as the main file wasn't showing up anywhere. So this isn't adding much if anything to the chain, but it does make it lot easier to work with the project and target in Visual studio, and shouldn't affect it in other builds.

The other option is to make a dummy target with just toml.h in it to work with, but this is what I have seen done in some other header only libraries and have used in the past.

Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, I haven't cared for *.vcproj at al... I'm not so sure what the best practice is when considering all platforms, but ok for now.

src/build.h Outdated
@@ -288,7 +288,7 @@ inline toml::Value build_string_01(void)
toml::Value root((toml::Table()));
toml::Value* top = &root;

top->setChild("s1", "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF.");
top->setChild("s1", u8"I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF.");
Copy link
Owner

Choose a reason for hiding this comment

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

could you keep indent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure will do. I will update and rebase and collapse the commits

…ws based systems interacted badly, so this change makes sure they both can't turn on at the same time on MSVC

update some of the cmake code and one test to build and pass on MSVC
Copy link
Owner

@mayah mayah left a comment

Choose a reason for hiding this comment

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

ok

@mayah mayah merged commit f5a2013 into mayah:master Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants