This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/split_celix_cxx_option in repository https://gitbox.apache.org/repos/asf/celix.git
commit 9c5476b5a604b517854376c54fb6753cc71fc42c Author: Pepijn Noltes <[email protected]> AuthorDate: Sun Dec 4 17:06:35 2022 +0100 Update CMakeLists.txt and dev_celix_with_clion.md to allow optimal C++17 support in the CLion IDE --- CMakeLists.txt | 9 ++++++++- documents/building/dev_celix_with_clion.md | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40d538e4..e2f8d5b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,14 @@ set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_FLAGS}") # Set C++ specific flags -set(CMAKE_CXX_STANDARD 14) #Celix header only C++ supported is based on C++14. +if (NOT DEFINED CMAKE_CXX_STANDARD) + #Celix header only C++ supported is based on C++14 and C++17. + #Default using C++14 to ensure the code compiles for C++14. + #To ensure IDE like CLion can provide optimal C++17 support, the CMAKE_CXX_STANDARD variable is only set if + #not already defined. + set(CMAKE_CXX_STANDARD 14) +endif () + set(CMAKE_CXX_FLAGS "-fno-rtti ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-Wall -Werror -Wextra -Weffc++ ${CMAKE_CXX_FLAGS}") diff --git a/documents/building/dev_celix_with_clion.md b/documents/building/dev_celix_with_clion.md index dd6cbbed..a2e3d49f 100644 --- a/documents/building/dev_celix_with_clion.md +++ b/documents/building/dev_celix_with_clion.md @@ -26,6 +26,14 @@ Conan will arrange the building of the Apache Celix dependencies and generate Fi Conan will also generate a `active_run.sh` and `deactivate_run.sh` script that does the environment (de)setup for the binary locations of the build dependencies (i.e. configures `PATH` and `LD_LIBRARY_PATH`/`DYLD_LIBRARY_PATH`). +## Configuring CLion for C++17 +C++ code in Celix is default configured for C++14. This is manually changed for C++17 libraries, bundles and test code +by updating the CMAKE_CXX_STANDARD var (`set(CMAKE_CXX_STANDARD 17`) in their respective CMakelists.txt files. + +The downside is that CLion seems to only take into account the top level CMAKE_CXX_STANDARD value. +To ensure that CLion provides the right syntax support for C++17, add `-DCMAKE_CXX_STANDARD=17` to the `CMake Options` +in `File` -> `Settings` -> `Build, Execution, Deployment` -> `CMake`. + ## Setting up the build directory ```shell #clone git repo @@ -61,4 +69,4 @@ then update the "Google Test" template so that the `active_run.sh` Conan generat If the Apache Celix CMake build directory is `home/joe/workspace/celix/cmake-build-debug` then the value for "Environment variables" should be: `source /home/joe/workspace/celix/cmake-build-debug/activate_run.sh` - \ No newline at end of file +
