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

Fix CMake configuration on Windows #22

Merged
merged 1 commit into from
Jun 25, 2019

Conversation

myd7349
Copy link
Contributor

@myd7349 myd7349 commented Jun 23, 2019

  • Do not define MI_MALLOC_OVERRIDE when built as a static library
  • Use different output names for shared lib and static lib

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

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

Disclaimer: I am not affiliated with this project, just very interested.

I do agree that the goals of this PR are sound. I left a few minor suggestions to make it easier on future contributors.

CMakeLists.txt Outdated
@@ -111,14 +110,28 @@ endif()
add_library(mimalloc SHARED ${mi_sources})
set_target_properties(mimalloc PROPERTIES VERSION ${mi_version} NO_SONAME "YES" OUTPUT_NAME ${mi_basename} )
target_compile_definitions(mimalloc PRIVATE ${mi_defines} MI_SHARED_LIB MI_SHARED_LIB_EXPORT)
target_compile_definitions(mimalloc PRIVATE $<$<BOOL:${OVERRIDE}>:MI_MALLOC_OVERRIDE>)
Copy link
Member

Choose a reason for hiding this comment

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

It might be easier to read for non-CMake experts (such as myself) if there was an if(OVERRIDE MATCHES "ON")...endif guard around a list(APPEND mi_defines MI_MALLOC_OVERRIDE here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey! @dscho Thanks for your kindly review. I have updated the PR. :-)

CMakeLists.txt Outdated
if(NOT WIN32)
# It is only possible to override malloc on Windows when building as a DLL.
# (src/alloc-override.c)
target_compile_definitions(mimalloc-static PRIVATE $<$<BOOL:${OVERRIDE}>:MI_MALLOC_OVERRIDE>)
Copy link
Member

Choose a reason for hiding this comment

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

Here, too, it might make sense to imitate the if(OVERRIDE MATCHES "ON") block that was edited, and why not just move that into the else() clause a couple lines above?

CMakeLists.txt Outdated
if(NOT WIN32)
# It is only possible to override malloc on Windows when building as a DLL.
# (src/alloc-override.c)
target_compile_definitions(mimalloc-obj PRIVATE $<$<BOOL:${OVERRIDE}>:MI_MALLOC_OVERRIDE>)
Copy link
Member

Choose a reason for hiding this comment

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

Here, too, I think it would make sense to just insert this block instead:

if(OVERRIDE MATCHES "ON")
  list(APPEND mi_defines MI_MALLOC_OVERRIDE)
endif()

It is easier to read, as it imitates the rather idiomatic (and simple) CMake style used in the rest of the file. This is particularly important when one keeps in mind that most developers do not really want to become CMake experts.

- Do not define MI_MALLOC_OVERRIDE when built as a static library
- Use different output names for shared lib and static lib
@daanx
Copy link
Collaborator

daanx commented Jun 25, 2019

Thanks so much!

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

3 participants