Restore CMake build w/ OPTION_USE_PANGO on macOS

16 views
Skip to first unread message

Manolo

unread,
Feb 19, 2021, 4:03:00 AM2/19/21
to fltk.coredev

Under macOS, CMake-based build with OPTION_USE_PANGO (and
OPTION_APPLE_X11) turned on fails because variables such as
HAVE_LIB_PANGO and HAVE_LIB_PANGOCAIRO remain undefined.
That results from recent changes in CMake-related files.

I propose the attached small patch to fix that. It adds more paths
where to search for pango libs, necessary under macOS, but that shouldn't do harm
on other backgrounds.

Albrecht: can you validate this proposal, please?
cmake-pango-macOS.patch

Albrecht Schlosser

unread,
Feb 19, 2021, 5:07:17 AM2/19/21
to fltkc...@googlegroups.com
On 2/19/21 10:02 AM Manolo wrote:
>
> Under macOS, CMake-based build with OPTION_USE_PANGO (and
> OPTION_APPLE_X11) turned on fails because variables such as
> HAVE_LIB_PANGO and HAVE_LIB_PANGOCAIRO remain undefined.
> That results from recent changes in CMake-related files.

Can you tell me which exact changes? Commits (hashes)?

> I propose the attached small patch to fix that. It adds more paths
> where to search for pango libs, necessary under macOS, but that
> shouldn't do harm on other backgrounds.
>
> Albrecht: can you validate this proposal, please?

I'll take a look into it but I need a little help from you so I can test
this myself.

That's not strictly necessary but I'd really like to be able to build
with X11 on my own new MacBook (M1).

Can you tell me what I need to install to build with X11 and Pango on
macOS? Note that I'm a complete noob on macOS.

So far I installed:

(1) the "Xcode (?) command line tools". When I entered 'git' I got a
popup that I needed to install the command line tools and I answered
"yes" / confirmed.

Update: later I installed a system update (Big Sur 11.2.1) and the
command line tools were "gone". I had to reinstall. Is this normal?

(2) CMake: I downloaded the .dmg file from CMake and "installed" it into
the Applications folder.

With this config I could build FLTK and all the demos (default: ARM).
Then I changed the CMake option to build universal apps and built again:
bingo, universal apps created.

I did not yet install Xcode, homebrew, or any other tools. I'd like to
have a complete build environment for FLTK so I can test my
modifications, particularly CMake but also configure / autoconf (missing
now), X11 etc.

Should I install homebrew? (How?)

How do I install autoconf?

What else should I install and how do I do this, what do you recommend?

All help would be very much appreciated. TIA.

Manolo

unread,
Feb 19, 2021, 6:46:12 AM2/19/21
to fltk.coredev
On Friday, February 19, 2021 at 11:07:17 AM UTC+1 Albrecht Schlosser wrote:
On 2/19/21 10:02 AM Manolo wrote:
>
> Under macOS, CMake-based build with OPTION_USE_PANGO (and
> OPTION_APPLE_X11) turned on fails because variables such as
> HAVE_LIB_PANGO and HAVE_LIB_PANGOCAIRO remain undefined.
> That results from recent changes in CMake-related files.

Can you tell me which exact changes? Commits (hashes)?
I will search that information I don't have at this point yet.


> I propose the attached small patch to fix that. It adds more paths
> where to search for pango libs, necessary under macOS, but that
> shouldn't do harm on other backgrounds.
>
> Albrecht: can you validate this proposal, please?

I'll take a look into it but I need a little help from you so I can test
this myself.

That's not strictly necessary but I'd really like to be able to build
with X11 on my own new MacBook (M1).

Can you tell me what I need to install to build with X11 and Pango on
macOS? Note that I'm a complete noob on macOS.

So far I installed:

(1) the "Xcode (?) command line tools". When I entered 'git' I got a
popup that I needed to install the command line tools and I answered
"yes" / confirmed.
That's good.


