How write CMakeLists.txt for Windows for wxWidgets and Boost ?

Creating CMakeLists.txt on Linux for these is simple but are problems on Windows with MinGw or Visual (generating project from CMakeLists.txt).
What are minimal examples for wxWidgets and Boost on Windows?

What are those problems? Do you have error output you can share?

For example project borneq/hexFinder from github, where CMakeLists.txt is

cmake_minimum_required(VERSION 3.1)
project(hexFinder)
find_package(Boost COMPONENTS filesystem system)
set(CMAKE_CXX_STANDARD 14)
add_executable(hexFinder hexFinder.cpp)
target_link_libraries(hexFinder
                   boost_system
                   boost_filesystem
                   boost_regex)

In Linux is OK, but in Windows:

  • I install Boost on c:\boost_1_76_0
  • generate VC++ project by c:\gitmy\hexFinder\build>cmake -G “Visual Studio 16 2019” …
    Try build and are errors: (no paths)
    Ważność Kod Opis Projekt Plik Wiersz Stan pominięcia
    Błąd (aktywny) E1696 nie można otworzyć pliku źródło boost/interprocess/file_mapping.hpp hexFinder C:\gitmy\hexFinder\hexFinder.cpp 1
    Błąd (aktywny) E1696 nie można otworzyć pliku źródło boost/interprocess/mapped_region.hpp hexFinder C:\gitmy\hexFinder\hexFinder.cpp 2
    Błąd (aktywny) E1696 nie można otworzyć pliku źródło boost/regex.hpp hexFinder C:\gitmy\hexFinder\hexFinder.cpp 3
    Błąd (aktywny) E1696 nie można otworzyć pliku źródło boost/filesystem.hpp hexFinder C:\gitmy\hexFinder\hexFinder.cpp 4
    Błąd (aktywny) E0276 nazwa, po której następują znaki „::”, musi być nazwą klasy lub przestrzeni nazw hexFinder C:\gitmy\hexFinder\hexFinder.cpp 9

(errors in Polish because I have Polish WIndows)

I want avoid put literal pathes to cmake like c:\boost_1_76_0 , espacially names like libboost_graph-vc142-mt-gd-x32-1_76.lib and prefer not put version like 1.76 to cmake.

You should use Boost::boost, Boost::filesystem, Boost::regex, and Boost::system to the target_link_libraries call. You’re just listing library names which is just -l flags. This works with the Linux distro packages because everything is in the default locations.