When reading CMake documentation there are places where by "standard location" is referred as a place where CMake will be looking for libraries and include files. What does it mean by "standard location" from CMake perspective on Windows. Is it C:/
or what exactly? In case one put a library in a different partition, say G:/
, does that mean this is not a standard location?
Asked
Active
Viewed 143 times
1

too honest for this site
- 12,050
- 4
- 30
- 52

Amani
- 16,245
- 29
- 103
- 153
-
On Linux, there are standard locations for header (`/usr/include`) and libraries (`/usr/lib`, or `/lib`, or `/usr/lib/
`). On Windows, there is probably only `c:\windows\system32` for libraries and no default location for headers. You should find platform specific scripts in the CMake directory, maybe having a look there clears things up. – Karsten Koop Jul 14 '17 at 13:09 -
The file `Modules/Platform/Windows.cmake` should set up some platform specific variables, e.g. it sets the library extension to .dll. It seems not to set any paths, whereas the equivalent `Linux.cmake` includes `UnixPaths.cmake` which sets those default locations. I'd guess there are no default paths on Windows. – Karsten Koop Jul 14 '17 at 13:14
-
Finding packages on windows is difficult for `CMake` because there is no standard place for libraries and include paths. You often need to tell CMake where to look. Although with that said a lot of packages assume you install in c:\Program Files. As a windows developer almost never put libraries there so I usually use CMAKE variables to steer `CMake` to look in a more likely place on my systems. – drescherjm Jul 14 '17 at 13:25
-
@KarstenKoop On Windows, my standard lib location is `C:\cygwin\usr\include`. Certainly the standard lib location more depends on the compiler than the OS. ;-) – chux - Reinstate Monica Jul 14 '17 at 13:31
-
***Is it C:/ or what exactly?*** No. On Windows / Visual Studio it is more likely C:\Program Files. But this may be dependent on the package you are finding. – drescherjm Jul 14 '17 at 14:14
-
You could just look at the source of the finder module to understand better what paths it is looking. Also the documentation for find_package() / find_library() – drescherjm Jul 14 '17 at 14:16
-
There is also the package registry. If you compile a package with CMake then try to find it CMake may find (I am no longer sure of the limitations see the rest of this comment) it in its registry regardless of what path you compiled from. I build everything in X: Although I try to disable this feature in most cases because I build the same source tree for more than 1 version of Visual Studio and this registry feature just gets in my way by picking the wrong binaries for the compiler version I am using. – drescherjm Jul 14 '17 at 14:19
1 Answers
0
It depends on the compiler. After cmake has determined the compiler it can configure the build system.
In case of gcc and clang you can list include directory as described here
gcc -xc++ -E -v -
clang -xc++ -E -v -

Jónás Balázs
- 781
- 10
- 24
-
My question is when CMake is configuring it does look for libraries and files in "standard locations". What are these standard location from CMake perspective? Not compiler perspective. A compiler is called after configuration with CMake. – Amani Jul 14 '17 at 13:57
-
***What are these standard location from CMake perspective?*** Depends on the variables CMake set for the compiler and os. Individual finder modules may have additional paths set to look for a package. And this may be dependent on several CMake variables. – drescherjm Jul 14 '17 at 14:09