Update: later I installed a system update (Big Sur 11.2.1) and the
command line tools were "gone". I had to reinstall. Is this normal?
Yes it is normal.


(2) CMake: I downloaded the .dmg file from CMake and "installed" it into
the Applications folder.
That's what I use too, as I like to use the GUI mode.


With this config I could build FLTK and all the demos (default: ARM).
Then I changed the CMake option to build universal apps and built again:
bingo, universal apps created.
We knew already from another user that FLTK builds and runs well on M1.
What I still ignore is whether x86_64 FLTK-based apps run on the M1, through Rosetta.


I did not yet install Xcode, homebrew, or any other tools. I'd like to
have a complete build environment for FLTK so I can test my
modifications, particularly CMake but also configure / autoconf (missing
now), X11 etc.

Should I install homebrew? (How?)
I'm not a homebrew user. I use Fink instead
because I liked its choice to put everything in a specific part of the file system
isolated from macOS. That used to be /sw and has been changed to /opt/sw more recently.
There's a problem now: Fink does not support macOS 11 yet. So you can't install it (I tried).
However, my version inherited from macOS 10.15 works well with 11.x. So I still use it.
I can share it.

My use of Fink explains why CMake files prepared for Linux need change: CMake command
    find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH} )
doesn't find the pango lib because it's not in CMAKE_LIBRARY_PATH which doesn't include /opt/sw/lib.
The modified CMake command
   find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH} ${PANGOXFT_LIBRARY_DIRS})
works for a user of Fink without hardcoded /opt/sw string.

Anyway, that situation reflects the fact there's not a single source of packaged software
for macOS, and FLTK should be able to support several setups, if possible.


How do I install autoconf?
Normally, you would get it via Fink. In the absence of that, download M4
Then do
./configure
make
make install
once for m4 and once for autoconf,.

Then you need to install Xquartz from https://www.xquartz.org/
This will put an app called XQuartz in /Applications/Utilities/ that will be your X server.
XQuartz automagically starts when an X11-based app is started.

At that point you should have enough to do that in FLTK:
autoconf -f
./configure --enable-x11
make
and obtain working X11-based FLTK test apps, provided /usr/local/bin is in your path.

I'll see what is possible for pango. I got it via Fink.


What else should I install and how do I do this, what do you recommend?

All help would be very much appreciated. TIA.
Don't hesitate to ask.

Gonzalo Garramuño

unread,
Feb 19, 2021, 7:36:34 AM2/19/21
to fltkc...@googlegroups.com

El 19/2/21 a las 07:07, Albrecht Schlosser escribió:
> On 2/19/21 10:02 AM Manolo wrote:
>
>
> Should I install homebrew? (How?)
Here's a tutorial video for M1 users on homebrew:

https://www.youtube.com/watch?v=nv2ylxro7rM



Albrecht Schlosser

unread,
Feb 19, 2021, 8:18:44 AM2/19/21
to fltkc...@googlegroups.com
On 2/19/21 12:46 PM Manolo wrote:
>
> On Friday, February 19, 2021 at 11:07:17 AM UTC+1 Albrecht Schlosser wrote:
>
> Can you tell me what I need to install to build with X11 and Pango on
> macOS? Note that I'm a complete noob on macOS.
>
> ...
>
> (2) CMake: I downloaded the .dmg file from CMake and "installed" it
> into the Applications folder.
>
> That's what I use too, as I like to use the GUI mode.

I also added the executable folder (not the .app folder) to my PATH and
now I can also run `cmake' or `cmake-gui' from the commandline. That's good.

How would I make this PATH change permanent, or would you recommend
installing symlinks as suggested elsewhere? How do you deal with such
installed tools and their paths?

> With this config I could build FLTK and all the demos (default: ARM).
> Then I changed the CMake option to build universal apps and built
> again:
> bingo, universal apps created.
>
> We knew already from another user that FLTK builds and runs well on M1.
> What I still ignore is whether x86_64 FLTK-based apps run on the M1,
> through Rosetta.

