View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0032921 | Open CASCADE | OCCT:Configuration | public | 2022-04-07 12:12 | 2022-06-24 13:21 |
Reporter | ddzama | Assigned To | ddzama | ||
Priority | normal | Severity | feature | ||
Status | assigned | Resolution | open | ||
Platform | Windows | OS | VC++ 2019 | ||
Target Version | 7.7.0 | ||||
Summary | 0032921: Configuration, CMake - allow selecting C++ standard | ||||
Description | Microsoft Visual Studio Professional 2019 Version 16.11.11 std=c++20 Make C++ standard to be enable from cmake settings: Now, user can choose standard by setting cmake variable CPP_STANDARD. Available next standard items: C++11 C++14 C++17 C++20 C++23 | ||||
Steps To Reproduce | Not required | ||||
Tags | No tags attached. | ||||
Test case number | N/A | ||||
|
Branch CR32921 has been created by ddzama. SHA-1: cafb923ca794c56fe8e69d75852d991b74c48b7b Detailed log of new commits: Author: Dmitry DZAMA Date: Tue Mar 29 16:33:45 2022 +0300 0032921: Make C++ standard to be enable from cmake settings Microsoft Visual Studio Professional 2019 Version 16.11.11 std=c++20 Make C++ standard to be enable from cmake settings: Now, user can choose standard by setting cmake variable CPP_STANDARD. Availabale next standard itemd: C++11 C++14 C++17 C++20 C++23 |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: 8b963c1d75a0d097249cb5f715b6ae8fc4dbbfc8 |
|
+# Set desired C++ standard +if ("${CPP_STANDARD}" STREQUAL "C++11") + set (CMAKE_CXX_STANDARD 11) According to documentation: > CMAKE_CXX_STANDARD - New in version 3.1. While CMakeLists.txt in OCCT specifies: > cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) Either we need to increase minimal requirements to CMake, or fallback should be applied for older CMake versions (passing C++11 to compiler flags as before). |
|
Now, different libs have different requirement to CMAKE version: adm/cmake/cotire.cmake:cmake_minimum_required(VERSION 2.8.12) CMakeLists.txt:cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) samples/glfw/CMakeLists.txt:cmake_minimum_required(VERSION 3.2) samples/java/jniviewer/app/src/main/jni/CMakeLists.txt:cmake_minimum_required(VERSION 3.4.1) samples/mfc/standard/01_Geometry/CMakeLists.txt:cmake_minimum_required (VERSION 2.6) samples/mfc/standard/02_Modeling/CMakeLists.txt:cmake_minimum_required (VERSION 2.6) samples/mfc/standard/03_ImportExport/CMakeLists.txt:cmake_minimum_required (VERSION 2.6) samples/mfc/standard/04_HLR/CMakeLists.txt:cmake_minimum_required (VERSION 2.6) samples/mfc/standard/mfcsample/CMakeLists.txt:cmake_minimum_required (VERSION 2.6) samples/webgl/CMakeLists.txt:cmake_minimum_required(VERSION 3.2) samples/xaml/CMakeLists.txt:cmake_minimum_required(VERSION 3.4.0) tools/CMakeLists.txt:cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) Maybe use unique requirement to CMAKE version, set in main cmake file? |
|
@ddzama, I don't see how CMake requirements to build some sample depend on CMake requirements for building OCCT. Samples could be built using OCCT pre-built on another computer with another CMake version and without using CMake at all. And a particular sample might indeed require a higher CMake version than OCCT itself - but OCCT users are not required to build all these samples. But there is another issue with the patch - it is unclear which consequences could be building OCCT and projects (samples, OCC Products) with mixed/incompatible versions of C++ standard. So that I guess C++ version selection should be propagated to all samples and OCC Products (could be done in dedicated bug/patch). |
|
Branch CR32921 has been updated by ddzama. SHA-1: 18738b72e9fa73afc791b44094d73b49d2bf7862 Detailed log of new commits: Author: ddzama Date: Fri Apr 8 14:43:59 2022 +0300 require minimum CMAKE version 3.1 (for enabling CMAKE_CXX_STANDARD) |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: 73e424210859e0303f5ed4da04d46a2940aed41e |
|
Branch CR32921 has been updated by ddzama. SHA-1: 0e3d7c4cbdfce581e8a359a7a281a93f8e6461e7 Detailed log of new commits: Author: ddzama Date: Mon Apr 25 12:16:14 2022 +0300 0032921: Preserve cmake policies. |
|
Branch CR32921 has been updated by ddzama. SHA-1: e76e6b90dfc427439bc381da20df8765e1245e81 Detailed log of new commits: Author: ddzama Date: Mon Apr 25 17:37:13 2022 +0300 Revert "0032921: Fix `if()` contents for employing new cmake policy `CMP0054`, started since version 3.1." This reverts commit 73e424210859e0303f5ed4da04d46a2940aed41e. |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: 6b480960d6af94baf41c94f9c5bd9d2d732463a1 |
|
@ddzama+# For moving from minimal cmake version 2.8.12 to 3.1, +# we, nevertheless, have to use 2.8.12 cmake policies +cmake_policy(VERSION 2.8) ... +# Set cmake version, but preserve cmake policies +cmake_policy(PUSH) +cmake_minimum_required (VERSION 3.1 FATAL_ERROR) +cmake_policy(POP) There is no way to use new polices from CMake 3.1 without warnings? They are useless and step in a wrong direction? |
|
+else () + set (CMAKE_CXX_STANDARD 23) Why "else" means "23"? Shouldn't be there an error in case of unknown string? --- a/adm/genproj.tcl +++ b/adm/genproj.tcl I don't think modifications of Code::Blocks generator have been actually tested and are necessary in scope of this patch. If we would like to expose C++ standard selection with 'genproj.bat' - at first, Visual Studio project files should be updated and selection should be exposed to `genconf.tcl`. This could be postponed to a dedicated patch. > Availabale next standard itemd: Two misprints. > Microsoft Visual Studio Professional 2019 > Version 16.11.11 > std=c++20 This text looks unrelated to commit message. > Now, user can choose standard by setting cmake variable CPP_STANDARD. Documentation should be updated to mention new CMake parameter. |
|
Consider renaming new CMake variable to have `BUILD_` prefix for better grouping. |
|
@kgv, yes. If moving cmake minimum required version from 2.8 to 3.1, the list of new policies is applied by default (if not preserve policies, as proposed above). If not preserve policies, compilation on Windows will cause errors. Introduced in 3.0 CMP0050: Disallow add_custom_command SOURCE signatures. CMP0049: Do not expand variables in target source entries. CMP0048: project() command manages VERSION variables. CMP0047: Use QCC compiler id for the qcc drivers on QNX. CMP0046: Error on non-existent dependency in add_dependencies. CMP0045: Error on non-existent target in get_target_property. CMP0044: Case sensitive Lang_COMPILER_ID generator expressions. CMP0043: Ignore COMPILE_DEFINITIONS_Config properties. CMP0042: MACOSX_RPATH is enabled by default. CMP0041: Error on relative include with generator expression. CMP0040: The target in the TARGET signature of add_custom_command() must exist. CMP0039: Utility targets may not have link dependencies. CMP0038: Targets may not link directly to themselves. CMP0037: Target names should not be reserved and should match a validity pattern. CMP0036: The build_name command should not be called. CMP0035: The variable_requires command should not be called. CMP0034: The utility_source command should not be called. CMP0033: The export_library_dependencies command should not be called. CMP0032: The output_required_files command should not be called. CMP0031: The load_command command should not be called. CMP0030: The use_mangled_mesa command should not be called. CMP0029: The subdir_depends command should not be called. CMP0028: Double colon in target name means ALIAS or IMPORTED target. CMP0027: Conditionally linked imported targets with missing include directories. CMP0026: Disallow use of the LOCATION target property. CMP0025: Compiler id for Apple Clang is now AppleClang. CMP0024: Disallow include export result. And introduced in 3.1 CMP0054: Only interpret if() arguments as variables or keywords when unquoted. CMP0053: Simplify variable reference and escape sequence evaluation. CMP0052: Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES. CMP0051: List TARGET_OBJECTS in SOURCES target property. |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: 0bdb1002364e321ab155c14e869890f6ad974765 |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: 32bda6940ed830a337c9431121a14d97d9bcb656 |
|
@ddzama, my question was different - policies in CMake looks like a compatibility hacks, and I'm not sure that the old policies will not be removed in some newer CMake release. So the question is actually - is it possible update our CMake scripts so that they will be compatible with new CMake policies without playing with policies? |
|
@kgv, i think it is, but, firstly - i should define what particular new policy(s) breaks compilation. And second - find out, how to fix it. And, yes, old policies may be removed in newer version of CMake software. Will i do this work now in current ticket? |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: b3bba91506387d8d50ab30fbd8618d845265ca40 |
|
@kgv, new policies (one or more from them) breaks compilation on MacOS. I try to find out the cause by comparing successed build directory with failed build directory, but until current moment unsuccessful. |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: 82da07e44807cce3bba190d55a29f6d9c5f9d191 |
|
@kgv, the problem on MacOs was in naming of cxx compilator. This is strange, but if we use cmake minimal 2.8 it called Clang, when we require 3.1 as minimal version - AppleClang. So, I fixed it by replace more strength STREQUAL operator to MATCHES one and just in case make it case insensitive. Successfully finished jenkins: http://jenkins-test-occt.nnov.opencascade.com/view/CR32887-master-ddzama/view/GIT/ |
|
> if we use cmake minimal 2.8 it called Clang, when we require 3.1 as minimal version - AppleClang. Interesting to know. I guess CMake developers decided to introduce "AppleClang" to distinguish this CLang fork coming with XCode. As these compilers have independent and inconsistent versioning, specific bugs and features sets, tracking them as the same one complicated handling some corner cases. |
|
@ddzama, if patch is ready for review, please don't forget to switch bug into appropriate state. |
|
@kgv, sorry for my late response. My activity in this direction has been suspended by other projects, and I do not understend entirely your last remark -should I change installatin direcory for occt, depending on cmake variable CMAKE_COMPILER_ID, and, therefore, for IFC, because IFC should receive the same installation directory. By other words, should we install occt in AppleClang/ directory or clang/ directory is stay fine? |
|
@ddzama, I didn't put any remark related to AppleClang - just put a comment. I don't know how it affects installation directory. In my opinion all CLang checks in CMake scripts should be updated to treat both values - in the same way. Save the parts, where AppleClang is supposed to be handled differently - I guess such places might be found in `if(APPLE)` cases in existing scripts (don't know if it worth changing these places). |
|
@kgv, ok There would be one commit - now there is not any reason to preserve policies when requiring cmake_minimal_version (VERSION 3.1) |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: dc9e78147e5bef405480e433b7033a91f031ee5f |
|
@kgv, sorry. I think we should push before and pop after policies requiring cmake version outside main CMakeLists.txt, because it may be changed in future. After achieving jenkins result, i move this ticket. |
|
@msv, please comment if you have any remarks to proposed solution. |
|
When using the variable CMAKE_CXX_STANDARD to set standard to C++14 when building ASRV on Ubuntu 18.04 with gcc 7.5 and cmake 3.22.1, I faced with the problem that GCC indeed used the standard C++11. So, setting only that variable does not dictate cmake to use this standard mandatory. I found the solution by setting the following: set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) So, I propose to include this setting in our scripts, too. |
|
One more remark, I did not understand why we left the old policies in some samples' scripts? Is it possible to avoid this? |
|
What about the same feature in occt-products repository? I think this ticket must include changes there, too. |
|
@msv > set(CMAKE_CXX_STANDARD_REQUIRED ON) Would this lead to failure building with default C++11 option on VS2019, as this compiler doesn't support this standard or this check validates only `>=`? |
|
Branch CR32921 has been updated by ddzama. SHA-1: 67f59a1b0ab2a1f2dc28bb204f73060e17ddf0ce Detailed log of new commits: Author: ddzama Date: Wed May 25 07:33:34 2022 +0300 0032921: do not preserve policies |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: 625aa3594315c5682b4ec7b11c223208e5dd3c2c |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: e57072dad28765863d2362023617f75c83fd8368 |
|
@kgv, @msv set(CMAKE_CXX_STANDARD_REQUIRED ON) has been added after setting c++ standard. get rid of preserving cmake policies. Jenkins teset has been executed successfully. |
|
> So, source of error has been localizedin file occt_toolkit.cmake, in lines ~325 and ~327. Information about line numbers doesn't look useful in git commit description. The patch should be squashed into a single commit before integration / sending for review (squashed patch pushed to a branch with incremented revision number). |
|
Still waiting actual test results. |
|
Branch CR32921 has been updated by ddzama. SHA-1: 5747d04a6ec0f8cb5ac6a1709f4ee2a66b794719 Detailed log of new commits: Author: ddzama Date: Mon May 30 00:03:01 2022 +0300 0032921: use std/c++20 as default c++ language standard |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: 3b75a51a7525dedb1db96470b3e58c8a9b1b9da0 |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: a2c019bd12d3149ed5ee8f600b9bcb3d943e193c |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: a035f39ce25c76ea804b875b00954dd9724620e4 |
|
Branch CR32921 has been updated forcibly by ddzama. SHA-1: dd7d6cc2cf437164174b9463ba82f21a122d420b |
|
@msv - please, see on testing results on jenkins-8 and jenkins-11 http://jenkins-test-occt.nnov.opencascade.com/view/CR32887-cxx11/view/COMPARE/ http://jenkins-test-11.nnov.opencascade.com/view/CR32887_CR32887/ |
|
@ddzamaddzama => bugmaster assigned => resolved Please never assign bugs in RESOLVED state to bugmaster - bugs should be assigned to reviewer first. |
|
@ddzama+# So, it should compiles with c++11/c++14 language standard. `should be compiled`. +# Current Qt version is incompatible with c++20. Which exactly `current version` is mentioned here? Please be more specific in the code, not just in git commit description. because of incomatibility of 5.11.2 version of Qt library interface with C++20 standard. `incomatibility` misprint. Qt 5 is NOT the latest version of this library, users are already using Qt 6 in some projects. +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) \ No newline at end of file Please add suggested newlines. These repetitive hacks in individual projects looks fragile - it would be better unifying this somehow. |
Date Modified | Username | Field | Change |
---|---|---|---|
2022-04-07 12:12 | ddzama | New Issue | |
2022-04-07 12:12 | ddzama | Assigned To | => ddzama |
2022-04-07 12:20 | kgv | Category | OCCT:Coding => OCCT:Configuration |
2022-04-07 12:20 | kgv | Summary | Make C++ standard to be enable from cmake settings => Configuratiuon, CMake - allow selecting C++ standard |
2022-04-07 12:20 | kgv | Description Updated | |
2022-04-07 12:20 | kgv | Relationship added | child of 0032887 |
2022-04-07 14:21 | git | Note Added: 0107681 | |
2022-04-07 14:44 | git | Note Added: 0107706 | |
2022-04-07 14:51 | ddzama | Relationship deleted | child of 0032887 |
2022-04-07 14:54 | ddzama | Relationship added | child of 0032887 |
2022-04-08 01:45 | kgv | Note Added: 0107735 | |
2022-04-08 10:00 | ddzama | Note Added: 0107740 | |
2022-04-08 14:23 | kgv | Note Added: 0107754 | |
2022-04-08 14:24 | kgv | Note Edited: 0107754 | |
2022-04-08 14:44 | git | Note Added: 0107755 | |
2022-04-20 11:14 | git | Note Added: 0108038 | |
2022-04-25 15:35 | git | Note Added: 0108152 | |
2022-04-25 17:37 | git | Note Added: 0108166 | |
2022-04-26 02:13 | git | Note Added: 0108178 | |
2022-04-26 11:30 | ddzama | Assigned To | ddzama => bugmaster |
2022-04-26 11:30 | ddzama | Status | new => resolved |
2022-04-26 11:30 | ddzama | Steps to Reproduce Updated | |
2022-04-26 16:47 | kgv | Assigned To | bugmaster => kgv |
2022-04-26 21:47 | kgv | Note Added: 0108200 | |
2022-04-26 22:02 | kgv | Note Added: 0108201 | |
2022-04-26 22:02 | kgv | Assigned To | kgv => ddzama |
2022-04-26 22:02 | kgv | Status | resolved => assigned |
2022-04-26 22:02 | kgv | Test case number | => N/A |
2022-04-26 22:03 | kgv | Note Edited: 0108201 | |
2022-04-26 22:05 | kgv | Note Added: 0108202 | |
2022-04-26 22:06 | kgv | Summary | Configuratiuon, CMake - allow selecting C++ standard => Configuration, CMake - allow selecting C++ standard |
2022-04-26 22:06 | kgv | Severity | minor => feature |
2022-04-26 22:06 | kgv | Product Version | 7.7.0 => |
2022-05-04 15:12 | ddzama | Note Added: 0108304 | |
2022-05-04 15:15 | ddzama | Note Edited: 0108304 | |
2022-05-04 15:16 | git | Note Added: 0108305 | |
2022-05-04 15:21 | git | Note Added: 0108308 | |
2022-05-04 15:29 | kgv | Note Added: 0108309 | |
2022-05-04 15:48 | ddzama | Note Added: 0108314 | |
2022-05-05 15:02 | git | Note Added: 0108349 | |
2022-05-06 12:51 | ddzama | Note Added: 0108365 | |
2022-05-06 16:13 | git | Note Added: 0108379 | |
2022-05-07 01:08 | ddzama | Note Added: 0108381 | |
2022-05-13 00:28 | kgv | Note Added: 0108419 | |
2022-05-18 11:07 | kgv | Note Added: 0108480 | |
2022-05-20 05:41 | ddzama | Note Added: 0108504 | |
2022-05-20 12:25 | kgv | Note Added: 0108509 | |
2022-05-20 12:50 | ddzama | Note Added: 0108510 | |
2022-05-20 12:51 | ddzama | Assigned To | ddzama => bugmaster |
2022-05-20 12:51 | ddzama | Status | assigned => resolved |
2022-05-20 12:51 | ddzama | Assigned To | bugmaster => ddzama |
2022-05-20 12:51 | ddzama | Status | resolved => assigned |
2022-05-20 12:53 | ddzama | Note Edited: 0108510 | |
2022-05-20 12:58 | ddzama | Note Edited: 0108504 | |
2022-05-25 07:35 | git | Note Added: 0108601 | |
2022-05-25 07:41 | ddzama | Note Added: 0108603 | |
2022-05-25 09:58 | ddzama | Assigned To | ddzama => bugmaster |
2022-05-25 09:58 | ddzama | Status | assigned => resolved |
2022-05-25 11:14 | kgv | Assigned To | bugmaster => msv |
2022-05-25 11:14 | kgv | Note Added: 0108604 | |
2022-05-25 12:49 | msv | Note Added: 0108605 | |
2022-05-25 12:51 | msv | Note Added: 0108606 | |
2022-05-25 12:53 | msv | Note Added: 0108607 | |
2022-05-25 12:53 | msv | Assigned To | msv => ddzama |
2022-05-25 12:53 | msv | Status | resolved => assigned |
2022-05-25 12:54 | msv | Note Edited: 0108605 | |
2022-05-25 13:15 | kgv | Note Added: 0108609 | |
2022-05-26 16:41 | git | Note Added: 0108630 | |
2022-05-27 10:01 | git | Note Added: 0108639 | |
2022-05-27 10:11 | git | Note Added: 0108640 | |
2022-05-27 13:04 | ddzama | Note Added: 0108646 | |
2022-05-27 13:04 | ddzama | Assigned To | ddzama => bugmaster |
2022-05-27 13:04 | ddzama | Status | assigned => resolved |
2022-05-27 13:31 | msv | Assigned To | bugmaster => msv |
2022-05-27 14:20 | kgv | Note Added: 0108653 | |
2022-05-27 14:20 | kgv | Note Edited: 0108653 | |
2022-05-27 14:39 | msv | Assigned To | msv => ddzama |
2022-05-27 14:39 | msv | Status | resolved => assigned |
2022-05-27 14:39 | msv | Note Added: 0108655 | |
2022-05-30 00:16 | git | Note Added: 0108736 | |
2022-05-30 00:18 | git | Note Added: 0108737 | |
2022-06-02 13:24 | git | Note Added: 0108791 | |
2022-06-03 04:39 | ddzama | Relationship added | child of 0032957 |
2022-06-03 12:40 | git | Note Added: 0108821 | |
2022-06-17 16:48 | ddzama | Relationship deleted | child of 0032887 |
2022-06-20 13:36 | ddzama | Relationship added | child of 0032887 |
2022-06-20 13:36 | ddzama | Relationship deleted | child of 0032957 |
2022-06-21 11:40 | git | Note Added: 0109136 | |
2022-06-24 07:07 | ddzama | Note Added: 0109211 | |
2022-06-24 07:14 | ddzama | Assigned To | ddzama => bugmaster |
2022-06-24 07:14 | ddzama | Status | assigned => resolved |
2022-06-24 09:40 | kgv | Note Added: 0109217 | |
2022-06-24 09:40 | kgv | Assigned To | bugmaster => msv |
2022-06-24 09:41 | kgv | Note Added: 0109218 | |
2022-06-24 13:21 | msv | Assigned To | msv => ddzama |
2022-06-24 13:21 | msv | Status | resolved => assigned |