MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0014052 | CMake | CMake | public | 2013-03-31 11:57 | 2016-06-10 14:31 |
Reporter | alecool | ||||
Assigned To | Kitware Robot | ||||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | moved | ||
Platform | PC | OS | Windows | OS Version | 7 64 bit |
Product Version | CMake 2.8.10.2 | ||||
Target Version | Fixed in Version | ||||
Summary | 0014052: System-specific variables are undefined before using project() command | ||||
Description | Using a trivial CMakeLists.txt, the MSVC variable is NOT defined when I add a project() command. The bug is reproduced with both generators "Visual Studio 10" and "Visual Studio 11" as well as the Win64 versions. Likewise, the MSYS variable is undefined when using the "MSYS Makefiles" generator. These are the only build toolsets that I cared to install on my system. | ||||
Steps To Reproduce | ### Using the following CMakeLists.txt CMAKE_MINIMUM_REQUIRED(VERSION 2.8) message( INFO ${CMAKE_GENERATOR} ) if(WIN32) message(INFO Win32) if(MSVC) message(INFO MSVC) else() message(INFO not MSVC) endif() if(MSVC_IDE) message(INFO MSVC_IDE) else() message(INFO not MSVC_IDE) endif() if(MSYS) message(INFO MSYS) else() message(INFO not MSYS) endif() else() message(INFO not Win32) endif() #Project configuration project (test) message( INFO ${CMAKE_GENERATOR} ) if(WIN32) message(INFO Win32) if(MSVC) message(INFO MSVC) else() message(INFO not MSVC) endif() if(MSVC_IDE) message(INFO MSVC_IDE) else() message(INFO not MSVC_IDE) endif() if(MSYS) message(INFO MSYS) else() message(INFO not MSYS) endif() else() message(INFO not Win32) endif() I get the following output: >cmake -G"Visual Studio 11" .. INFOVisual Studio 11 INFOWin32 INFOnotMSVC INFOnotMSVC_IDE INFOnotMSYS -- The C compiler identification is MSVC 17.0.51106.1 -- The CXX compiler identification is MSVC 17.0.51106.1 -- Check for working C compiler using: Visual Studio 11 -- Check for working C compiler using: Visual Studio 11 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler using: Visual Studio 11 -- Check for working CXX compiler using: Visual Studio 11 -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done INFOVisual Studio 11 INFOWin32 INFOMSVC INFOMSVC_IDE INFOnotMSYS -- Configuring done -- Generating done -- Build files have been written to: E:/dev/cpp/test/TestCMake/VC11_x86 ### Removing the project command as follows: CMAKE_MINIMUM_REQUIRED(VERSION 2.8) message( INFO ${CMAKE_GENERATOR} ) if(WIN32) message(INFO Win32) if(MSVC) message(INFO MSVC) else() message(INFO not MSVC) endif() if(MSVC_IDE) message(INFO MSVC_IDE) else() message(INFO not MSVC_IDE) endif() if(MSYS) message(INFO MSYS) else() message(INFO not MSYS) endif() else() message(INFO not Win32) endif() #Project configuration # project (test) message( INFO ${CMAKE_GENERATOR} ) if(WIN32) message(INFO Win32) if(MSVC) message(INFO MSVC) else() message(INFO not MSVC) endif() if(MSVC_IDE) message(INFO MSVC_IDE) else() message(INFO not MSVC_IDE) endif() if(MSYS) message(INFO MSYS) else() message(INFO not MSYS) endif() else() message(INFO not Win32) endif() I get the following output, which was expected with the previous CMakeLists.txt >cmake -G"Visual Studio 11" .. -- The C compiler identification is MSVC 17.0.51106.1 -- The CXX compiler identification is MSVC 17.0.51106.1 -- Check for working C compiler using: Visual Studio 11 -- Check for working C compiler using: Visual Studio 11 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler using: Visual Studio 11 -- Check for working CXX compiler using: Visual Studio 11 -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done INFOVisual Studio 11 INFOWin32 INFOMSVC INFOMSVC_IDE INFOnotMSYS INFOVisual Studio 11 INFOWin32 INFOMSVC INFOMSVC_IDE INFOnotMSYS -- Configuring done -- Generating done -- Build files have been written to: E:/dev/cpp/test/TestCMake/VC11_x86 | ||||
Additional Information | We observe that depending on the presence and the position of the project() command, the behavior of code dependent on the definition of system-specific variables can change a great deal. I couldn't find any documentation whether this is known and specified behavior, and it seems a bit counter-intuitive that a command documented as "Setting a name for the entire project" would influence the behavior of a cmake script that much. | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2013-03-31 11:57 | alecool | New Issue | |||
2013-03-31 14:29 | Eric NOULARD | Note Added: 0032732 | |||
2013-03-31 17:06 | alecool | Note Added: 0032733 | |||
2013-04-01 08:04 | Brad King | Note Added: 0032734 | |||
2016-06-10 14:28 | Kitware Robot | Note Added: 0042258 | |||
2016-06-10 14:28 | Kitware Robot | Status | new => resolved | ||
2016-06-10 14:28 | Kitware Robot | Resolution | open => moved | ||
2016-06-10 14:28 | Kitware Robot | Assigned To | => Kitware Robot | ||
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|