CMake error, if version less than 3.8
davidwed opened this issue · 5 comments
If I want to create the json_dto library with a CMake version lesser than 3.8 I get the following error:
CMake Error at json_dto/CMakeLists.txt:13 (set_target_properties):
INTERFACE_LIBRARY targets may only have whitelisted properties. The
property "CXX_STANDARD" is not allowed.
CMake Error at json_dto/CMakeLists.txt:13 (set_target_properties):
INTERFACE_LIBRARY targets may only have whitelisted properties. The
property "CXX_STANDARD_REQUIRED" is not allowed.
CMake Error at json_dto/CMakeLists.txt:13 (set_target_properties):
INTERFACE_LIBRARY targets may only have whitelisted properties. The
property "CXX_EXTENSIONS" is not allowed.
CMake prior to 3.8 is a rather old version. Do you really haven't a possibility to use more modern versions of CMake?
I am currently testing if I can use json_dto on different Linux distributions.
Debian 9.x for example uses cmake 3.7.2
BTW: If cmake 3.8 is default, you should change "cmake_minimum_required(VERSION 3.3)".
I remember that we did testing of json_dto's CMake build files with old CMake a long time ago and because of that CMakeLists.txt contains the following lines:
IF (${CMAKE_VERSION} VERSION_LESS "3.8.0")
set_target_properties(${JSON_DTO} PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
ELSE ()
target_compile_features(${JSON_DTO} INTERFACE cxx_std_14)
ENDIF ()
But I can't understand why it's not working now. Googling such errors leads to CMake's issues and it seems that this approach should work.
We'll investigate this issue further. If there the actual reason won't be found we'll accept your PR.
Thanks for reporting that!
I think it has something to do with the whitelist restriction that is used when using INTERFACE_* or IMPORTED_* in CMake < 3.8
https://gitlab.kitware.com/cmake/cmake/issues/17214
https://gitlab.kitware.com/cmake/cmake/issues/17217
The current problem for me now is to understand why we decided that this approach works. Maybe it was our mistake during the testing, maybe something else. I don't know yet.