View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015917CMakeCMakepublic2016-01-13 18:162016-06-10 14:21
ReporterDaniel Williams 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformWin64OSWindows 7OS Versionsp1
Product VersionCMake 3.4.1 
Target VersionFixed in Version 
Summary0015917: Visual Studio project files generated incorrectly
DescriptionExecutables are incorrectly flagged as Application executables (i.e. to use winMain) instead of utility / console executables (and use the normal main)

when cmake is generating solution (.sln) and project (.vcxproj) files for Visual Studio, it cannot set the flags correctly. The generator creates:
    <ConfigurationType>Application</ConfigurationType>

Instead of:
    <ConfigurationType>Utility</ConfigurationType>

This in turn causes compile-time Link Errors

As it should. This is controlled by a flag on the executable. (or so says the documentation):
[1]https://cmake.org/cmake/help/v3.4/command/add_executable.html [^]
[2]https://cmake.org/cmake/help/v3.4/prop_tgt/WIN32_EXECUTABLE.html [^]




Steps To Reproduce1) create empty project with supplied CMakeLists.txt
2) create a minimal 'main.cpp' (contents don't matter, empty should be fine)
3) run configure ; run generate
4) inspect $BUILD_DIR/test.exe.vcxproj
   DOM: Project/PropertyGroup/ConfigurationType values will all still be set to "Application" which requires the winmain symbol be defined.

This Application tag is generated both with and without the WIN32 flag. It is only supposed to be generated *with*. (Without the flag, the 'ConfigurationType' tag should be set to 'Utility', the console exe version.)
Additional Information1) Originally Reproduced as far back as CMake 3.1.2
2) the 'set_executable(...)' function correctly sets the flag, as checked by 'get_target_property(...)', but this property does not carry through to the file generation stage.
TagsNo tags attached.
Attached Filestxt file icon CMakeLists.txt [^] (278 bytes) 2016-01-13 18:16 [Show Content]
txt file icon CMakeLists-15917-ng.txt [^] (430 bytes) 2016-01-14 03:21 [Show Content]

 Relationships

  Notes
(0040228)
Nils Gladitz (developer)
2016-01-14 03:22

The distinction is not made through <ConfigurationType>.

GUI/Windows (WinMain) applications use:
    <SubSystem>Windows</SubSystem>

While console (main) applications use:
    <SubSystem>Console</SubSystem>

I attached a self-contained working example for both (CMakeLists-15917-ng.txt; rename to CMakeLists.txt).
(0040245)
Daniel Williams (reporter)
2016-01-14 14:24

Understood.

I show adding the WIN32 tag to change the tag in the vcxproj as intended.

And I tracked down the error to a badly-configured dependency, (which exhibited the same link error symptom).

Therefore, I vote to close this issue as resolved.
(0041287)
Kitware Robot (administrator)
2016-06-10 14:21

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2016-01-13 18:16 Daniel Williams New Issue
2016-01-13 18:16 Daniel Williams File Added: CMakeLists.txt
2016-01-14 03:21 Nils Gladitz File Added: CMakeLists-15917-ng.txt
2016-01-14 03:22 Nils Gladitz Note Added: 0040228
2016-01-14 14:24 Daniel Williams Note Added: 0040245
2016-01-14 14:45 Nils Gladitz Status new => resolved
2016-01-14 14:45 Nils Gladitz Resolution open => no change required
2016-01-14 14:45 Nils Gladitz Assigned To => Nils Gladitz
2016-01-14 14:45 Brad King Assigned To Nils Gladitz =>
2016-06-10 14:21 Kitware Robot Note Added: 0041287
2016-06-10 14:21 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team