Currently I am using FLTK in my cmake project. I would like to use a preexisting install if found, and build from source if it isn't found. To do this I added the following code to my CMakeLists.txt:find_package(FLTK 1.3.6 EXACT) # Removing this line will make the error disappear
if (NOT FLTK_FOUND) set(FLTK_BUILD_TEST FALSE CACHE BOOL "Build test/demo programs" FORCE) # Don't tmake fltk build tests set(OPTION_BUILD_HTML_DOCUMENTATION FALSE CACHE BOOL "build html docs" FORCE) # Don't build fltk docs add_subdirectory("lib/fltk/fltk-1.3.6") endif ()
This works fine on a system with fltk installed, but if it isn't installed and I try to configure, it prints all the usual "checking size of..." etc then outputs this error:CMake Error at lib/fltk/fltk-1.3.6/CMake/export.cmake:46 (export): export given target "FLTK_IMAGES_LIBRARY-NOTFOUND" which is not built by this project. Call Stack (most recent call first): lib/fltk/fltk-1.3.6/CMakeLists.txt:119 (include)
My guess would be that find_packages has set some environment variable that's messing with the fltk CMake. How could I go about fixing this?
Yes that is the correct line. Also, adding set(FLTK_LIBRARIES "") before add_subdirectory works. Thanks for the help.
On Friday, March 25, 2022 at 5:34:09 AM UTC-7 Albrecht Schlosser wrote:
On 3/25/22 06:55 supsm17 wrote:
Currently I am using FLTK in my cmake project. I would like to use a preexisting install if found, and build from source if it isn't found. To do this I added the following code to my CMakeLists.txt:find_package(FLTK 1.3.6 EXACT) # Removing this line will make the error disappear
if (NOT FLTK_FOUND) set(FLTK_BUILD_TEST FALSE CACHE BOOL "Build test/demo programs" FORCE) # Don't tmake fltk build tests set(OPTION_BUILD_HTML_DOCUMENTATION FALSE CACHE BOOL "build html docs" FORCE) # Don't build fltk docs add_subdirectory("lib/fltk/fltk-1.3.6") endif ()
This works fine on a system with fltk installed, but if it isn't installed and I try to configure, it prints all the usual "checking size of..." etc then outputs this error:CMake Error at lib/fltk/fltk-1.3.6/CMake/export.cmake:46 (export): export given target "FLTK_IMAGES_LIBRARY-NOTFOUND" which is not built by this project. Call Stack (most recent call first): lib/fltk/fltk-1.3.6/CMakeLists.txt:119 (include)
... you might succeed if you set 'FLTK_LIBRARIES' to an empty string before you use 'add_subdirectory("lib/fltk/fltk-1.3.6")' as described above. This is based on the fact that we add our libraries to this variable but I don't see that it is initialized - and thus it may use the result set by 'find_package(FLTK 1.3.6 EXACT)' which *might* set this variable.