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

Get rid of CMake export headers #41

Merged
merged 1 commit into from
Jan 7, 2022
Merged

Conversation

athre0z
Copy link
Member

@athre0z athre0z commented Jan 4, 2022

This PR gets rid of the CMake generated ZycoreExportConfig.h header. It's annoying to deal with in non-CMake environments because CMake generates it for one specific compiler (so you can't just generate it once and use it everywhere) and also doesn't really provide much that we couldn't just as well detect at compile time.

Because the previous exports created by CMake were rather cryptic, I also took the opportunity to rename them:

  • ZYCORE_STATIC_DEFINE -> ZYCORE_STATIC_BUILD
  • Zycore_EXPORTS -> ZYCORE_SHOULD_EXPORT

There was a third define that we manually defined previously, ZYCORE_EXPORTS (mind the casing), which was seemingly unused, so I removed it.

Because we don't have CI here, I created a branch in the Zydis repo and updated the submodule. Builds just fine, results are here.

Once approved, I'll apply the same changes to Zydis.

@athre0z athre0z requested a review from flobernd January 4, 2022 15:19
@athre0z athre0z added A-build Area: Build system C-enhancement Category: Enhancement of existing features P-medium Priority: Medium labels Jan 4, 2022
@athre0z athre0z force-pushed the remove-generateexportheader branch from 9783473 to 38f7dc7 Compare January 4, 2022 15:23
SOVERSION ${Zycore_VERSION_MAJOR}.${Zycore_VERSION_MINOR})
VERSION "${Zycore_VERSION}"
SOVERSION "${Zycore_VERSION_MAJOR}.${Zycore_VERSION_MINOR}"
DEFINE_SYMBOL "ZYCORE_SHOULD_EXPORT")
Copy link
Member Author

Choose a reason for hiding this comment

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

This renames the default of Zycore_EXPORTS -> ZYCORE_SHOULD_EXPORT.

@athre0z athre0z force-pushed the remove-generateexportheader branch from 38f7dc7 to 9319c44 Compare January 4, 2022 15:34
Copy link
Member

@flobernd flobernd left a comment

Choose a reason for hiding this comment

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

LGTM!

Let's carefully test again after the Zydis follow-up PR.

@flobernd
Copy link
Member

flobernd commented Jan 5, 2022

Btw, could you please add something unrelated (must be right below the includes on top):

if (NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
if (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()

I found on Windows the .dll files are placed in sub-directories which makes it impossible to run/debug the applications in case of shared-build.

After adding the above lines, the libraries (shared and static) are always placed in the top-level binary directory.

For Zycore it should not make a difference, but for Zydis and Zyrex it improves things (will create a PR later, if you are fine with the changes).

@athre0z athre0z merged commit dd2211a into master Jan 7, 2022
@athre0z athre0z deleted the remove-generateexportheader branch January 7, 2022 10:30
@athre0z
Copy link
Member Author

athre0z commented Jan 7, 2022

Let's do that in a different PR after we figured out how to best do this in the discussion here.

@athre0z athre0z restored the remove-generateexportheader branch January 7, 2022 11:44
@athre0z athre0z deleted the remove-generateexportheader branch January 7, 2022 11:44
@Tachi107
Copy link
Contributor

I'm a bit late, but dropping GenerateExportHeader also means that all the header files will now be the same on all architectures, making it possible to install multiple copies of the zycore/zydis packages compiled for different architectures in Debian, useful in cross-compilation environments. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build Area: Build system C-enhancement Category: Enhancement of existing features P-medium Priority: Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants