Using CMake to build under MSVC.

23 views
Skip to first unread message

pvr...@btinternet.com

unread,
Nov 4, 2025, 4:06:03 PMNov 4
to fltk.general
I have started to move my projects from MSVC Solutions on Windows and Makefile on Linux.

I have successfully managed to move from Makefile to CMakeLists.txt on Linux.  

When I clone the repo on Windows I found an issue.

First, I had to learn how to install FLTK from sources on MSVC. I eventually found this by using the Developer Power Shell and running "sudo cmake --install ." 

I then had to remove my requiring version 1.4.4 as I am using bleeding edge 1.5 check-out on Windows. I am using 1.4.4 on Linux as there is another app (not mine) that doesn't yet work with 1.5.

Now the problem: It seems to be looking for lib/blocks.lib as fltk::blocks appears to be required. I remember seeing a comment in the CMakesList that all fltk::* targets are looked for. I pulled the latest git and the problem is still there.

Regards Phil.

PS C:\Users\pvros\source\repos\qbs\build> cmake ..
CMake Error at C:/Program Files (x86)/FLTK/CMake/FLTK-Targets.cmake:163 (message):
The imported target "fltk::blocks" references the file

"C:/Program Files (x86)/FLTK/lib/blocks.lib"

but this file does not exist. Possible reasons include:

* The file was deleted, renamed, or moved to another location.

* An install or uninstall procedure did not complete successfully.

* The installation package was faulty and contained

"C:/Program Files (x86)/FLTK/CMake/FLTK-Targets.cmake"

but not all the files it references.

Call Stack (most recent call first):
C:/Program Files (x86)/FLTK/CMake/FLTKConfig.cmake:39 (include)
CMakeLists.txt:33 (find_package)


-- Configuring incomplete, errors occurred

Albrecht Schlosser

unread,
Nov 4, 2025, 4:43:04 PMNov 4
to fltkg...@googlegroups.com
Hi Phil,


on 11/4/25 22:06 'pvr...@btinternet.com' via fltk.general wrote:
I have started to move my projects from MSVC Solutions on Windows and Makefile on Linux.

Hmm, I can't parse the above sentence. Did you mean to append "... to CMake" (on both platforms)?


I have successfully managed to move from Makefile to CMakeLists.txt on Linux.

OK, great. I assume that applies to your application *and* to building the FLTK library itself, right?


When I clone the repo on Windows I found an issue.

First, I had to learn how to install FLTK from sources on MSVC. I eventually found this by using the Developer Power Shell and running "sudo cmake --install ."

Hmm, didn't you move "from MSVC ... to ??". What exactly are you doing (a) to build FLTK and (b) to build your application? Just for my understanding. ;-)


I then had to remove my requiring version 1.4.4 as I am using bleeding edge 1.5 check-out on Windows. I am using 1.4.4 on Linux as there is another app (not mine) that doesn't yet work with 1.5.

OK, but we're now talking about FLTK 1.5 on Windows ?


Now the problem: It seems to be looking for lib/blocks.lib as fltk::blocks appears to be required. I remember seeing a comment in the CMakesList that all fltk::* targets are looked for. I pulled the latest git and the problem is still there.

Which CMakeLists.txt? There are always two involved, one for FLTK itself, and one for your application.

Anyway, fltk::blocks should never be required to build your application. If at all, fltk::blocks would be an executable that's built during the FLTK build (and not a library). Hence fltk::blocks should not be required, nor should it resolve to "C:/Program Files (x86)/FLTK/lib/blocks.lib" which would be a library that doesn't exist.



PS C:\Users\pvros\source\repos\qbs\build> cmake .. CMake Error at C:/Program Files (x86)/FLTK/CMake/FLTK-Targets.cmake:163 (message): The imported target "fltk::blocks" references the file "C:/Program Files (x86)/FLTK/lib/blocks.lib" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "C:/Program Files (x86)/FLTK/CMake/FLTK-Targets.cmake" but not all the files it references. Call Stack (most recent call first): C:/Program Files (x86)/FLTK/CMake/FLTKConfig.cmake:39 (include) CMakeLists.txt:33 (find_package) -- Configuring incomplete, errors occurred

