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 build options BUILD_STATIC_LIBRARY, BUILD_SHARED_LIBRARY, and B… #492

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

axelsommerfeldt
Copy link
Contributor

…UILD_DEVEL_PACKAGE added (default=ON)

These three new CMake build options control what kind of libraries will be build and what contents will be put into the resulting package:

  • BUILD_STATIC_LIBRARY controls if a static restbed library should be build
  • BUILD_SHARED_LIBRARY controls if a shared restbed library should be build
  • BUILD_DEVEL_PACKAGE controls if a development package should be build, i.e. C++ header files included

The default value for all three options is ON to provide backward-compatibility with older restbed versions which do not offer these build options yet.

…UILD_DEVEL_PACKAGE added (default=ON)

These three new CMake build options control what kind of libraries will be build and what contents will be put into the resulting package:
* BUILD_STATIC_LIBRARY controls if a static restbed library should be build
* BUILD_SHARED_LIBRARY controls if a shared restbed library should be build
* BUILD_DEVEL_PACKAGE controls if a development package should be build, i.e. C++ header files included

The default value for all three options is ON to provide backward-compatibility with older restbed versions which do not offer these build options yet.
@axelsommerfeldt
Copy link
Contributor Author

How does the addition of CMake options (which do not cause any change unless set to OFF) could affect a regression test?

96/116 Test  #96: yield_callback_leads_to_service_crash_regression_test_suite ................Exit code 0xc0000409
***Exception:   0.10 sec

It seems that either the "yield_callback_leads_to_service_crash" bug isn't really fixed or something else here is fishy.

BTW: The result of the tests on Debian 11:

96/116 Test  #96: yield_callback_leads_to_service_crash_regression_test_suite ................   Passed    0.01 sec
...
100% tests passed, 0 tests failed out of 116

Total Test time (real) =  23.69 sec

Comment on lines +101 to +103
if ( WIN32 )
# Workaround to avoid name clash of static lib and dynamic import lib under windows.
set_target_properties( ${SHARED_LIBRARY_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}-shared" )
Copy link

Choose a reason for hiding this comment

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

Only MSVC uses file names that conflict between shared and static libraries.
Also, the .dll does not really need the -shared suffix.
So set the ARCHIVE_OUTPUT_NAME property additionally.

Suggested change
if ( WIN32 )
# Workaround to avoid name clash of static lib and dynamic import lib under windows.
set_target_properties( ${SHARED_LIBRARY_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}-shared" )
if ( MSVC )
# Workaround to avoid name clash of static lib and dynamic import lib under windows.
set_target_properties( ${SHARED_LIBRARY_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} ARCHIVE_OUTPUT_NAME "${PROJECT_NAME}-shared" )

This results in the following files:

restbed-shared.lib # import library of restbed.dll (shared library)
restbed.dll        # shared library
restbed.lib        # static library

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your feedback. But I'm not sure what the proposed change of yours has to do with my Pull Request. I just have introduced three boolean switches (which default to ON) and have surrounded already existing CMake code with if ( ) ... endif() (and have indented the lines within it), that's all. It's a very trivial change which should have no impact except offering the possibility to set one (or more) of these new switches to OFF. Therefore I have no idea why one of the tests fails when run on MS-Windows.

Regarding the MS-Windows build: I can neither comment on this nor check it since I'm using Linux only and have no experience with CMake and MS-Windows. But I don't see the correlation with my changes, and furthermore it's a test execution that fails under MS-Windows, not the build, at least that is my understanding.

endif ( )

if ( BUILD_SHARED_LIBRARY )
install( TARGETS ${SHARED_LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library )
Copy link

Choose a reason for hiding this comment

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

You need to install restbed.dll too.

Suggested change
install( TARGETS ${SHARED_LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library )
install( TARGETS ${SHARED_LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR} COMPONENT runtime)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What does this proposed change has to do with my Pull Request? I just have indented this already existing line because I have surrounded it with if( )..endif().

If there is something to improve for the MS-Windows build, I suggest making a separate Pull Request.

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

2 participants