From: "cron2 (Code Review)" Date: Wed, 20 Dec 2023 17:07:42 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., heiko@...515..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <26b97a9c8b7ce9d4b63b29f9d5fd9eccc449bebb-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="a5lSF7F4WFk="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: cmake: create and link compile_commands.json file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: d12fk Cc: flichtenheld , plaisthos , openvpn-devel --a5lSF7F4WFk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/48= 3?usp=3Demail ) Change subject: cmake: create and link compile_commands.json file ...................................................................... cmake: create and link compile_commands.json file CMake has support to create a json file which contains exact information how each file in the project is compiled. This file can be consumed by clangd, which in turn provides precise symbol information to IDEs for better code navigation and contextual information. I use it with vscode to be able to quickly switch between native Linux and mingw builds and have the symbols info change dynamically with it. So handy that I think it is useful for others as well. Bump required CMake version for CREATE_LINK. Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64 Signed-off-by: Heiko Hund Acked-by: Frank Lichtenheld Message-Id: <20231220123659.55542-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27= 840.html Signed-off-by: Gert Doering --- M .gitignore M CMakeLists.txt 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a1da366..4153a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ m4/ltversion.m4 m4/lt~obsolete.m4 +compile_commands.json doc/openvpn-examples.5 doc/openvpn-examples.5.html doc/openvpn.8 diff --git a/CMakeLists.txt b/CMakeLists.txt index d40b213..bc46c27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.14) set(CMAKE_CONFIGURATION_TYPES "Release;Debug;ASAN") project(openvpn) @@ -42,6 +42,11 @@ set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of = the plugin directory") +# Create machine readable compile commands +set(CMAKE_EXPORT_COMPILE_COMMANDS 1) +file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json + ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLI= C) + # AddressSanitize - use CXX=3Dclang++ CC=3Dclang cmake -DCMAKE_BUILD_TYPE= =3Dasan to build with ASAN set(CMAKE_C_FLAGS_ASAN "-fsanitize=3Daddress,undefined -fno-sanitize-recover=3Dall -fno-optim= ize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointe= r -g -O1" -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/483?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad14739e202cea64 Gerrit-Change-Number: 483 Gerrit-PatchSet: 5 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --a5lSF7F4WFk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

cmake: create and link compile_commands.json f=
ile

CMake has support to create a json file which contains exact inf= ormation
how each file in the project is compiled. This file can be cons= umed by
clangd, which in turn provides precise symbol information to IDE= s for
better code navigation and contextual information.

I use it= with vscode to be able to quickly switch between native Linux and
mingw= builds and have the symbols info change dynamically with it. So
handy t= hat I think it is useful for others as well.

Bump required CMake ver= sion for CREATE_LINK.

Change-Id: Ib14c1161b4b0c9df797b9932ad14739e20= 2cea64
Signed-off-by: Heiko Hund <heiko@...2662...>
Acked-by: F= rank Lichtenheld <frank@...2641...>
Message-Id: <20231220123659= .55542-1-frank@...2641...>
URL: https://www.mail-archive.com/openvpn-= devel@lists.sourceforge.net/msg27840.html
Signed-off-by: Gert Doering &l= t;gert@...1296...>
---
M .gitignore
M CMakeLists.txt
2 files= changed, 7 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index a1da366..4153= a3e 100644
--- a/.gitignore
+++ b/.gitignor= e
@@ -40,6 +40,7 @@
m4/ltversion.m4=
m4/lt~obsolete.m4

+compile_commands.json
doc/openv= pn-examples.5
doc/openvpn-examples.5.html
= doc/openvpn.8
diff --git a/CMakeLists.txt b/CMakeLists.txt=
index d40b213..bc46c27 100644
--- a/CMakeL= ists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 = @@
-cmake_minimum_requi= red(VERSION 3.12)
+cm= ake_minimum_required(VERSION 3.14)
set(CMAKE_CONFIGURATION= _TYPES "Release;Debug;ASAN")
project(openvpn)

@@ -42,6 +42,11 @@
=
set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH &qu= ot;Location of the plugin directory")

+# Create machine readable compile = commands

+set(CMAKE_E= XPORT_COMPILE_COMMANDS 1)
+file(CREATE_LINK ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+ ${CMA= KE_CURRENT_SOURCE_DIR}/compile_commands.json SYMBOLIC)
+
# AddressSanitize - us= e CXX=3Dclang++ CC=3Dclang cmake -DCMAKE_BUILD_TYPE=3Dasan to build with AS= AN
set(CMAKE_C_FLAGS_ASAN
"-fsan= itize=3Daddress,undefined -fno-sanitize-recover=3Dall -fno-optimize-sibling= -calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1&qu= ot;

To view, visit change 483. To unsubscrib= e, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib14c1161b4b0c9df797b9932ad1= 4739e202cea64
Gerrit-Change-Number: 483
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <heiko@...515...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--a5lSF7F4WFk=--