I'm now trying to do this. The first (naive) attempt was to build x86
apps and just execute them:

albrecht@mars x64 % grep ARCH CMakeCache.txt
CMAKE_OSX_ARCHITECTURES:STRING=x86_64
OPTION_ARCHFLAGS:STRING=
albrecht@mars x64 % file bin/test/hello.app/Contents/MacOS/hello
bin/test/hello.app/Contents/MacOS/hello: Mach-O 64-bit executable x86_64
albrecht@mars x64 % bin/test/hello.app/Contents/MacOS/hello
zsh: bad CPU type in executable: bin/test/hello.app/Contents/MacOS/hello

So the build worked but execution not. Hmm, Rosetta not available? ...

Now running `blocks' from the Finder yields:

To open "blocks", you need to install Rosetta. Do you want to install it
now?

Clicking [Install] ... installs ... no further message ...

Now running the same blocks executable (in Finder) works.

And from the terminal the same command as above (s/hello/blocks/) works
as well. Does this answer your question?

> I did not yet install Xcode, homebrew, or any other tools. I'd like to
> have a complete build environment for FLTK so I can test my
> modifications, particularly CMake but also configure / autoconf
> (missing
> now), X11 etc.
>
> Should I install homebrew? (How?)
>
> I'm not a homebrew user. I use Fink instead
>         https://www.finkproject.org/
> because I liked its choice to put everything in a specific part of the
> file system isolated from macOS. That used to be /sw
> and has been changed to /opt/sw more recently.
>
> There's a problem now: Fink does not support macOS 11 yet. So you can't
> install it (I tried).
> However, my version inherited from macOS 10.15 works well with 11.x. So
> I still use it.
> I can share it.

Thanks, I'll take a look at Homebrew first. Gonzalo posted a link to a
video. I'll watch it and see...

> My use of Fink explains why CMake files prepared for Linux need change:
> CMake command
>     find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH} )
> doesn't find the pango lib because it's not in CMAKE_LIBRARY_PATH which
> doesn't include /opt/sw/lib.
> The modified CMake command
>    find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH}
> ${PANGOXFT_LIBRARY_DIRS})
> works for a user of Fink without hardcoded /opt/sw string.
>
> Anyway, that situation reflects the fact there's not a single source of
> packaged software
> for macOS, and FLTK should be able to support several setups, if possible.

Yep, I think this is very important. I'm looking for a more general way,
like extending the PATH environment variable. Not exactly that but an
equivalent CMake way. Basically the user should provide their
installation paths of such additional libraries and CMake should find
these. Maybe we'll end up with a user provided list in an option field
("additional library search paths") or the user must set an appropriate
CMake variable. Then the rest should "just work".

I'd like to try to find the best "CMake compatible" way rather than
editing our CMake support files. Similar to the removal of hardcoded
paths from configure.ac ...

> How do I install autoconf?
>
> Normally, you would get it via Fink. In the absence of that, download M4
> from http://ftp.gnu.org/gnu/m4/ and autoconf from
> http://ftp.gnu.org/gnu/autoconf/
> Then do
> ./configure
> make
> make install
> once for m4 and once for autoconf,.

Okay, thanks, I'll try this - unless I can install it via Homebrew.

> Then you need to install Xquartz from https://www.xquartz.org/
> This will put an app called XQuartz in /Applications/Utilities/ that
> will be your X server.
> XQuartz automagically starts when an X11-based app is started.

Thanks again, I'll try that as well.

> At that point you should have enough to do that in FLTK:
> autoconf -f
> ./configure --enable-x11
> make
> and obtain working X11-based FLTK test apps, provided /usr/local/bin is
> in your path.
>
> I'll see what is possible for pango. I got it via Fink.

Maybe Homebrew? I'll investigate...

> All help would be very much appreciated. TIA.

Thank you very much for all your help. I'm making progress...

> Don't hesitate to ask.

Sure. Do you know a reliable source for a VNC server installation for
macOS? On Windows I installed TightVNC (as suggested by Greg) but this
appears to be only available on Linux and Windows. Any idea for macOS?

Albrecht Schlosser

unread,
Feb 19, 2021, 8:19:43 AM2/19/21
to fltkc...@googlegroups.com
On 2/19/21 1:36 PM Gonzalo Garramuño wrote:
>
> El 19/2/21 a las 07:07, Albrecht Schlosser escribió:
>> Should I install homebrew? (How?)

> Here's a tutorial video for M1 users on homebrew:
>
> https://www.youtube.com/watch?v=nv2ylxro7rM

Thank you very much. Watching ...

Manolo

unread,
Feb 19, 2021, 8:53:36 AM2/19/21
to fltk.coredev
On Friday, February 19, 2021 at 2:18:44 PM UTC+1 Albrecht Schlosser wrote:
On 2/19/21 12:46 PM Manolo wrote:
>
> On Friday, February 19, 2021 at 11:07:17 AM UTC+1 Albrecht Schlosser wrote:
>
> Can you tell me what I need to install to build with X11 and Pango on
> macOS? Note that I'm a complete noob on macOS.
>
> ...
>
> (2) CMake: I downloaded the .dmg file from CMake and "installed" it
> into the Applications folder.
>
> That's what I use too, as I like to use the GUI mode.

I also added the executable folder (not the .app folder) to my PATH and
now I can also run `cmake' or `cmake-gui' from the commandline. That's good.

