[CMake] The find_xxx family and VS

Hendrik Sattler post at hendrik-sattler.de
Tue Jun 15 12:05:42 EDT 2010


Am Dienstag 15 Juni 2010, 14:12:38 schrieb Micha Renner:
> It seems, that CMake can detect the MSVC specific headers and libraries
> only, if it runs within Visual Studio.
> 
> For example:
> FIND_FILE(STD_FILE stdio.h),
> FIND_PATH(STD_PATH stdio.h) or
> FIND_LIBRARY(LIB_PATH comctl32)
> 
> results in "NOT-FOUND", if CMake is run outside the IDE with an empty
> Build-Directory.
> 
> This means the first run of the compiler/linker always fails, since
> CMake regenerates the solution-/config-files only if there is a change
> in the script/config files inside VS.
> 
> This always leads to complex instructions for third-party users who just
> want to build the programs/libraries, like this.
> "After you have build the solution files with cmake-gui:
> - open VS,
> - open the project
> - open the "Top-level"-CMakeList.txt file
> - Hit a space in an empty line
> - Rebuild the project.
> 
> Is there a better foolproof method to solve this.

Yes. You must call cmake from the Visual Studio Command Prompt (either in the 
Windows start menu or from the IDE).
Additional, there is no gain in trying to find libraries that come with the 
compiler or system when they are always there. Additionally, the compiler 
itself knows where to find them.

HS


More information about the CMake mailing list