Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Warning: Policy CMP0054 is not set #44

Closed
j-o opened this issue Jan 26, 2017 · 6 comments
Closed

CMake Warning: Policy CMP0054 is not set #44

j-o opened this issue Jan 26, 2017 · 6 comments
Assignees

Comments

@j-o
Copy link

j-o commented Jan 26, 2017

Output using CMake 3.6.1.:

Lib baselib
Lib fiblib
Example fibcmd
Example fibgui
CMake Warning (dev) at cmake/CompileOptions.cmake:52 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "MSVC" will no longer be dereferenced when the policy
  is set to NEW.  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  source/tests/CMakeLists.txt:17 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/CompileOptions.cmake:67 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "MSVC" will no longer be dereferenced when the policy
  is set to NEW.  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  source/tests/CMakeLists.txt:17 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/CompileOptions.cmake:94 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "MSVC" will no longer be dereferenced when the policy
  is set to NEW.  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  source/tests/CMakeLists.txt:17 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/CompileOptions.cmake:144 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "MSVC" will no longer be dereferenced when the policy
  is set to NEW.  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  source/tests/CMakeLists.txt:17 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

Test fiblib-test
Configuring done
@scheibel
Copy link
Member

scheibel commented Feb 1, 2017

Seems like MSVC is a variable defined when running CMake with a Visual Studio generator. Then, the compiler id check against "MSVC" can be interpreted as a compiler id check against On if CMake would dereference "MSVC" instead of treating it as a string.
However, we intentionally set the policy CMP0054 to NEW so that this behavior should not occur and even the warning should not occur. Can someone with a MSVC generator can have a look at this?

@kateyy
Copy link
Contributor

kateyy commented Feb 1, 2017

It seems that the problem is in sources/tests/CMakeLists.txt: cmake_minimum_required resets the CMake policy settings and CompileOptions.cmake is included before setting CMP0054 to NEW.
I've seen this warning when building glbinding with tests (MSVC).

@scheibel
Copy link
Member

scheibel commented Feb 1, 2017

Thanks for investigating. I think this can be fixed. 😄

scheibel added a commit that referenced this issue Feb 1, 2017
@scheibel scheibel assigned scheibel and unassigned scheibel Feb 1, 2017
@kateyy
Copy link
Contributor

kateyy commented Feb 1, 2017

What happens when you build cmake-init based projects with CMake 3.0? I would assume that it implicitly dereferences MSVC to On or Off, so that CompileOptions.cmake would never be able to detect the MSVC compiler. I'm not sure if this is true, i never tested this behavior.
Note: CMP0054 was introduced in CMake 3.1, and you allow building your projects with CMake 3.0

@scheibel
Copy link
Member

scheibel commented Feb 1, 2017

The second problem I suppose is solved as our set_policy function tests internally if the policy is available with the current CMake version.
The old behavior that is active with CMake 3.0 should indeed result in wrong behavior using MSVC generators; we have to adjust the code accordingly.

@scheibel
Copy link
Member

scheibel commented Feb 1, 2017

I suggest we discuss the CMake 3.0 and MSVC compiler options issue in #49.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants