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

add cmake building support #704

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

Conversation

trailblazing
Copy link

@trailblazing trailblazing commented Jan 6, 2021

Update for #617
Based on the most recent upstream code HEAD "8a2fdfe" (origin/master, origin/HEAD, master) replace archaic &std::vector::operator[0] with c++11 std::vector::data

Details:

  1. src/hunspell/CMakeLists.txt:92
    # $<$<CXX_COMPILER_ID:Clang>:-Wl,-no-undefined,error>
    This setting does not work on Void Linux (Clang, musl). It's not necessary for this toolchain.

  2. src/hunspell/CMakeLists.txt:101
    VERSION 0.0.${PROJECT_VERSION_PATCH} # ${PROJECT_VERSION}
    If I set project version to 1.7.2, the patch version would be 2. We will get "libhunspell-1.7.so.0.0.2". Otherwise from the original version setting we got "libhunspell-1.7.so.1.7.0"

  3. src/hunspell/CMakeLists.txt:161
    VERSION 0.0.${PROJECT_VERSION_PATCH} # ${PROJECT_VERSION}
    Same as above.

Copy link

@friendlyanon friendlyanon left a comment

Choose a reason for hiding this comment

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

Lots of mistakes in these CMake files and even more code that just duplicates features that are already built into CMake.


# ~~~ Options
option(HUNSPELL_BUILD_TOOLS "Build Hunspell tools and parser." ON)
option(HUNSPELL_BUILD_STATIC_LIB "Build static hunspell library." ON)

Choose a reason for hiding this comment

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

Please do not duplicate CMake built-in functionality: https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Comment on lines +15 to +17
set(HUNSPELL_INCLUDE_INSTALL_DIR "include")
set(HUNSPELL_LIBRARY_INSTALL_DIR "lib")
set(HUNSPELL_RUNTIME_INSTALL_DIR "bin")

Choose a reason for hiding this comment

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

Please do not duplicate CMake built-in functionality: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html

set(HUNSPELL_RUNTIME_INSTALL_DIR "bin")
set(HUNSPELL_INSTALL_TARGETS "" CACHE INTERNAL "")
set(HUNSPELL_EXTRA_EXPORT_TARGETS "" CACHE INTERNAL "")
set(VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})

Choose a reason for hiding this comment

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

Please do not duplicate CMake built-in functionality: https://cmake.org/cmake/help/latest/variable/PROJECT_VERSION.html

Comment on lines +22 to +24
# Set RPATH for installed executables
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${HUNSPELL_LIBRARY_INSTALL_DIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

Choose a reason for hiding this comment

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

Please do not set CMAKE_* variables that are intended to be manipulated from the command-line by users.

Comment on lines +30 to +35
include(CheckCXXCompilerFlag)

check_cxx_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
if(NOT HAVE_VISIBILITY)
set(HAVE_VISIBILITY 0)
endif()

Choose a reason for hiding this comment

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

I assume the goal here is to check for DLL exports, in which case please avoid duplicating CMake built-in functionality. This example shows how to properly create a dual static/shared project: https://github.com/friendlyanon/cxx-static-shared-example

set(_TEST_OUTPUT_NAME "test")

set(HUNSPELL_PARSERS_TARGET_PREFIX "parsers" CACHE INTERNAL "")
set(HUNSPELL_PARSERS_LIB_TARGET "${HUNSPELL_PARSERS_TARGET_PREFIX}_lib" CACHE INTERNAL "")

Choose a reason for hiding this comment

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

What's with the suffix? See comment above about idiomatic naming on different platforms.

Comment on lines +62 to +64
if(WIN32 OR MINGW)
copy_dll_if_changed(${HUNSPELL_LIB_TARGET_SHARED} ${HUNSPELL_PARSERS_TEST_TARGET})
endif()

Choose a reason for hiding this comment

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

This is harmful. See comment above.

Comment on lines +51 to +55
find_package(Curses)

if(NOT CURSES_FOUND)
message(FATAL_ERROR "Could not find curses library. Set paths manually.")
endif()

Choose a reason for hiding this comment

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

Just use the REQUIRED argument.

Comment on lines +104 to +108
find_package_handle_standard_args(Readline
REQUIRED_VARS
READLINE_LIBRARY
READLINE_INCLUDE_PATH
)

Choose a reason for hiding this comment

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

What is this doing smack dab in the middle of everything? This is a function made available by FindPackageHandleStandardArgs for ONLY inside find modules. For one, the module is not included anywhere, but more importantly this code is not even in a find module.

Comment on lines +122 to +128
$<$<BOOL:${_HAVE_LOCALE_H}>:HAVE_LOCALE_H>
$<$<BOOL:${_HAVE_LANGINFO_H}>:HAVE_LANGINFO_H>
$<$<BOOL:${Iconv_FOUND}>:HAVE_ICONV>
$<$<BOOL:${Iconv_FOUND}>:ICONV_CONST=>
$<$<BOOL:${_HAVE_CURSES_H}>:HAVE_CURSES_H>
$<$<BOOL:${_HAVE_NCURSESW_H}>:HAVE_NCURSESW_CURSES_H>
$<$<BOOL:${Readline_FOUND}>:HAVE_READLINE>

Choose a reason for hiding this comment

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

These are known at configure time, please do not defer them to generation time using genexes.

@friendlyanon friendlyanon mentioned this pull request Jan 18, 2022
@pzmarius
Copy link

Lots of mistakes in these CMake files and even more code that just duplicates features that are already built into CMake.

Hi there @friendlyanon , here is the author of the original PR #617.

I see you have had some time to perform a basic code review. If you need this functionality and have some better ideas on how to improve the build architecture of 'hunspell' using CMake, then feel free to implement and update these scripts, I am afraid I do not have time nor am I interested in CMake anymore.

I would suggest that you and others here that intend to add or want official support for CMake to have a discussion with the maintainer regarding the details of the original build system and lay down some proper requirements, before doing any further unnecessary work. This has not been the case at the time of implementing the initial CMake scripts. I do also believe that the maintainer would consider a replacement of current makefiles only if the complete functionality is provided by CMake.

@ssvb
Copy link

ssvb commented May 14, 2023

Who is going to benefit from a CMake build system? I think that's the fist thing to figure out.

@friendlyanon
Copy link

I would suggest that you and others here that intend to add or want official support for CMake to have a discussion with the maintainer

#758 sort of aims to be that. So far there has been no response there.

Who is going to benefit from a CMake build system?

The entire ecosystem! That is if you consider surveys such as these:
https://isocpp.org/files/papers/CppDevSurvey-2022-summary.pdf
https://www.jetbrains.com/lp/devecosystem-2022/cpp/
https://twitter.com/meetingcpp/status/1617835891015442435

Supporting clients using CMake (via a CMake package) would also make it trivial to have hunspell as a transitive dependency in the de facto standard build system of C++ and C projects.

CMake also just makes it easier to build projects in general. So much so that I wrote my own CMakeLists.txt for packaging hunspell for Conan, because I'm too old to be trying to make make work on platforms other than Linux: https://github.com/conan-io/conan-center-index/blob/master/recipes/hunspell/all/CMakeLists.txt
That Conan recipe could use an update too.

@vadi2
Copy link

vadi2 commented Apr 20, 2024

Hunspell is impossible to compile on Windows in April 2024 since autotools is no longer installable after the osdn mirror lost stability, so quite a few folks will benefit from the cmake-based build process.

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

5 participants