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: Fix configuration on Win32 #2323

Closed
wants to merge 1 commit into from

Conversation

myd7349
Copy link
Contributor

@myd7349 myd7349 commented May 11, 2019

On Windows with MSVC, this line:

check_library_exists(m pow "" WITH_HDRHISTOGRAM)

causes WITH_HDRHISTOGRAM set to OFF.
As a result:

  • When specifying WITHOUT_WIN32_CONFIG=ON, the histogram source will not be built.
  • When specifying WITHOUT_WIN32_CONFIG=OFF, there will be link erros since WITH_HISTOGRAM is defined as 1 in win32_config.h

References:
https://stackoverflow.com/questions/32816646/can-cmake-detect-if-i-need-to-link-to-libm-when-using-pow-in-c

@myd7349
Copy link
Contributor Author

myd7349 commented May 11, 2019

The configuration step on Win32 through CMake still have room for improvement. For example, the meaning of WITHOUT_WIN32_CONFIG is confusing
The doc string of this option is:

Avoid including win32_config.h on cmake builds

but rd.h will always include this header when built with MSVC.

I have a more aggressive patch here: myd7349@24965ee
If this patch is preferable, I'd like to add more commits to this PR.

CMakeLists.txt Outdated
@@ -35,7 +35,12 @@ endif()

# LIBM {
include(CheckLibraryExists)
check_library_exists(m pow "" WITH_HDRHISTOGRAM)
check_library_exists(m pow "" HAVE_LIBM)
Copy link
Contributor

Choose a reason for hiding this comment

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

On MSVC we don't need to, and probably shouldnt, check for libm at all.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@edenhill Thanks for your review! I will update this PR later.

@edenhill
Copy link
Contributor

I think I like the more aggressive approach, better to get this all right in one go.

@myd7349 myd7349 force-pushed the win32-cmake-config branch from 8f15751 to 3f84c98 Compare May 21, 2019 12:30
@myd7349
Copy link
Contributor Author

myd7349 commented May 21, 2019

Here is a related discussion about libm: mesonbuild/meson#5390 (comment)

@myd7349 myd7349 changed the title CMake: Fix hdr histogram compilation check for MSVC CMake: Fix configuration on Win32 May 21, 2019
- Remove WITHOUT_WIN32_CONFIG option
- Fix hdr histogram check
- Fix WITH_PLUGINS check
- Specify _CRT_SECURE_NO_WARNINGS
- Fix MSVC ARM64 check
- Fix __ARM_ARCH_6KZ__ typo
@myd7349
Copy link
Contributor Author

myd7349 commented Aug 1, 2019

snappy support doesn't work out-of-box, reported by @rotrida:
microsoft/vcpkg#7456
To enable it, we have to pass an extra option:

cmake -DWITH_SNAPPY=ON

the problem is that, WITH_SNAPPY is not an option defined like this:

option(WITH_SNAPPY ...)

@edenhill
Copy link
Contributor

edenhill commented Aug 1, 2019

@myd7349 WITH_SNAPPY should always be set to 1 in CMakeLists.txt

@myd7349 myd7349 closed this Aug 15, 2022
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.

2 participants