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: msvc and release is a build failure #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

XMuli
Copy link

@XMuli XMuli commented Jul 14, 2022

No description provided.

Comment on lines 35 to 36
#else
#define QTACRYLICHELPER_API Q_DECL_EXPORT // Q_DECL_IMPORT
Copy link
Author

Choose a reason for hiding this comment

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

Of course deleting the following two lines directly will also fail to compile. Although it is a bit strange.

@XMuli
Copy link
Author

XMuli commented Jul 14, 2022

When switching to release, it will show that this macro is not defined. It is a bit inconsistent with the definition here

QTACRYLICHELPER_BUILD_LIBRARY

image

@moodyhunter
Copy link

I suspect this would be an incorrect fix :(
see also the template file from https://codereview.qt-project.org/c/qt/qtbase/+/356214

@XMuli
Copy link
Author

XMuli commented Jul 15, 2022

@moodyhunter But it does fail to compile (me too 😅)

Win10 21H2 + MSVC(2019) + Release

image

@moodyhunter
Copy link

strange. but I'm on a holiday trip, will investigate a bit once I'm back home.

@moodyhunter
Copy link

It seems that for a static build, QTACRYLICHELPER_STATIC isn't defined properly as it should be.

@moodyhunter
Copy link

@XMuli can you try adding...

if(NOT BUILD_SHARED_LIBS)
    target_compile_definitions(${PROJECT_NAME} PUBLIC QTACRYLICHELPER_STATIC)
endif()

to src/CMakeLists.txt and try rebuilding?

Note the PUBLIC keyword is required to populate this macro define to a downstream user project (that are, the ones under examples/)

@XMuli
Copy link
Author

XMuli commented Jul 18, 2022

It is running successfully. @moodyhunter thanks

But I am confused as follows:

if(BUILD_SHARED_LIBS)

BUILD_SHARED_LIBS is ON by default and generates shared (not static), why does it become static under release?

@moodyhunter
Copy link

I haven't experienced that before...
Can you try performing a clean build and verifying CMAKE_BUILD_TYPE and BUILD_SHARED_LIBS in CMakeCache.txt?

@XMuli
Copy link
Author

XMuli commented Jul 18, 2022

Okay, I'll try it when I get home tonight

@XMuli
Copy link
Author

XMuli commented Jul 19, 2022

The test is as follows(Win10 + VS2019 + CMake 3.3)
BUILD_SHARED_LIBS is OFF by default.

ON: Generate (.dll + .exp + .lib)
OFF: Generate (.lib)

@XMuli
Copy link
Author

XMuli commented Jul 21, 2022

Modified the commit to generate .dll by default

to avoid direct run failures and confusion

@@ -3,6 +3,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(BUILD_SHARED_LIBS ON)

Choose a reason for hiding this comment

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

may it be wrapped by an if check?

Copy link
Author

Choose a reason for hiding this comment

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

What to calibrate?😰

If you want to generate .lib manually change it to OFF.

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