Re: [fltk.coredev] Using CMake to build a user app under macOS

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Using CMake to build a user app under macOS Albrecht Schlosser 03:46 Sep 02 top right image
 
On 9/2/20 11:02 AM Manolo wrote:

I'm trying to build a small FLTK-using app with cmake under macOS.
Following README.CMake.txt, section 3, I prepared this CMakeLists.txt:

cmake_minimum_required(VERSION 2.6.3)
project(small)
set(FLTK_DIR /Volumes/Extra) # the BUILD dir of FLTK
find_package(FLTK REQUIRED NO_MODULE)
add_executable(small MACOSX_BUNDLE small.cxx)
target_include_directories(small PUBLIC ${FLTK_INCLUDE_DIRS})
target_link_libraries(small fltk)

With it, the build fails at link step (compilation step is good) in that
all macOS-defined symbols are missing.
If I replace the last line of CMakeLists.txt by

       target_link_libraries(small fltk  "-framework Cocoa")

the build succeeds, and a functional macOS bundle is produced.

That's great (I mean, that it works so far as documented), however we need to document this (for now, see below).

I had expected cmake to be smart enough to know from
find_package(FLTK REQUIRED NO_MODULE)
that "-framework Cocoa" was necessary in link commands.
Is that incorrect?

For now this is not possible. Our CMake code is still "classic" mode which means that we can't (or do not (yet)) provide "interface dependencies" of the FLTK libraries to the user.

In a (hopefully near) future version we may switch to "modern CMake" which provides "targets" with link interface dependencies to the consumer of the FLTK libs.

The prerequisite is CMake 3.0 or later (we're now at minimum 3.2.3 but this may need to be changed) and the FLTK CMake code needs to be updated in some parts. This is something I have on my todo list for the near future. I'm still investigating what exactly we need to do though...

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/792f1459-cd51-19dd-7bca-70bb5c4dcd5d%40online.de.
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2020 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.