cmake_policy appears to do nothing
Hi all. I'm on a centos8 system with cmake 3.18.2-11 installed. I've been beating my head trying to use swig support and silence the policy warning. Here's my reduced test. You can see I've tried setting policy to either old or new and in different places. Nothing seems to work:
(base) [jlquinn@bertdev01 blah2]$ cat CMakeLists.txt
# -*-cmake-*-
cmake_policy(SET CMP0078 NEW)
cmake_minimum_required (VERSION 3.16)
project(blah2)
cmake_policy(SET CMP0078 NEW)
#cmake_policy(SET CMP0078 OLD)
find_package(SWIG 3.0 REQUIRED)
cmake_policy(SET CMP0078 NEW)
#cmake_policy(SET CMP0078 OLD)
#cmake_policy(SET CMP0086 OLD)
include(UseSWIG)
cmake_policy(SET CMP0078 NEW)
#cmake_policy(SET CMP0078 OLD)
#cmake_policy(SET CMP0086 OLD)
#message("XXX policy 78 ${biteme}")
swig_add_library(blahpy LANGUAGE python SOURCES blah.i)
(base) [jlquinn@bertdev01 blah2]$ cat blah.i
(base) [jlquinn@bertdev01 blah2]$ cmake -B opt -S . -DCMAKE_BUILD_TYPE=relwithdebinfo
-- The C compiler identification is GNU 8.4.1
-- The CXX compiler identification is GNU 8.4.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SWIG: /bin/swig (found suitable version "3.0.12", minimum required is "3.0")
CMake Warning (dev) at /usr/share/cmake/Modules/UseSWIG.cmake:632 (message):
Policy CMP0078 is not set: UseSWIG generates standard target names. Run
"cmake --help-policy CMP0078" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
Call Stack (most recent call first):
CMakeLists.txt:22 (swig_add_library)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jlquinn/blah2/opt
Any help would be appreciated Thanks Jerry