In vs2010 a bad project file could be generated if a .c or .cxx file
was marked with HEADER_FILE_ONLY, if it was in a library that contained
both c and c++ code. This fixes the error in the code, and adds a test
for this case.
If a .sln file refers to a project file with a leading ".\", as in
".\foo.vcxproj" instead of just "foo.vcxproj" or a full path then
msbuild behaves strangely. Whenever target foo is built as a dependency
of another target, msbuild brings multiple configurations up to date
instead of just the requested configuration!
Avoid a leading ".\" in project file references to avoid this behavior.
This alternative fix to that attempted by commit 57e71533 (Avoid msbuild
idiosyncrasy that builds multiple configs, 2010-12-10) avoids use of
full path project file references which vcbuild does not support.
This reverts commit 57e71533f4.
While "msbuild" can handle full paths to project files in solutions,
the old "vcbuild" used for VS < 10 cannot. We will need another
way to fix issue #11594.
For prior versions of Visual Studio we would intentionally pass
"/nologo-" for "verbose makefiles" (CMAKE_VERBOSE_MAKEFILE ON)
when the caller did not already explicitly specify either /nologo
or /nologo-. And we still do. For the prior versions.
This had the side effect of always passing /nologo- for try_compile
operations because try_compile generates projects that have verbose
makefiles on.
However, starting with Visual Studio 10, the compiler emits
"cl ... warning D9035: option 'nologo-' has been deprecated"
when passed "/nologo-".
Therefore, this commit removes setting "/nologo-" for verbose
makefiles in the Visual Studio 10 case to avoid emitting a
warning for every single invocation of the compiler in a given
build.
With Visual Studio 10, we do not set this flag either way
and therefore, the generated project has no value for this
setting and gets Visual Studio's default value, which is
of course "/nologo", which does not produce a warning.
With Visual Studio 10, a caller can still force "/nologo-"
if desired by adding it explicitly to CMAKE_C_FLAGS or
CMAKE_CXX_FLAGS.
One of Cygwin's goals is to build projects using the POSIX API with no
Windows awareness. Many CMake-built projects have been written to test
for UNIX and WIN32 but not CYGWIN. The preferred behavior under Cygwin
in such projects is to take the UNIX path but not the WIN32 path.
Unfortunately this change is BACKWARDS INCOMPATIBLE for Cygwin-aware
CMake projects! Some projects that previously built under Cygwin and
are Cygwin-aware when they test for WIN32 may now behave differently.
Eventually these projects will need to be updated, but to help users
build them in the meantime we print a warning about the change in
behavior. Furthermore, one may set CMAKE_LEGACY_CYGWIN_WIN32 to request
old behavior during the transition.
Normally we avoid backwards incompatible changes, but we make an
exception in this case for a few reasons:
(1) This behavior is preferred by Cygwin's design goals.
(2) A warning provides a clear path forward for everyone who may see
incompatible behavior, and CMAKE_LEGACY_CYGWIN_WIN32 provides a
compatibility option. The warning and compatibility option both
disappear when the minimum required version of CMake in a project is
sufficiently new, so this issue will simply go away over time as
projects are updated to account for the change.
(3) The fixes required to update projects are fairly insignificant.
Furthermore, the Cygwin distribution has no releases itself so project
versions that predate said fixes tend to be difficult to build anyway.
(4) This change enables many CMake-built projects that did not
previously build under Cygwin to work out-of-the-box. From bug #10122:
"I have built over 120 different source packages with (my patched)
CMake, including most of KDE4, and have found that NOT defining
WIN32 on Cygwin is much more accurate." -- Yaakov Selkowitz
A fully compatible change would require patches on top of these project
releases for Cygwin even though they otherwise need not be aware of it.
(5) Yaakov has been maintaining a fork of CMake with this change for the
Cygwin Ports distribution. It works well in practice. By accepting the
change in upstream CMake we avoid confusion between the versions.
CMake itself builds without WIN32 defined on Cygwin. Simply disable
CMAKE_LEGACY_CYGWIN_WIN32 explicitly in our own CMakeLists.txt file.
Previously, we would search in the Windows registry for the path
to makensis, and fail immediately if we could not read the registry
value, assuming that it was simply not installed.
This change looks for makensis in the PATH even if the registry value
is not there, enabling the scenario where makensis is installed without
admin privileges and never even touches HKEY_LOCAL_MACHINE during the
non-admin install.
In VS9 and previous versions, :VCReportError is the goto label
to jump to after a failed custom command. It stops the build
before it tries to go any further.
In VS10, :VCEnd is the correct label to use.
Create a method in the VS generators to provide the correct
line of script to use for each version of Visual Studio.
For more internal details, search for VCEnd in the
C:\Program Files\MSBuild directory.
XCode and Visual Studio generators can run from
${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE} and determining this at
testing time is not feasible without adding in more
PASS_REGULAR_EXPRESSION's which may create false positives.
Since the parsing code is in cross-platform, generator-agnostic code,
if it passes with Makefiles, it should work with other generators on
other platforms.
The tests-if-CYGWIN topic made a change to Tests/Testing/CMakeLists.txt
in code that the custom-command-generator-expressions topic moved to the
Tests/PerConfig/CMakeLists.txt file. Make the same change to the same
content in the new file. (Only a small part of the file moved so rename
detection did not do this automatically.)
The KWSys SystemTools::GetMaximumFilePathLength method is poorly
conceived and should not be used. The cmDepends code honors its own
MaxPath buffer size. Just hard-code it.
The first instinct of a lot of users is to use file(GLOB) to assemble
lists of sources. Add a warning to the help text stating that it should
not be used for this purpose and briefly explain why.
Suggested-By: Ryan Pavlik