[CMake] Policy CMP0063 is not set: Honor visibility properties for all target
Alexander Shukaev
cmake at Alexander.Shukaev.name
Sat Jun 18 07:03:29 EDT 2016
On 06/18/2016 12:18 PM, Nils Gladitz wrote:
> On 18.06.2016 11:38, Alexander Shukaev wrote:
>>
>> I did try both variants, after and before
>>
>> cmake_minimum_required(VERSION)
>>
>> but the result is the same. The scope is for sure parent to targets.
>
> I don't know what else it could be but this works fine for me:
>
> cmake_minimum_required(VERSION 2.8.12)
>
> if(POLICY CMP0063)
> cmake_policy(SET CMP0063 NEW)
> endif()
>
> file(WRITE foo.cpp "int main() {}")
>
> set(CMAKE_CXX_VISIBILITY_PRESET hidden)
>
> add_executable(foo foo.cpp)
>
>
> Is it possible that the scope where the policy warning comes from has
> its own cmake_minimum_required(VERSION) call? (e.g. is there more than
> one?)
>
> Nils
>
You were right, Nils. I have a CMake library that is pretty huge. When
one does `find_package' for it, then it will `include' all its modules
into the client code. Back when I started it, I didn't know that
`cmake_minimum_required' can reset policies. So there were a couple of
modules that were still calling `cmake_minimum_required' which is
clearly a bad practice. I cleaned it up and it works now.
However, now the sequence is like this
xxx.cmake:
if(POLICY CMP0011)
cmake_policy(SET CMP0011 NEW)
endif()
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
CMakeLists.txt:
include(xxx)
cmake_minimum_required(VERSION 3.1.0)
and it still works. Is it because the version is high enough so it does
not reset policies?
Alexander
More information about the CMake
mailing list