How would I make this PATH change permanent, or would you recommend
installing symlinks as suggested elsewhere? How do you deal with such
installed tools and their paths?
I wouldn't add a folder inside an app to my path. I'd rather copy the cmake exe
to /usr/local/bin or $HOME/bin.


> With this config I could build FLTK and all the demos (default: ARM).
> Then I changed the CMake option to build universal apps and built
> again:
> bingo, universal apps created.
>
> We knew already from another user that FLTK builds and runs well on M1.
> What I still ignore is whether x86_64 FLTK-based apps run on the M1,
> through Rosetta.

I'm now trying to do this. The first (naive) attempt was to build x86
apps and just execute them:

albrecht@mars x64 % grep ARCH CMakeCache.txt
CMAKE_OSX_ARCHITECTURES:STRING=x86_64
OPTION_ARCHFLAGS:STRING=
albrecht@mars x64 % file bin/test/hello.app/Contents/MacOS/hello
bin/test/hello.app/Contents/MacOS/hello: Mach-O 64-bit executable x86_64
albrecht@mars x64 % bin/test/hello.app/Contents/MacOS/hello
zsh: bad CPU type in executable: bin/test/hello.app/Contents/MacOS/hello

So the build worked but execution not. Hmm, Rosetta not available? ...

Now running `blocks' from the Finder yields:

To open "blocks", you need to install Rosetta. Do you want to install it
now?

Clicking [Install] ... installs ... no further message ...

Now running the same blocks executable (in Finder) works.

And from the terminal the same command as above (s/hello/blocks/) works
as well. Does this answer your question?
Great. So it seems that, provided the user installs Rosetta, x86_64 apps run on the M1.
The modified (and simplified for clarity) CMake code to locate Pango
would become :
  pkg_check_modules(PANGOXFT pangoxft)
  if (PANGOXFT_FOUND )
    include_directories (${PANGOXFT_INCLUDE_DIRS} )

    find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH} ${PANGOXFT_LIBRARY_DIRS})
  endif  (PANGOXFT_FOUND )

My view was this is quite "CMake compatible" since there's no hardcoded path
and we have CMake use PANGOXFT_LIBRARY_DIRS that it just computed
with command pkg_check_modules(PANGOXFT pangoxft).

For this to work, I believe the condition is that pkg-config must be found in the PATH
so pkg_check_modules() runs correctly.
I'm not a VNC user, so no advice.

I would recommend you to use BBedit at http://www.barebones.com/products/bbedit/index.html
as an excellent source code editor. Its free mode does all I ever needed, including
as git mergetool.

Manolo

unread,
Feb 19, 2021, 9:45:14 AM2/19/21
to fltk.coredev
On Friday, February 19, 2021 at 2:18:44 PM UTC+1 Albrecht Schlosser wrote:

How would I make this PATH change permanent, or would you recommend
installing symlinks as suggested elsewhere? How do you deal with such
installed tools and their paths?
You can change your .login or .profile as under Linux  to set your PATH
depending on your shell.
The effect will appear when you work in the Terminal app.
However, when you run an app from the finder, its PATH is not modified.

Manolo

unread,
Feb 20, 2021, 1:49:23 AM2/20/21
to fltk.coredev
On Friday, February 19, 2021 at 11:07:17 AM UTC+1 Albrecht Schlosser wrote:
On 2/19/21 10:02 AM Manolo wrote:
>
> Under macOS, CMake-based build with OPTION_USE_PANGO (and
> OPTION_APPLE_X11) turned on fails because variables such as
> HAVE_LIB_PANGO and HAVE_LIB_PANGOCAIRO remain undefined.
> That results from recent changes in CMake-related files.

Can you tell me which exact changes? Commits (hashes)?

I believe to understand what happened.  It's not caused by any commit.

Previously, CMake command pkg_check_modules() would not work
on my setting (macOS + Fink) where pkg-config is in /opt/sw/bin
because CMake, run from the finder, does not search this folder.

The backup part of options.cmake was therefore used to locate Pango:
  if (APPLE AND OPTION_APPLE_X11)
    find_file(FINK_PREFIX NAMES /opt/sw /sw)
    list (APPEND CMAKE_INCLUDE_PATH  ${FINK_PREFIX}/include)
    include_directories (${FINK_PREFIX}/include/cairo)
    list (APPEND CMAKE_LIBRARY_PATH  ${FINK_PREFIX}/lib)
  endif (APPLE AND OPTION_APPLE_X11)
    find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH})

Yesterday I added to /usr/local/bin a link to /opt/sw/bin/pkg-config .
CMake started to perform successfully command
  pkg_check_modules(PANGOXFT pangoxft)
but that other command
    find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH})
would fail, for a reason I believe to be that CMAKE_LIBRARY_PATH is not
the place to search for the Pango library in the macOS + Fink setup.

Therefore, my proposal to modify that command as follows
    find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH} ${PANGOXFT_LIBRARY_DIRS})
I also wonder whether command
    find_library(HAVE_LIB_PANGO pango-1.0 ${PANGOXFT_LIBRARY_DIRS})
is not the good one, just after
  pkg_check_modules(PANGOXFT pangoxft)

Manolo

unread,
Feb 20, 2021, 4:59:10 AM2/20/21
to fltk.coredev
On Friday, February 19, 2021 at 11:07:17 AM UTC+1 Albrecht Schlosser wrote:
What else should I install [on macOS] and how do I do this, what do you recommend?

I would also recommend to install Pixie, an Apple app to visualize at the single pixel level
what gets drawn to any desktop window.  I get it from https://developer.apple.com/download/more/
in an item called "Additional tools for Xcode 12" which contains Pixie as well as several other
apps.
Using that web site requires an Apple account, possibly an Apple developer account.
The free version of that account is enough.

About integration between working with windows and with the Terminal :
- it's possible to drag a file or folder from any Finder window and drop it to the Terminal
to get its full path.
- in Terminal, command "open /usr/local" will open that otherwise hidden folder in
a standard Finder window.
- in a Finder window, keep the cursor a second at the left end of the folder name
present in the window title bar, the folder icon appears which you can drag and drop
to a Terminal window in order to put there that folder full path.

Reply all
Reply to author
Forward
0 new messages