OK, given your error message above, I suggest that you post your "installed" file "C:/Program Files (x86)/FLTK/lib/blocks.lib" so I can take a look at it. I've just been working on a very similar issue on Debian (and Ubuntu), but that war very likely caused by *modifying* the file during or after installation by the distribution maintainers (see GitHub Issue #1314 (https://github.com/fltk/fltk/discussions/1314).

As I wrote in the context of issue #1314, `FLTK-Targets.cmake` is a file generated by CMake (instructions derived from the FLTK CMake files), hence I wonder what's happening in your case.

Please post your `FLTK-Targets.cmake` file as requested above, then I can take a look and try it myself on a Windows box - but not today, it's too late here for new tests today...

Albrecht Schlosser

unread,
Nov 4, 2025, 5:03:20 PMNov 4
to fltkg...@googlegroups.com
Sorry for confusion, ...

On 11/4/25 22:42 'Albrecht Schlosser' via fltk.general wrote:
> OK, given your error message above, I suggest that you post your
> "installed" file "C:/Program Files (x86)/FLTK/lib/blocks.lib" so I can
> take a look at it.

... should read "C:/Program Files (x86)/FLTK/CMake/FLTK-Targets.cmake",
of course. Obviously I copied the wrong string.

pvr...@btinternet.com

unread,
Nov 4, 2025, 5:04:35 PMNov 4
to fltkg...@googlegroups.com
Hi Albrecht,


From: 'Albrecht Schlosser' via fltk.general <fltkg...@googlegroups.com>
Sent: Tuesday, November 4, 2025 9:42 PM
Subject: Re: [fltk.general] Using CMake to build under MSVC.
 
Hi Phil,

on 11/4/25 22:06 'pvr...@btinternet.com' via fltk.general wrote:
I have started to move my projects from MSVC Solutions on Windows and Makefile on Linux.

Hmm, I can't parse the above sentence. Did you mean to append "... to CMake" (on both platforms)?

Sorry, sort of implied. Yes to CMake in both platforms: W11 and Debian bookworm using FLTK compiled from source on both.

I have successfully managed to move from Makefile to CMakeLists.txt on Linux.

OK, great. I assume that applies to your application *and* to building the FLTK library itself, right?

I mean my application, I was already using CMake to build FLTK on Linux.

When I clone the repo on Windows I found an issue.

First, I had to learn how to install FLTK from sources on MSVC. I eventually found this by using the Developer Power Shell and running "sudo cmake --install ."

Hmm, didn't you move "from MSVC ... to ??". What exactly are you doing (a) to build FLTK and (b) to build your application? Just for my understanding. ;-)

Originally on FLTK I was letting MSVC do its default build with CMakeList. I realised this evening I could use the CLI Cmake commands to both build and install FLTK on my windows environment. I was linking my app to the built version in my W11 clone of FLTK. I now have it installed in C:/Program Files (86). 

I then had to remove my requiring version 1.4.4 as I am using bleeding edge 1.5 check-out on Windows. I am using 1.4.4 on Linux as there is another app (not mine) that doesn't yet work with 1.5.

OK, but we're now talking about FLTK 1.5 on Windows ?
1.5 on Windows and 1.4.4 on Linux.

Now the problem: It seems to be looking for lib/blocks.lib as fltk::blocks appears to be required. I remember seeing a comment in the CMakesList that all fltk::* targets are looked for. I pulled the latest git and the problem is still there.

Which CMakeLists.txt? There are always two involved, one for FLTK itself, and one for your application.
The FLTK one. It may not have been CMakeLists.txt (I have just looked and not found the comment) but one of the various other files, I was just in browse mode not diagnostic mode at the time.

