[CMake] Distinguish two header files with same name using cmake

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Aug 14 23:30:56 EDT 2017


On 2017-08-14 15:33-0600 dmh at ucar.edu wrote:

> I have the following situation using cmake
> 1. Running windows 7
> 2. Both cygwin and visual studio (VS) community edition (version 14)
>   installed.
> 3. I am building with visual studio as my compiler.
> 4. Cygwin has winsock2.h in /usr/include/w32api
>   The VS community edition does not have winsock2.h
> 5. Note that some older (non community edition) versions of VS do have
>   winsock2.h defined.
> 6. CHECK_INCLUDE_FILE("winsock2.h", HAVE_WINSOCK2_H) returns true
>   because it is finding the cygwin version instead of the VS version.
>
> The question is how do I see if the installed VS has winsock2.h defined while 
> ignoring any cygwin version.
>
> The reason I need to know this is that the presence of winsock2.h in VS is 
> causing a conflict with another package (libcurl). I can work around the 
> conflict if I know if the VS installation has winsock2.h (or not).
>
> I speculate that I need to prevent CMake from searching w32api.
> I considered using CMAKE_REQUIRED_INClUDES to remove a directory 
> (/usr/include/w32api), but I can see no way to do that.
>
> Suggestions?

CMake pays close attention to environment variables (e.g., PATH) when
finding what it thinks are system files.  See the documentation of
find_path, find_file, find_library, etc.  So make sure there are no
mentions of Cygwin locations in any of your enviroment variables to
reduce the chances that Cygwin locations contaminate your VS build.

Alan

__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list