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...