FLTK logo

Re: [fltk/fltk] Cannot build project with CMake (add_library cannot create ALIAS target "fltk" because target "fltk::fltk" is imported but not globally visible) (Issue #970)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [fltk/fltk] Cannot build project with CMake (add_library cannot create ALIAS target "fltk" because target "fltk::fltk" is imported but not globally visible) (Issue #970) Albrecht Schlosser 09:53 May 07  
 

@sprkrd Thanks for the report, but I can't reproduce the error messages here. Please make sure that you have built and installed a fresh copy of FLTK and that the install directory is empty before you install FLTK.

I tested to build your project directly from the FLTK build and from the installation folder. Both worked w/o issues.

BTW (this may be helpful to avoid other issues): current docs (in README.CMake.txt) recommend to set FLTK_DIR as a cache variable. This prevents false find results in case the CMake procedure would find some older instances of FLTK:

# change this to your fltk build directory
set(FLTK_DIR "/path/to/fltk"
    CACHE FILEPATH "FLTK installation or build directory")
find_package(FLTK CONFIG REQUIRED)

I strongly recommend to do this. One advantage is that you can inspect the cache variable with tools like cmake-gui. You could also output FLTK_DIR after the find_package() command.

Sidenote: NO_MODULE is an alias name of CONFIG and is not required in your project. It shouldn't do any harm though.

... unless I comment out lines 87 to 119 from FLTKConfig.cmake ...

Although I can't reproduce this I remember that I had similar issues in the past but I couldn't find out yet what caused this. If you build from scratch and it doesn't work, then an easier workaround is to change only line 35 in CMake/FLTKConfig.cmake.in:

  set(FLTK_CREATE_COMPATIBILITY_ALIASES FALSE)  ## changed from TRUE to FALSE

The generated aliases are only useful if you still use old FLTK target names like fltk_shared but you are using the new namespaced target name fltk::fltk-shared, hence your project doesn't need the compatibility aliases.

That said, I wonder what caused this error in your build. It would be very helpful if you could provide CMake logs and more info about your build process (if it still fails w/o editing CMake/FLTKConfig.cmake.in). Thank you.

Could it be possible that CMake finds another (older) instance of FLTK on your system?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/issues/970/2098898014@github.com>

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

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