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

Allow building with cmake (to ease building on windows) #16

Closed
wants to merge 3 commits into from

Conversation

trondn
Copy link

@trondn trondn commented Jan 27, 2016

The patch series allows for building on windows with the following steps:

git clone git://github.com/trondn/snappy
mkdir build
cd build
cmake -G "NMake Makefiles" ..\snappy
nmake all test

(It should also build on unix systems by dropping the "-G NMake Makefiles" part)

@Optiligence
Copy link

Just my 2 cents when i see this:
https://cmake.org/cmake/help/v3.4/module/GenerateExportHeader.html
https://cmake.org/cmake/help/v3.4/module/CMakePackageConfigHelpers.html (omitting this disregards an integral part of the cmake ecosystem)
for the vs compile fix see #10

(This allows for easier builds on Windows)
Auto generated by CLion to cover cmake, c/c++ and autotools
@trondn
Copy link
Author

trondn commented Jan 27, 2016

I've never used the GenerateExportHeader or PackageConfig thing before :-) Updated the set to use that

@Nulifier
Copy link

Nulifier commented Feb 5, 2016

Your config.h.in file doesn't work for MSVC 2015. You need to either check for _MSC_VER <= 1900 or increment it as it still doesn't have ssize_t.

@jakirkham
Copy link

Would be great if this works on VS 2008 also.

@ccleve
Copy link

ccleve commented Aug 9, 2016

I cloned today's version of google/snappy and applied this pull request to it. It built fine and the unit tests ran fine as well. I'm on Windows 10 with Visual Studio 14. There were a few compile warnings (attached).

If the warnings are not of concern, then please accept this PR. It'll make building projects that depend on snappy easier.
warnings.txt

@rapoth
Copy link

rapoth commented Aug 27, 2016

@trondn Thank you for submitting this PR! I can confirm this works on today's version of google/snappy with similar warnings with Visual Studio 14 2015 on Windows 10.

When I run the unit tests, I get a warning:

Running microbenchmarks.
WARNING: Compiled without optimization, will be slow.

Do you by any chance happen to know why?

Copy link
Contributor

@vrabaud vrabaud left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me !


# I haven't looked at what the soname for the previous
# versions of snappy... let's just start with 1.1.3
SET(SNAPPY_SONAME "1.1.3")
Copy link
Contributor

Choose a reason for hiding this comment

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

That variable is useless now that you use SNAPPY_MAJOR in SET_TARGET_PROPERTIES.

@@ -0,0 +1,155 @@
PROJECT(Snappy C CXX)
Copy link
Contributor

Choose a reason for hiding this comment

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

The project is CXX only no ?

Copy link
Contributor

Choose a reason for hiding this comment

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

We export a C only API by wrapping the C++ code. See snappy-c.h.


TEST_BIG_ENDIAN(WORDS_BIG_ENDIAN)
IF (WORDS_BIG_ENDIAN)
MESSAGE(STATUS "Builing on big endian system")
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: Building

Copy link
Contributor

@vrabaud vrabaud left a comment

Choose a reason for hiding this comment

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

That should probably be its own PR no ? The smaller the PR, the better.

@vrabaud
Copy link
Contributor

vrabaud commented Feb 8, 2017

The three commits should probably be independent PR, not to lose track of the awesomeness of the CMake commit :)

@vrabaud
Copy link
Contributor

vrabaud commented Feb 8, 2017

For the warning in VS, maybe you can add something like:

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release" CACHE
    "Build type: Release, Debug or RelWithDebInfo" STRING FORCE
  )
endif()


ADD_DEFINITIONS(-DHAVE_CONFIG_H)

INCLUDE_DIRECTORIES(BEFORE ${Snappy_SOURCE_DIR})
Copy link
Contributor

@alkis alkis Feb 8, 2017

Choose a reason for hiding this comment

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

Forgive my Cmake noobishness, but Cmake best practices says do not use include_directories but target_include_directories instead.

ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF (WIN32)

ADD_DEFINITIONS(-DHAVE_CONFIG_H)
Copy link
Contributor

Choose a reason for hiding this comment

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

target_add_definitions instead?

@@ -68,6 +69,7 @@ typedef enum {
* }
* free(output);
*/
SNAPPY_PUBLIC_API
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to remove all SNAPPY_PUBLIC_API and use WINDOWS_EXPORT_ALL_SYMBOLS instead?

@jakirkham
Copy link

jakirkham commented Mar 22, 2017

Not to be noisy, but is there any news on this PR?

Edit: I guess the work is continuing in PR ( #29 ).

@alkis
Copy link
Contributor

alkis commented Jun 2, 2017

Closing this because CMake support has been added internally and will be part of the next release.

@alkis alkis closed this Jun 2, 2017
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.

8 participants