0

I'm a Linux user who's trying to set up a dev environment on Windows. I've cloned the fmt repo and built it the way I'm used to on Linux:

C:\Users\me\Development> git clone https://github.com/fmtlib/fmt.git
C:\Users\me\Development> cd fmt
C:\Users\me\Development> mkdir build
C:\Users\me\Development> cd build
C:\Users\me\Development> cmake ..
C:\Users\me\Development> cmake --build . --config Release

Now I want to install it so that I can include it in projects. Normally I would $ sudo make install but I'm not sure what to do on Windows and the fmt doc page has nothing for Windows installation.

When I did this same set of steps with FLTK there was a variable that I had to set to help me find things:

# CMakeLists.txt
set(FLTK_DIR "Path/to/installation")
find_package(FLTK REQUIRED NO_MODULE)

But it seems to be looking for the installation point, not the build dir. How can I get this to work?

Chrinkus
  • 11
  • 3
  • What compiler are you using under windows? `cmake --build . --config Release` is not enough for Visual Studio Community (msvc compiler) because you most likely need to build both Debug and Release. Also note that this package is in `vcpkg` – drescherjm Dec 16 '20 at 19:52
  • ***But it seems to be looking for the installation point, not the build dir. How can I get this to work?*** I use the build folder with MSVC all the time. I don't build the install targets for the most part. – drescherjm Dec 16 '20 at 19:56
  • @drescherjm I'm using MSVC which I assume to be the default. I did build both the Debug and Release versions. As for vcpkg, I'm leaning more towards using Conan but I'm also learning how C++ works with Windows so I thought installing libs manually would give me experience before I bring in a package manager. Interesting about using the build folder. Where do you usually put it? I just put mine in my home directory as shown above but then I need to hardcode my username into my cmake files which I'd prefer not to. – Chrinkus Dec 16 '20 at 20:07
  • I have a completely separate tree for the source versus the builds. So `x:\CMakeBased\somehiearchy\ProjectX` would be the source then x:\x64.XX\VC142\ProjectX would be where I build projectX for 3rd party libs its `x:\CMakeBased\Lib\LibName` for the source with the build in `x:\x64.XX\VC142\Lib\LibName` the XX is an incremental number because I simultaneously have several build trees with a single source tree. – drescherjm Dec 16 '20 at 20:11
  • Does this answer your question? [How to use CMake to install](https://stackoverflow.com/questions/48428647/how-to-use-cmake-to-install) – Tsyvarev Mar 10 '22 at 22:03

1 Answers1

0

You can run:

cmake --install . [--prefix <install-dir>]

The prefix is optional. On Windows, the default CMAKE_INSTALL_PREFIX is set to:

C:/Program Files (x86)/<project name>

Which in the case fmtlib would be:

C:/Program Files (x86)/FMT

Another option is to use vcpkg on Windows, which will install fmtlib locally in its own vcpkg install prefix. Then you can use it via:

find_package(fmt REQUIRED)
add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE fmt::fmt)

You just have to pass the vcpkg cmake toolchain file to your cmake invocation:

cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
mo_al_
  • 561
  • 4
  • 9