Anyway, fltk::blocks should never be required to build your application. If at all, fltk::blocks would be an executable that's built during the FLTK build (and not a library). Hence fltk::blocks should not be required, nor should it resolve to "C:/Program Files (x86)/FLTK/lib/blocks.lib" which would be a library that doesn't exist.

It doesn't exist. 


PS C:\Users\pvros\source\repos\qbs\build> cmake .. CMake Error at C:/Program Files (x86)/FLTK/CMake/FLTK-Targets.cmake:163 (message): The imported target "fltk::blocks" references the file "C:/Program Files (x86)/FLTK/lib/blocks.lib" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "C:/Program Files (x86)/FLTK/CMake/FLTK-Targets.cmake" but not all the files it references. Call Stack (most recent call first): C:/Program Files (x86)/FLTK/CMake/FLTKConfig.cmake:39 (include) CMakeLists.txt:33 (find_package) -- Configuring incomplete, errors occurred

OK, given your error message above, I suggest that you post your "installed" file "C:/Program Files (x86)/FLTK/lib/blocks.lib" so I can take a look at it. I've just been working on a very similar issue on Debian (and Ubuntu), but that war very likely caused by *modifying* the file during or after installation by the distribution maintainers (see GitHub Issue #1314 (https://github.com/fltk/fltk/discussions/1314).

The file has not been generated. Either that is the error (unlikely) or the code in FLTK-Targets.cmake that expects it is wrong, or shouldn't be being invoked.

As I wrote in the context of issue #1314, `FLTK-Targets.cmake` is a file generated by CMake (instructions derived from the FLTK CMake files), hence I wonder what's happening in your case.

Please post your `FLTK-Targets.cmake` file as requested above, then I can take a look and try it myself on a Windows box - but not today, it's too late here for new tests today...

Attached. I'm only an hour behind you.

Phil.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
FLTK-Targets.cmake

pvr...@btinternet.com

unread,
Nov 7, 2025, 5:18:15 AMNov 7
to fltkg...@googlegroups.com
If I try and build my app using the build version of FLTK rather than the installed version - i.e. add

set(FLTK_DIR "C:/Users/pvros/source/repos/fltk/build"
    CACHE FILEPATH "FLTK installation or build directory")

To the CmakeLists.txt file, I get further along my build. 

So it's the conversion to the installed files that is leaving the dependency on fltk::blocks in the installed CMake files for FLTK.

I attach the .cmake files from the build directory.

Regards Phil.

From: 'pvr...@btinternet.com' via fltk.general <fltkg...@googlegroups.com>
Sent: Tuesday, November 4, 2025 10:04 PM
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/Do1c2N6ctVo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/DU4PR06MB10412285A637DEF39F99FC8FBF0C4A%40DU4PR06MB10412.eurprd06.prod.outlook.com.
FLTKConfig.cmake
FLTK-Targets.cmake

Albrecht Schlosser

unread,
Nov 7, 2025, 6:51:44 AMNov 7
to fltkg...@googlegroups.com
On 11/7/25 11:18 'pvr...@btinternet.com' via fltk.general wrote:
If I try and build my app using the build version of FLTK rather than the installed version - i.e. add

set(FLTK_DIR "C:/Users/pvros/source/repos/fltk/build"
    CACHE FILEPATH "FLTK installation or build directory")

To the CmakeLists.txt file, I get further along my build. 

So it's the conversion to the installed files that is leaving the dependency on fltk::blocks in the installed CMake files for FLTK.

Thanks, this observation is really helpful. That was my suspicion as well, but it's great that you confirmed it before I even got around to test it myself. This could also be causing the issue on Debian/Ubuntu mentioned previously, although I'm sure the Linux maintainers modified the files somehow...


I attach the .cmake files from the build directory.

Thanks for these files as well, I'll look into them later. Today I'll be too busy.

Regards Phil.

Best regards
Albrecht
Reply all
Reply to author
Forward
0 new messages