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

Modernize CMake #374

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Modernize CMake #374

wants to merge 4 commits into from

Conversation

Symbitic
Copy link

This pull request updates the cmake build system to use more modern features. The minimum required version is v3.12, which is found in all three GitHub runners.

Changes:

  • Replaced global commands like add_compile_options with target_compile_options. CMake strongly encourages encourages this practice.
  • Add a new option: CMARK_EXE. When turned off, the cmark executable will not be built. Useful for when building cmark as a subproject.
  • Export cmark_static as just cmark when shared libraries are disabled.
  • Update install directory for cmake files on Windows (Windows does not search lib/cmake/cmark).

All modern operating systems have at least CMake 3.12 installed, including all 3 in the CI build matrix. That allows more modern CMake features to be used. `MINGW` is defined since version 3.2. Specify allowed configuration types in `CMAKE_CONFIGURATION_TYPES`. Finally, add new option: `CMARK_EXE`.
* Use cmark as static library name when CMARK_SHARED is disabled.
* Change install directory for CMake files on Windows.
CMake discourages the use of global commands like add_compile_options.
Instead, things like target_compile_options should be used.

Additional changes:
+ Do not build the cmark program when CMARK_EXE is off.
+ Use ENABLE_EXPORTS to disable -rdynamic.
+ Export cmark_static as just cmark when shared is disabled.
@Mikenux
Copy link

Mikenux commented Nov 8, 2021

Hello!

In Evince (Document Viewer), there is work in progress to support markdown files (via md -> html -> pdf conversion; see https://gitlab.gnome.org/GNOME/evince/-/merge_requests/391).

I think the build option CMARK_EXE is what is needed to only build cmark as library for a flatpak build. So, it would be nice to have this. Thanks!

@jgm
Copy link
Member

jgm commented Nov 8, 2021

@nwellnhof is there no build configuration currently accessible that allows building without creating the executable?

It has been a while; I don't recall all the reasons this wasn't merged, but I think they include:

  • It's a very big patch, and hard for someone like me who isn't an expert on cmake to evaluate
  • At the time we were considering other incompatible cmake patches
  • We didn't at the time want to require cmake 3.12; in fact we've only recently increased the minimum cmake version required to 3.

I see the value in something like CMARK_EXE. Maybe it's possible to extract that part of this patch without requiring more than cmake 3.7?

@Mikenux
Copy link

Mikenux commented Nov 9, 2021

@jgm: I now build with '-BUILDDIR=build' option in the json file, but '-DCMAKE_INSTALL_PREFIX=/app' does not work. However, if I edit the Makefile by removing the '?' after 'INSTALL_PREFIX' and by adding '/app' after '=', it works (I edit the file, then recompress in personal archive). Did I use the wrong option?

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.

3 participants